diff options
author | Iain <qt-info@nokia.com> | 2009-05-26 15:17:31 (GMT) |
---|---|---|
committer | Iain <qt-info@nokia.com> | 2009-05-26 15:17:31 (GMT) |
commit | 82f8c6fbc0006d08638a397941f170e2bee6460d (patch) | |
tree | 3fc8b33e139a28d17482b9fe7bd349896cbd5ece /src | |
parent | 8d9b58cde5d1ad6c6684bcc3516cd3782b946bfc (diff) | |
parent | 4998ad5f72314b48ad8c8115b64f4cb4b747c2bc (diff) | |
download | Qt-82f8c6fbc0006d08638a397941f170e2bee6460d.zip Qt-82f8c6fbc0006d08638a397941f170e2bee6460d.tar.gz Qt-82f8c6fbc0006d08638a397941f170e2bee6460d.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Diffstat (limited to 'src')
181 files changed, 3248 insertions, 2502 deletions
diff --git a/src/3rdparty/phonon/phonon/phonon_export.h b/src/3rdparty/phonon/phonon/phonon_export.h index e579f67..5f93ea0 100644 --- a/src/3rdparty/phonon/phonon/phonon_export.h +++ b/src/3rdparty/phonon/phonon/phonon_export.h @@ -32,7 +32,11 @@ # define PHONON_EXPORT Q_DECL_IMPORT # endif # else /* UNIX */ -# define PHONON_EXPORT Q_DECL_EXPORT +# ifdef MAKE_PHONON_LIB /* We are building this library */ +# define PHONON_EXPORT Q_DECL_EXPORT +# else /* We are using this library */ +# define PHONON_EXPORT Q_DECL_IMPORT +# endif # endif #endif diff --git a/src/3rdparty/phonon/phonon/phononnamespace.h b/src/3rdparty/phonon/phonon/phononnamespace.h index 0bbf4f4..2492ee6 100644 --- a/src/3rdparty/phonon/phonon/phononnamespace.h +++ b/src/3rdparty/phonon/phonon/phononnamespace.h @@ -25,6 +25,11 @@ #include "phonon_export.h" +#ifdef __QT_SYNCQT__ +// Tell syncqt to create a "Global" header here +#pragma qt_class(Phonon::Global) +#endif + /** * Helper macro that can be used like * \code diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 26ce489..7d5d1c5 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - a6ebe3865025e2bb4d767a79435af4daf5a9b4db + 4ee8af9348b3f57d3c0f3575ae0a58336cf07a92 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 00bd427..072beee 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,143 @@ +2009-05-19 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org> + + Reviewed by Simon Hausmann. + + Do not call the parent implementation (Widget::) in show() and hide() + of the PluginViewQt, as it always changes the visible state of the + platformWidget (equal to the platformPluginWidget in the Qt port), + thus ignoring the isParentVisible() test. + + * plugins/qt/PluginViewQt.cpp: + (WebCore::PluginView::show): + (WebCore::PluginView::hide): + +2009-04-22 Tamas Szirbucz <szirbucz.tamas@stud.u-szeged.hu> + + Reviewed by Ariya Hidayat. + + https://bugs.webkit.org/show_bug.cgi?id=25023 + Delete reply in QNetworkReplyHandler::abort() to avoid leak. + + * platform/network/qt/QNetworkReplyHandler.cpp: + (WebCore::QNetworkReplyHandler::abort): + +2009-05-20 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Anders Carlsson. + + https://bugs.webkit.org/show_bug.cgi?id=24510 + + Fix a bug where the browserfuncs were not properly assigned, + make hasproperty use _NP_HasProperty and hasmethod _NP_HasMethod. + + Test: plugins/netscape-invoke-browserfuncs.html + + * plugins/gtk/PluginPackageGtk.cpp: + (WebCore::PluginPackage::load): Fix assignment + * plugins/qt/PluginPackageQt.cpp: + (WebCore::PluginPackage::load): Fix assignment + +2009-05-11 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Holger Freyther. + + Change Qt port to match the mac and windows ports, and unregister plugins when plugins are stopped. + Not doing that can cause assersion failure. + https://bugs.webkit.org/show_bug.cgi?id=25702 + + * plugins/qt/PluginViewQt.cpp: + (WebCore::PluginView::stop): + +2009-05-18 Ariya Hidayat <ariya.hidayat@nokia.com> + + Reviewed by Simon Hausmann. + + Done together with Balazs Kelemen <kelemen.balazs@stud.u-szeged.hu>. + + https://bugs.webkit.org/show_bug.cgi?id=24551 + + [Qt] Reuse FontPlatformData for the same FontDescription. + This effectively prevents growing heap usage for loading every web page. + + * platform/graphics/qt/FontCacheQt.cpp: + (WebCore::qHash): Necessary for FontPlatformDataCache. + (WebCore::FontCache::getCachedFontPlatformData): Reuse the instance if + it exists, otherwise create a new one and insert it in the cache. + +2009-05-18 Balazs Kelemen <kelemen.balazs@stud.u-szeged.hu> + + Reviewed by Ariya Hidayat. + + https://bugs.webkit.org/show_bug.cgi?id=24551 + + [Qt] Fix the leak in FontFallbackList::fontDataAt() function. + When creating a new instance of SimpleFontData, put it in the font list + so that it can deleted later on. + + * platform/graphics/qt/FontFallbackListQt.cpp: + (WebCore::FontFallbackList::invalidate): + (WebCore::FontFallbackList::releaseFontData): + (WebCore::FontFallbackList::fontDataAt): + +2009-05-15 Ariya Hidayat <ariya.hidayat@nokia.com> + + Reviewed by Holger Freyther. + + [Qt] In the image decoder, remove the raw image data represented as QImage + once the image is converted to QPixmap and inserted in the pixmap cache. + This effectively reduces the heap usage when running on graphics system + other than raster (i.e the case where QImage != QPixmap). + + * platform/graphics/qt/ImageDecoderQt.cpp: + (WebCore::ImageDecoderQt::imageAtIndex): Nullified the image on purpose. + * platform/graphics/qt/ImageDecoderQt.h: Made m_imageList mutable. + +2009-05-15 Ariya Hidayat <ariya.hidayat@nokia.com> + + Reviewed by Holger Freyther. + + [Qt] Refactor alpha channel detection the image decoder. + Sets the boolean flag as soon as the image is being read. + + * platform/graphics/qt/ImageDecoderQt.cpp: + (WebCore::ImageDecoderQt::ImageDecoderQt): Initialized m_hasAlphaChannel. + (WebCore::ImageDecoderQt::setData): Set the flag when appropriate. + (WebCore::ImageDecoderQt::supportsAlpha): Simplified. + (WebCore::ImageDecoderQt::reset): Resetted the flag. + * platform/graphics/qt/ImageDecoderQt.h: Added m_hasAlphaChannel. + +2009-05-13 Ariya Hidayat <ariya.hidayat@nokia.com> + + Reviewed by Sam Weinig. + + [Qt] Fix "lighther" composition mode. + QPainter::CompositionMode_Plus is the right match. + + * platform/graphics/qt/GraphicsContextQt.cpp: + (WebCore::toQtCompositionMode): + +2009-04-29 Ariya Hidayat <ariya.hidayat@nokia.com> + + Reviewed by Simon Fraser. + + [Qt] Initialize GraphicsContext's and ImageBuffer's QPainter to match + the default values of canvas attributes. + + * platform/graphics/qt/ImageBufferQt.cpp: + (WebCore::ImageBufferData::ImageBufferData): + +2009-04-27 Ariya Hidayat <ariya.hidayat@nokia.com> + + Reviewed by Tor Arne Vestbø. + + https://bugs.webkit.org/show_bug.cgi?id=18475 + + [Qt] Widget painting should follow the layout direction (LTR, RTL) + of the element style, not the application layout direction. + + * platform/qt/RenderThemeQt.cpp: + (WebCore::RenderThemeQt::applyTheme): + 2009-03-13 Adam Bergkvist <adam.bergkvist@ericsson.com> Reviewed by Alexey Proskuryakov. diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp index 8a31861..5d1f147 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp @@ -26,6 +26,9 @@ #include "FontDescription.h" #include "FontPlatformData.h" #include "Font.h" +#include "StringHash.h" + +#include <QHash> namespace WebCore { @@ -33,9 +36,31 @@ void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigne { } +typedef QHash<FontDescription, FontPlatformData*> FontPlatformDataCache; + +// using Q_GLOBAL_STATIC leads to crash. TODO investigate the way to fix this. +static FontPlatformDataCache* gFontPlatformDataCache; + +uint qHash(const FontDescription& key) +{ + uint value = CaseFoldingHash::hash(key.family().family()); + value ^= key.computedPixelSize(); + value ^= static_cast<int>(key.weight()); + return value; +} + FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& description, const AtomicString& family, bool checkingAlternateName) { - return new FontPlatformData(description); + if (!gFontPlatformDataCache) + gFontPlatformDataCache = new FontPlatformDataCache; + + FontPlatformData* fontData = gFontPlatformDataCache->value(description, 0); + if (!fontData) { + fontData = new FontPlatformData(description); + gFontPlatformDataCache->insert(description, fontData); + } + + return fontData; } SimpleFontData* FontCache::getCachedFontData(const FontPlatformData*) diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp index 22ae205..50627b7 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp @@ -42,8 +42,6 @@ FontFallbackList::FontFallbackList() void FontFallbackList::invalidate(WTF::PassRefPtr<WebCore::FontSelector> fontSelector) { - releaseFontData(); - m_fontList.clear(); m_familyIndex = 0; m_pitch = UnknownPitch; m_loadingCustomFonts = false; @@ -53,6 +51,9 @@ void FontFallbackList::invalidate(WTF::PassRefPtr<WebCore::FontSelector> fontSel void FontFallbackList::releaseFontData() { + if (m_fontList.size()) + delete m_fontList[0].first; + m_fontList.clear(); } void FontFallbackList::determinePitch(const WebCore::Font* font) const @@ -90,7 +91,12 @@ const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigne family = family->next(); } - return new SimpleFontData(FontPlatformData(description), _font->wordSpacing(), _font->letterSpacing()); + if (m_fontList.size()) + return m_fontList[0].first; + + const FontData* result = new SimpleFontData(FontPlatformData(description), _font->wordSpacing(), _font->letterSpacing()); + m_fontList.append(pair<const FontData*, bool>(result, result->isCustomFont())); + return result; } const FontData* FontFallbackList::fontDataForCharacters(const WebCore::Font* font, const UChar*, int) const diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 6c90ea3..490b54b 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -98,7 +98,7 @@ static inline QPainter::CompositionMode toQtCompositionMode(CompositeOperator op case CompositeHighlight: return QPainter::CompositionMode_SourceOver; case CompositePlusLighter: - return QPainter::CompositionMode_SourceOver; + return QPainter::CompositionMode_Plus; } return QPainter::CompositionMode_SourceOver; diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp index 29a02d4..333269e 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp @@ -47,7 +47,24 @@ ImageBufferData::ImageBufferData(const IntSize& size) : m_pixmap(size) { m_pixmap.fill(QColor(Qt::transparent)); - m_painter.set(new QPainter(&m_pixmap)); + + QPainter* painter = new QPainter(&m_pixmap); + m_painter.set(painter); + + // Since ImageBuffer is used mainly for Canvas, explicitly initialize + // its painter's pen and brush with the corresponding canvas defaults + // NOTE: keep in sync with CanvasRenderingContext2D::State + QPen pen = painter->pen(); + pen.setColor(Qt::black); + pen.setWidth(1); + pen.setCapStyle(Qt::FlatCap); + pen.setJoinStyle(Qt::MiterJoin); + pen.setMiterLimit(10); + painter->setPen(pen); + QBrush brush = painter->brush(); + brush.setColor(Qt::black); + painter->setBrush(brush); + painter->setCompositionMode(QPainter::CompositionMode_SourceOver); } ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success) diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp index 394c7a7..cd32428 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp @@ -197,7 +197,8 @@ ImageDecoderQt* ImageDecoderQt::create(const SharedBuffer& data) } ImageDecoderQt::ImageDecoderQt(const QString &imageFormat) - : m_imageFormat(imageFormat) + : m_hasAlphaChannel(false) + , m_imageFormat(imageFormat) { } @@ -212,6 +213,7 @@ bool ImageDecoderQt::hasFirstImageHeader() const void ImageDecoderQt::reset() { + m_hasAlphaChannel = false; m_failed = false; m_imageList.clear(); m_pixmapCache.clear(); @@ -230,6 +232,9 @@ void ImageDecoderQt::setData(const IncomingData &data, bool allDataReceived) const ReadContext::ReadResult readResult = readContext.read(allDataReceived); + if (hasFirstImageHeader()) + m_hasAlphaChannel = m_imageList[0].m_image.hasAlphaChannel(); + if (debugImageDecoderQt) qDebug() << " read returns " << readResult; @@ -280,7 +285,7 @@ int ImageDecoderQt::repetitionCount() const bool ImageDecoderQt::supportsAlpha() const { - return hasFirstImageHeader() && m_imageList[0].m_image.hasAlphaChannel(); + return m_hasAlphaChannel; } int ImageDecoderQt::duration(size_t index) const @@ -314,6 +319,10 @@ QPixmap* ImageDecoderQt::imageAtIndex(size_t index) const if (!m_pixmapCache.contains(index)) { m_pixmapCache.insert(index, QPixmap::fromImage(m_imageList[index].m_image)); + + // store null image since the converted pixmap is already in pixmap cache + Q_ASSERT(m_imageList[index].m_imageState == ImageComplete); + m_imageList[index].m_image = QImage(); } return &m_pixmapCache[index]; } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h index a2eb6aa..b8c3edd 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h @@ -81,8 +81,9 @@ private: int m_duration; }; + bool m_hasAlphaChannel; typedef QList<ImageData> ImageList; - ImageList m_imageList; + mutable ImageList m_imageList; mutable QHash<int, QPixmap> m_pixmapCache; int m_loopCount; QString m_imageFormat; diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index 2c730a6..3e9b239 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -174,6 +174,7 @@ void QNetworkReplyHandler::abort() if (m_reply) { QNetworkReply* reply = release(); reply->abort(); + reply->deleteLater(); deleteLater(); } } diff --git a/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp index a9da76b..02d17ed 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp @@ -737,6 +737,10 @@ ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) con if (isHovered(o)) option.state |= QStyle::State_MouseOver; + option.direction = Qt::LeftToRight; + if (o->style() && o->style()->direction() == WebCore::RTL) + option.direction = Qt::RightToLeft; + ControlPart result = o->style()->appearance(); switch (result) { diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp index 4387813..13f5394 100644 --- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp @@ -151,8 +151,8 @@ bool PluginPackage::load() m_browserFuncs.getproperty = _NPN_GetProperty; m_browserFuncs.setproperty = _NPN_SetProperty; m_browserFuncs.removeproperty = _NPN_RemoveProperty; - m_browserFuncs.hasproperty = _NPN_HasMethod; - m_browserFuncs.hasmethod = _NPN_HasProperty; + m_browserFuncs.hasproperty = _NPN_HasProperty; + m_browserFuncs.hasmethod = _NPN_HasMethod; m_browserFuncs.setexception = _NPN_SetException; m_browserFuncs.enumerate = _NPN_Enumerate; m_browserFuncs.construct = _NPN_Construct; diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp index c8dd0e5..e856f92 100644 --- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp @@ -58,6 +58,7 @@ #include "MouseEvent.h" #include "Page.h" #include "PlatformMouseEvent.h" +#include "PluginMainThreadScheduler.h" #include "RenderLayer.h" #include "Settings.h" @@ -112,7 +113,9 @@ void PluginView::show() if (isParentVisible() && platformPluginWidget()) platformPluginWidget()->setVisible(true); - Widget::show(); + // do not call parent impl. here as it will set the platformWidget + // (same as platformPluginWidget in the Qt port) to visible, even + // when parent isn't visible. } void PluginView::hide() @@ -122,7 +125,9 @@ void PluginView::hide() if (isParentVisible() && platformPluginWidget()) platformPluginWidget()->setVisible(false); - Widget::hide(); + // do not call parent impl. here as it will set the platformWidget + // (same as platformPluginWidget in the Qt port) to invisible, even + // when parent isn't visible. } void PluginView::paint(GraphicsContext* context, const IntRect& rect) @@ -225,6 +230,8 @@ void PluginView::stop() JSC::JSLock::DropAllLocks dropAllLocks(false); + PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance); + // Clear the window m_npWindow.window = 0; if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) { diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index c3bd633..d9f925a 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,28 @@ +2009-05-19 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org> + + Reviewed by Simon Hausmann. + + Fix a plugin bug in the WebKit code, similar to the one in WebCore. + + The problem is when a non visible QtPluginWidget would show it self + in a sibling frame. The problem was due to our clipping. In Qt, + if setMask is set with an empty QRegion, no clipping will + be performed, so in that case we hide the PluginContainer + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::): + +2009-03-27 Erik L. Bunce <elbunce@xendom.com> + + Reviewed by Simon Hausmann. + + https://bugs.webkit.org/show_bug.cgi?id=24746 + + Improved selection tests. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::textSelection): + 2009-04-24 Simon Hausmann <simon.hausmann@nokia.com> Rubber-stamped by Ariya Hidayat. diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index c421d42..a2b33c0 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -1058,7 +1058,13 @@ public: IntRect clipRect(static_cast<FrameView*>(parentScrollView)->windowClipRect()); clipRect.move(-windowRect.x(), -windowRect.y()); clipRect.intersect(platformWidget()->rect()); - platformWidget()->setMask(QRegion(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height())); + + QRegion clipRegion = QRegion(clipRect); + platformWidget()->setMask(clipRegion); + + // if setMask is set with an empty QRegion, no clipping will + // be performed, so in that case we hide the platformWidget + platformWidget()->setVisible(!clipRegion.isEmpty()); } }; diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index fe74fac..620aa31 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -872,14 +872,6 @@ void tst_QWebPage::textSelection() "<p>May the source<br/>be with you!</p></body></html>"); page->mainFrame()->setHtml(content); - // this will select the first paragraph - QString script = "var range = document.createRange(); " \ - "var node = document.getElementById(\"one\"); " \ - "range.selectNode(node); " \ - "getSelection().addRange(range);"; - page->mainFrame()->evaluateJavaScript(script); - QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); - // these actions must exist QVERIFY(page->action(QWebPage::SelectAll) != 0); QVERIFY(page->action(QWebPage::SelectNextChar) != 0); @@ -895,7 +887,8 @@ void tst_QWebPage::textSelection() QVERIFY(page->action(QWebPage::SelectStartOfDocument) != 0); QVERIFY(page->action(QWebPage::SelectEndOfDocument) != 0); - // right now they are disabled because contentEditable is false + // right now they are disabled because contentEditable is false and + // there isn't an existing selection to modify QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), false); QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), false); QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), false); @@ -912,11 +905,37 @@ void tst_QWebPage::textSelection() // ..but SelectAll is awalys enabled QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true); + // this will select the first paragraph + QString selectScript = "var range = document.createRange(); " \ + "var node = document.getElementById(\"one\"); " \ + "range.selectNode(node); " \ + "getSelection().addRange(range);"; + page->mainFrame()->evaluateJavaScript(selectScript); + QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); + + // here the actions are enabled after a selection has been created + QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), true); + // make it editable before navigating the cursor page->setContentEditable(true); + // cursor will be before the word "The", this makes sure there is a charet + page->triggerAction(QWebPage::MoveToStartOfDocument); + QVERIFY(page->isSelectionCollapsed()); + QCOMPARE(page->selectionStartOffset(), 0); + // here the actions are enabled after contentEditable is true - QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true); QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true); QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true); QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true); diff --git a/src/corelib/arch/qatomic_mips.h b/src/corelib/arch/qatomic_mips.h index b263aab..ea9954b 100644 --- a/src/corelib/arch/qatomic_mips.h +++ b/src/corelib/arch/qatomic_mips.h @@ -103,16 +103,25 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree() #if defined(Q_CC_GNU) && !defined(Q_OS_IRIX) +#if _MIPS_SIM == _ABIO32 +#define SET_MIPS2 ".set mips2\n\t" +#else +#define SET_MIPS2 +#endif + inline bool QBasicAtomicInt::ref() { register int originalValue; register int newValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" "ll %[originalValue], %[_q_value]\n" "addiu %[newValue], %[originalValue], %[one]\n" "sc %[newValue], %[_q_value]\n" "beqz %[newValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [_q_value] "+m" (_q_value), [newValue] "=&r" (newValue) @@ -125,12 +134,15 @@ inline bool QBasicAtomicInt::deref() { register int originalValue; register int newValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" "ll %[originalValue], %[_q_value]\n" "addiu %[newValue], %[originalValue], %[minusOne]\n" "sc %[newValue], %[_q_value]\n" "beqz %[newValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [_q_value] "+m" (_q_value), [newValue] "=&r" (newValue) @@ -143,7 +155,9 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) { register int result; register int tempValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" "ll %[result], %[_q_value]\n" "xor %[result], %[result], %[expectedValue]\n" "bnez %[result], 0f\n" @@ -153,6 +167,7 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) "beqz %[tempValue], 0b\n" "nop\n" "0:\n" + ".set pop\n" : [result] "=&r" (result), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -166,7 +181,9 @@ inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) { register int result; register int tempValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" "ll %[result], %[_q_value]\n" "xor %[result], %[result], %[expectedValue]\n" "bnez %[result], 0f\n" @@ -177,6 +194,7 @@ inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) "nop\n" "sync\n" "0:\n" + ".set pop\n" : [result] "=&r" (result), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -190,7 +208,9 @@ inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) { register int result; register int tempValue; - asm volatile("sync\n" + asm volatile(".set push\n" + SET_MIPS2 + "sync\n" "0:\n" "ll %[result], %[_q_value]\n" "xor %[result], %[result], %[expectedValue]\n" @@ -201,6 +221,7 @@ inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) "beqz %[tempValue], 0b\n" "nop\n" "0:\n" + ".set pop\n" : [result] "=&r" (result), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -219,12 +240,15 @@ inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) { register int originalValue; register int tempValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" "ll %[originalValue], %[_q_value]\n" "move %[tempValue], %[newValue]\n" "sc %[tempValue], %[_q_value]\n" "beqz %[tempValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -237,13 +261,16 @@ inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue) { register int originalValue; register int tempValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" "ll %[originalValue], %[_q_value]\n" "move %[tempValue], %[newValue]\n" "sc %[tempValue], %[_q_value]\n" "beqz %[tempValue], 0b\n" "nop\n" "sync\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -256,13 +283,16 @@ inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue) { register int originalValue; register int tempValue; - asm volatile("sync\n" + asm volatile(".set push\n" + SET_MIPS2 + "sync\n" "0:\n" "ll %[originalValue], %[_q_value]\n" "move %[tempValue], %[newValue]\n" "sc %[tempValue], %[_q_value]\n" "beqz %[tempValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -280,12 +310,15 @@ inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) { register int originalValue; register int newValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" "ll %[originalValue], %[_q_value]\n" "addu %[newValue], %[originalValue], %[valueToAdd]\n" "sc %[newValue], %[_q_value]\n" "beqz %[newValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [_q_value] "+m" (_q_value), [newValue] "=&r" (newValue) @@ -298,13 +331,16 @@ inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd) { register int originalValue; register int newValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" "ll %[originalValue], %[_q_value]\n" "addu %[newValue], %[originalValue], %[valueToAdd]\n" "sc %[newValue], %[_q_value]\n" "beqz %[newValue], 0b\n" "nop\n" "sync\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [_q_value] "+m" (_q_value), [newValue] "=&r" (newValue) @@ -317,13 +353,16 @@ inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) { register int originalValue; register int newValue; - asm volatile("sync\n" + asm volatile(".set push\n" + SET_MIPS2 + "sync\n" "0:\n" "ll %[originalValue], %[_q_value]\n" "addu %[newValue], %[originalValue], %[valueToAdd]\n" "sc %[newValue], %[_q_value]\n" "beqz %[newValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [_q_value] "+m" (_q_value), [newValue] "=&r" (newValue) @@ -350,7 +389,9 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValu { register T *result; register T *tempValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" LLP" %[result], %[_q_value]\n" "xor %[result], %[result], %[expectedValue]\n" "bnez %[result], 0f\n" @@ -360,6 +401,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValu "beqz %[tempValue], 0b\n" "nop\n" "0:\n" + ".set pop\n" : [result] "=&r" (result), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -374,7 +416,9 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValu { register T *result; register T *tempValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" LLP" %[result], %[_q_value]\n" "xor %[result], %[result], %[expectedValue]\n" "bnez %[result], 0f\n" @@ -385,6 +429,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValu "nop\n" "sync\n" "0:\n" + ".set pop\n" : [result] "=&r" (result), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -399,7 +444,9 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValu { register T *result; register T *tempValue; - asm volatile("sync\n" + asm volatile(".set push\n" + SET_MIPS2 + "sync\n" "0:\n" LLP" %[result], %[_q_value]\n" "xor %[result], %[result], %[expectedValue]\n" @@ -410,6 +457,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValu "beqz %[tempValue], 0b\n" "nop\n" "0:\n" + ".set pop\n" : [result] "=&r" (result), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -430,12 +478,15 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue) { register T *originalValue; register T *tempValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" LLP" %[originalValue], %[_q_value]\n" "move %[tempValue], %[newValue]\n" SCP" %[tempValue], %[_q_value]\n" "beqz %[tempValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -449,13 +500,16 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue) { register T *originalValue; register T *tempValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" LLP" %[originalValue], %[_q_value]\n" "move %[tempValue], %[newValue]\n" SCP" %[tempValue], %[_q_value]\n" "beqz %[tempValue], 0b\n" "nop\n" "sync\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -469,13 +523,16 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue) { register T *originalValue; register T *tempValue; - asm volatile("sync\n" + asm volatile(".set push\n" + SET_MIPS2 + "sync\n" "0:\n" LLP" %[originalValue], %[_q_value]\n" "move %[tempValue], %[newValue]\n" SCP" %[tempValue], %[_q_value]\n" "beqz %[tempValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [tempValue] "=&r" (tempValue), [_q_value] "+m" (_q_value) @@ -495,12 +552,15 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueTo { register T *originalValue; register T *newValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" LLP" %[originalValue], %[_q_value]\n" "addu %[newValue], %[originalValue], %[valueToAdd]\n" SCP" %[newValue], %[_q_value]\n" "beqz %[newValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [_q_value] "+m" (_q_value), [newValue] "=&r" (newValue) @@ -514,13 +574,16 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueTo { register T *originalValue; register T *newValue; - asm volatile("0:\n" + asm volatile(".set push\n" + SET_MIPS2 + "0:\n" LLP" %[originalValue], %[_q_value]\n" "addu %[newValue], %[originalValue], %[valueToAdd]\n" SCP" %[newValue], %[_q_value]\n" "beqz %[newValue], 0b\n" "nop\n" "sync\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [_q_value] "+m" (_q_value), [newValue] "=&r" (newValue) @@ -534,13 +597,16 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueTo { register T *originalValue; register T *newValue; - asm volatile("sync\n" + asm volatile(".set push\n" + SET_MIPS2 + "sync\n" "0:\n" LLP" %[originalValue], %[_q_value]\n" "addu %[newValue], %[originalValue], %[valueToAdd]\n" SCP" %[newValue], %[_q_value]\n" "beqz %[newValue], 0b\n" "nop\n" + ".set pop\n" : [originalValue] "=&r" (originalValue), [_q_value] "+m" (_q_value), [newValue] "=&r" (newValue) diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp index ea35e9e..39d7698 100644 --- a/src/corelib/concurrent/qfuturewatcher.cpp +++ b/src/corelib/concurrent/qfuturewatcher.cpp @@ -465,7 +465,7 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event) break; emit q->progressValueChanged(event->index1); - if (event->text != QString()) // ### + if (!event->text.isNull()) // ### q->progressTextChanged(event->text); break; case QFutureCallOutEvent::ProgressRange: diff --git a/src/corelib/concurrent/qtconcurrentiteratekernel.cpp b/src/corelib/concurrent/qtconcurrentiteratekernel.cpp index 5c20146..bfc0e82 100644 --- a/src/corelib/concurrent/qtconcurrentiteratekernel.cpp +++ b/src/corelib/concurrent/qtconcurrentiteratekernel.cpp @@ -108,11 +108,17 @@ static qint64 getticks() return 0; return (ts.tv_sec * 1000000000) + ts.tv_nsec; #else + +#ifdef Q_OS_SYMBIAN + return clock(); +#else // no clock_gettime(), fall back to wall time struct timeval tv; gettimeofday(&tv, 0); return (tv.tv_sec * 1000000) + tv.tv_usec; #endif + +#endif } #elif defined(Q_OS_WIN) diff --git a/src/corelib/concurrent/qtconcurrentiteratekernel.h b/src/corelib/concurrent/qtconcurrentiteratekernel.h index 38d2824..5cf4ebe 100644 --- a/src/corelib/concurrent/qtconcurrentiteratekernel.h +++ b/src/corelib/concurrent/qtconcurrentiteratekernel.h @@ -181,7 +181,10 @@ public: typedef T ResultType; IterateKernel(Iterator _begin, Iterator _end) -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION +#if defined (QT_NO_STL) + : begin(_begin), end(_end), current(_begin), currentIndex(0), + forIteration(false), progressReportingEnabled(true) +#elif !defined(QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION) : begin(_begin), end(_end), current(_begin), currentIndex(0), forIteration(selectIteration(typename std::iterator_traits<Iterator>::iterator_category())), progressReportingEnabled(true) #else @@ -189,7 +192,12 @@ public: forIteration(selectIteration(std::iterator_category(_begin))), progressReportingEnabled(true) #endif { +#if defined (QT_NO_STL) + iterationCount = 0; +#else iterationCount = forIteration ? std::distance(_begin, _end) : 0; + +#endif } virtual ~IterateKernel() { } diff --git a/src/corelib/concurrent/qtconcurrentthreadengine.h b/src/corelib/concurrent/qtconcurrentthreadengine.h index 9e7d12e..444e0db 100644 --- a/src/corelib/concurrent/qtconcurrentthreadengine.h +++ b/src/corelib/concurrent/qtconcurrentthreadengine.h @@ -51,6 +51,7 @@ #include <QtCore/qdebug.h> #include <QtCore/qtconcurrentexception.h> #include <QtCore/qwaitcondition.h> +#include <QtCore/qmutex.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 15b2d53..27aaac1 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1118,7 +1118,7 @@ class QDataStream; #ifndef Q_DECL_EXPORT # ifdef Q_OS_WIN # define Q_DECL_EXPORT __declspec(dllexport) -# elif defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) +# elif defined(Q_CC_NOKIAX86) # define Q_DECL_EXPORT __declspec(dllexport) # elif defined(QT_VISIBILITY_AVAILABLE) # define Q_DECL_EXPORT __attribute__((visibility("default"))) @@ -1130,7 +1130,7 @@ class QDataStream; #ifndef Q_DECL_IMPORT # if defined(Q_OS_WIN) # define Q_DECL_IMPORT __declspec(dllimport) -# elif defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) +# elif defined(Q_CC_NOKIAX86) # define Q_DECL_IMPORT __declspec(dllimport) # else # define Q_DECL_IMPORT diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index b14f436..81bfb27 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -201,8 +201,8 @@ void QDirIteratorPrivate::advance() QString subDir = it->currentFilePath(); #ifdef Q_OS_WIN - if (currentFileInfo.isSymLink()) - subDir = currentFileInfo.canonicalFilePath(); + if (nextFileInfo.isSymLink()) + subDir = nextFileInfo.canonicalFilePath(); #endif pushSubDirectory(subDir, it->nameFilters(), it->filters()); } diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 4a20c97..551485d 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -718,26 +718,29 @@ QFile::rename(const QString &newName) return true; } - QFile in(fileName()); + if (isSequential()) { + d->setError(QFile::RenameError, tr("Will not rename sequential file using block copy")); + return false; + } + QFile out(newName); - if (in.open(QIODevice::ReadOnly)) { + if (open(QIODevice::ReadOnly)) { if (out.open(QIODevice::WriteOnly | QIODevice::Truncate)) { bool error = false; char block[4096]; - qint64 read; - while ((read = in.read(block, sizeof(block))) > 0) { - if (read != out.write(block, read)) { + qint64 bytes; + while ((bytes = read(block, sizeof(block))) > 0) { + if (bytes != out.write(block, bytes)) { d->setError(QFile::RenameError, out.errorString()); error = true; break; } } - if (read == -1) { - d->setError(QFile::RenameError, in.errorString()); + if (bytes == -1) { + d->setError(QFile::RenameError, errorString()); error = true; } if(!error) { - in.close(); if (!remove()) { d->setError(QFile::RenameError, tr("Cannot remove source file")); error = true; @@ -747,12 +750,16 @@ QFile::rename(const QString &newName) out.remove(); } else { fileEngine()->setFileName(newName); + setPermissions(permissions()); + unsetError(); setFileName(newName); } + close(); return !error; } + close(); } - d->setError(QFile::RenameError, out.isOpen() ? in.errorString() : out.errorString()); + d->setError(QFile::RenameError, out.isOpen() ? errorString() : out.errorString()); } return false; } @@ -914,6 +921,7 @@ QFile::copy(const QString &newName) out.setAutoRemove(false); #endif } + close(); } if(!error) { QFile::setPermissions(newName, permissions()); diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 61ea7cc..07f3c9c 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -312,6 +312,10 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh) if (ret == -1) { q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, qt_error_string(int(errno))); + + this->openMode = QIODevice::NotOpen; + this->fh = 0; + return false; } } @@ -335,6 +339,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd) if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append))) openMode |= QFile::Truncate; + d->openMode = openMode; d->lastFlushFailed = false; d->closeFileHandle = false; d->nativeFilePath.clear(); @@ -367,6 +372,10 @@ bool QFSFileEnginePrivate::openFd(QIODevice::OpenMode openMode, int fd) if (ret == -1) { q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, qt_error_string(int(errno))); + + this->openMode = QIODevice::NotOpen; + this->fd = -1; + return false; } } @@ -868,6 +877,119 @@ bool QFSFileEngine::supportsExtension(Extension extension) const return false; } +/*! \fn bool QFSFileEngine::caseSensitive() const + Returns true for Windows, false for Unix. +*/ + +/*! \fn bool QFSFileEngine::copy(const QString ©Name) + + For windows, copy the file to file \a copyName. + + Not implemented for Unix. +*/ + +/*! \fn QString QFSFileEngine::currentPath(const QString &fileName) + For Unix, returns the current working directory for the file + engine. + + For Windows, returns the canonicalized form of the current path used + by the file engine for the drive specified by \a fileName. On + Windows, each drive has its own current directory, so a different + path is returned for file names that include different drive names + (e.g. A: or C:). + + \sa setCurrentPath() +*/ + +/*! \fn QFileInfoList QFSFileEngine::drives() + For Windows, returns the list of drives in the file system as a list + of QFileInfo objects. On unix, Mac OS X and Windows CE, only the + root path is returned. On Windows, this function returns all drives + (A:\, C:\, D:\, etc.). + + For Unix, the list contains just the root path "/". +*/ + +/*! \fn QString QFSFileEngine::fileName(FileName file) const + \reimp +*/ + +/*! \fn QDateTime QFSFileEngine::fileTime(FileTime time) const + \reimp +*/ + +/*! \fn QString QFSFileEngine::homePath() + Returns the home path of the current user. + + \sa rootPath() +*/ + +/*! \fn bool QFSFileEngine::isRelativePath() const + \reimp +*/ + +/*! \fn bool QFSFileEngine::link(const QString &newName) + + Creates a link from the file currently specified by fileName() to + \a newName. What a link is depends on the underlying filesystem + (be it a shortcut on Windows or a symbolic link on Unix). Returns + true if successful; otherwise returns false. +*/ + +/*! \fn bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const + \reimp +*/ + +/*! \fn uint QFSFileEngine::ownerId(FileOwner own) const + In Unix, if stat() is successful, the \c uid is returned if + \a own is the owner. Otherwise the \c gid is returned. If stat() + is unsuccessful, -2 is reuturned. + + For Windows, -2 is always returned. +*/ + +/*! \fn QString QFSFileEngine::owner(FileOwner own) const + \reimp +*/ + +/*! \fn bool QFSFileEngine::remove() + \reimp +*/ + +/*! \fn bool QFSFileEngine::rename(const QString &newName) + \reimp +*/ + +/*! \fn bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const + \reimp +*/ + +/*! \fn QString QFSFileEngine::rootPath() + Returns the root path. + + \sa homePath() +*/ + +/*! \fn bool QFSFileEngine::setCurrentPath(const QString &path) + Sets the current path (e.g., for QDir), to \a path. Returns true if the + new path exists; otherwise this function does nothing, and returns false. + + \sa currentPath() +*/ + +/*! \fn bool QFSFileEngine::setPermissions(uint perms) + \reimp +*/ + +/*! \fn bool QFSFileEngine::setSize(qint64 size) + \reimp +*/ + +/*! \fn QString QFSFileEngine::tempPath() + Returns the temporary path (i.e., a path in which it is safe + to store temporary files). +*/ + QT_END_NAMESPACE #endif // QT_NO_FSFILEENGINE diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 4747bcc..e595f15 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -293,9 +293,8 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) int oldFlags = fcntl(QT_FILENO(fh), F_GETFL); for (int i = 0; i < 2; ++i) { // Unix: Make the underlying file descriptor non-blocking - int v = 1; if ((oldFlags & O_NONBLOCK) == 0) - fcntl(QT_FILENO(fh), F_SETFL, oldFlags | O_NONBLOCK, &v, sizeof(v)); + fcntl(QT_FILENO(fh), F_SETFL, oldFlags | O_NONBLOCK); // Cross platform stdlib read size_t read = 0; @@ -313,8 +312,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) // Unix: Restore the blocking state of the underlying socket if ((oldFlags & O_NONBLOCK) == 0) { - int v = 1; - fcntl(QT_FILENO(fh), F_SETFL, oldFlags, &v, sizeof(v)); + fcntl(QT_FILENO(fh), F_SETFL, oldFlags); if (readBytes == 0) { int readByte = 0; do { @@ -331,8 +329,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) } // Unix: Restore the blocking state of the underlying socket if ((oldFlags & O_NONBLOCK) == 0) { - int v = 1; - fcntl(QT_FILENO(fh), F_SETFL, oldFlags, &v, sizeof(v)); + fcntl(QT_FILENO(fh), F_SETFL, oldFlags); } if (readBytes == 0 && !feof(fh)) { // if we didn't read anything and we're not at EOF, it must be an error @@ -1045,7 +1042,7 @@ QString QFSFileEngine::fileName(FileName file) const #endif if (len > 0) { QString ret; - if (S_ISDIR(d->st.st_mode) && s[0] != '/') { + if (d->doStat() && S_ISDIR(d->st.st_mode) && s[0] != '/') { QDir parent(d->filePath); parent.cdUp(); ret = parent.path(); diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 2df13f0..6ae13e9 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -946,9 +946,6 @@ bool QFSFileEnginePrivate::nativeIsSequential() const return false; } -/*! - \reimp -*/ bool QFSFileEngine::remove() { Q_D(QFSFileEngine); @@ -959,9 +956,6 @@ bool QFSFileEngine::remove() }); } -/*! - \reimp -*/ bool QFSFileEngine::copy(const QString ©Name) { Q_D(QFSFileEngine); @@ -974,9 +968,6 @@ bool QFSFileEngine::copy(const QString ©Name) }); } -/*! - \reimp -*/ bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); @@ -1017,9 +1008,6 @@ static inline bool mkDir(const QString &path) }); } -/*! - \reimp -*/ static inline bool rmDir(const QString &path) { QT_WA({ @@ -1029,9 +1017,6 @@ static inline bool rmDir(const QString &path) }); } -/*! - \reimp -*/ static inline bool isDirPath(const QString &dirPath, bool *existed) { QString path = dirPath; @@ -1054,9 +1039,6 @@ static inline bool isDirPath(const QString &dirPath, bool *existed) return fileAttrib & FILE_ATTRIBUTE_DIRECTORY; } -/*! - \reimp -*/ bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const { QString dirName = name; @@ -1097,9 +1079,6 @@ bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) con return mkDir(name); } -/*! - \reimp -*/ bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const { QString dirName = name; @@ -1120,20 +1099,11 @@ bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) co return rmDir(name); } -/*! - \reimp -*/ bool QFSFileEngine::caseSensitive() const { return false; } -/*! - Sets the current path (e.g., for QDir), to \a path. Returns true if the - new path exists; otherwise this function does nothing, and returns false. - - \sa currentPath() -*/ bool QFSFileEngine::setCurrentPath(const QString &path) { if (!QDir(path).exists()) @@ -1153,16 +1123,6 @@ bool QFSFileEngine::setCurrentPath(const QString &path) #endif } -/*! - Returns the canonicalized form of the current path used by the file - engine for the drive specified by \a fileName. - - On Windows, each drive has its own current directory, so a different - path is returned for file names that include different drive names - (e.g. A: or C:). - - \sa setCurrentPath() -*/ QString QFSFileEngine::currentPath(const QString &fileName) { #if !defined(Q_OS_WINCE) @@ -1219,11 +1179,6 @@ QString QFSFileEngine::currentPath(const QString &fileName) #endif } -/*! - Returns the home path of the current user. - - \sa rootPath() -*/ QString QFSFileEngine::homePath() { QString ret; @@ -1277,11 +1232,6 @@ QString QFSFileEngine::homePath() return QDir::fromNativeSeparators(ret); } -/*! - Returns the root path. - - \sa homePath() -*/ QString QFSFileEngine::rootPath() { #if defined(Q_OS_WINCE) @@ -1299,10 +1249,6 @@ QString QFSFileEngine::rootPath() return ret; } -/*! - Returns the temporary path (i.e., a path in which it is safe to store - temporary files). -*/ QString QFSFileEngine::tempPath() { QString ret; @@ -1330,11 +1276,6 @@ QString QFSFileEngine::tempPath() return ret; } -/*! - Returns the list of drives in the file system as a list of QFileInfo - objects. On unix, Mac OS X and Windows CE, only the root path is returned. - On Windows, this function returns all drives (A:\, C:\, D:\, etc.). -*/ QFileInfoList QFSFileEngine::drives() { QFileInfoList ret; @@ -1556,9 +1497,6 @@ QString QFSFileEnginePrivate::getLink() const return readLink(filePath); } -/*! - \reimp -*/ bool QFSFileEngine::link(const QString &newName) { #if !defined(Q_OS_WINCE) @@ -1816,9 +1754,6 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil return ret; } -/*! - \reimp -*/ QString QFSFileEngine::fileName(FileName file) const { Q_D(const QFSFileEngine); @@ -1912,9 +1847,6 @@ QString QFSFileEngine::fileName(FileName file) const return d->filePath; } -/*! - \reimp -*/ bool QFSFileEngine::isRelativePath() const { Q_D(const QFSFileEngine); @@ -1924,18 +1856,12 @@ bool QFSFileEngine::isRelativePath() const || (d->filePath.at(0) == QLatin1Char('/') && d->filePath.at(1) == QLatin1Char('/'))))); // drive, e.g. a: } -/*! - \reimp -*/ uint QFSFileEngine::ownerId(FileOwner /*own*/) const { static const uint nobodyID = (uint) -2; return nobodyID; } -/*! - \reimp -*/ QString QFSFileEngine::owner(FileOwner own) const { #if !defined(QT_NO_LIBRARY) @@ -1974,9 +1900,6 @@ QString QFSFileEngine::owner(FileOwner own) const return QString(QLatin1String("")); } -/*! - \reimp -*/ bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); @@ -2003,9 +1926,6 @@ bool QFSFileEngine::setPermissions(uint perms) return ret; } -/*! - \reimp -*/ bool QFSFileEngine::setSize(qint64 size) { Q_D(QFSFileEngine); @@ -2075,9 +1995,6 @@ static inline QDateTime fileTimeToQDateTime(const FILETIME *time) return ret; } -/*! - \reimp -*/ QDateTime QFSFileEngine::fileTime(FileTime time) const { Q_D(const QFSFileEngine); diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index fe3ceff..3816803 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -945,9 +945,9 @@ QByteArray QIODevice::readAll() QByteArray tmp; if (d->isSequential() || size() == 0) { - // Read it in chunks, bytesAvailable() is unreliable for sequential - // devices. - const int chunkSize = 4096; + // Read it in chunks. Use bytesAvailable() as an unreliable hint for + // sequential devices, but try to read 4K as a minimum. + int chunkSize = qMax(qint64(4096), bytesAvailable()); qint64 totalRead = 0; forever { tmp.resize(tmp.size() + chunkSize); @@ -956,6 +956,7 @@ QByteArray QIODevice::readAll() if (readBytes <= 0) return tmp; totalRead += readBytes; + chunkSize = qMax(qint64(4096), bytesAvailable()); } } else { // Read it all in one go. diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 33d4a47..1fedd55 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -140,15 +140,6 @@ static void qt_native_close(int fd) } while (ret == -1 && errno == EINTR); } -static void qt_native_sigaction(int signum, const struct sigaction *act, - struct sigaction *oldact) -{ - int ret; - do { - ret = ::sigaction(signum, act, oldact); - } while (ret == -1 && errno == EINTR); -} - static void qt_native_dup2(int oldfd, int newfd) { int ret; @@ -255,7 +246,7 @@ QProcessManager::QProcessManager() memset(&action, 0, sizeof(action)); action.sa_handler = qt_sa_sigchld_handler; action.sa_flags = SA_NOCLDSTOP; - qt_native_sigaction(SIGCHLD, &action, &oldAction); + ::sigaction(SIGCHLD, &action, &oldAction); if (oldAction.sa_handler != qt_sa_sigchld_handler) qt_sa_old_sigchld_handler = oldAction.sa_handler; } @@ -282,9 +273,9 @@ QProcessManager::~QProcessManager() memset(&action, 0, sizeof(action)); action.sa_handler = qt_sa_old_sigchld_handler; action.sa_flags = SA_NOCLDSTOP; - qt_native_sigaction(SIGCHLD, &action, &oldAction); + ::sigaction(SIGCHLD, &action, &oldAction); if (oldAction.sa_handler != qt_sa_sigchld_handler) { - qt_native_sigaction(SIGCHLD, &oldAction, 0); + ::sigaction(SIGCHLD, &oldAction, 0); } } @@ -900,7 +891,7 @@ static void qt_ignore_sigpipe() struct sigaction noaction; memset(&noaction, 0, sizeof(noaction)); noaction.sa_handler = SIG_IGN; - qt_native_sigaction(SIGPIPE, &noaction, 0); + ::sigaction(SIGPIPE, &noaction, 0); } } @@ -1270,7 +1261,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a struct sigaction noaction; memset(&noaction, 0, sizeof(noaction)); noaction.sa_handler = SIG_IGN; - qt_native_sigaction(SIGPIPE, &noaction, 0); + ::sigaction(SIGPIPE, &noaction, 0); ::setsid(); @@ -1316,7 +1307,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a struct sigaction noaction; memset(&noaction, 0, sizeof(noaction)); noaction.sa_handler = SIG_IGN; - qt_native_sigaction(SIGPIPE, &noaction, 0); + ::sigaction(SIGPIPE, &noaction, 0); // '\1' means execv failed char c = '\1'; @@ -1327,7 +1318,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a struct sigaction noaction; memset(&noaction, 0, sizeof(noaction)); noaction.sa_handler = SIG_IGN; - qt_native_sigaction(SIGPIPE, &noaction, 0); + ::sigaction(SIGPIPE, &noaction, 0); // '\2' means internal error char c = '\2'; diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index a1f921e..1f77caa 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -406,7 +406,7 @@ QString QResource::absoluteFilePath() const } /*! - Returns true if the resource really exists in the resource heirarchy, + Returns true if the resource really exists in the resource hierarchy, false otherwise. */ diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 484e79a..14fc2d4 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2295,7 +2295,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, As mentioned in the \l{Fallback Mechanism} section, QSettings stores settings for an application in up to four locations, depending on whether the settings are user-specific or - system-wide and whether the the settings are application-specific + system-wide and whether the settings are application-specific or organization-wide. For simplicity, we're assuming the organization is called MySoft and the application is called Star Runner. diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index e120f28..45a03e3 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -291,14 +291,22 @@ class QTemporaryFileEngine : public QFSFileEngine { Q_DECLARE_PRIVATE(QFSFileEngine) public: - QTemporaryFileEngine(const QString &file) : QFSFileEngine(file) { } + QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true) + : QFSFileEngine(file), filePathIsTemplate(fileIsTemplate) + { + } + ~QTemporaryFileEngine(); + bool isReallyOpen(); void setFileName(const QString &file); bool open(QIODevice::OpenMode flags); bool remove(); + bool rename(const QString &newName); bool close(); + + bool filePathIsTemplate; }; QTemporaryFileEngine::~QTemporaryFileEngine() @@ -306,6 +314,21 @@ QTemporaryFileEngine::~QTemporaryFileEngine() QFSFileEngine::close(); } +bool QTemporaryFileEngine::isReallyOpen() +{ + Q_D(QFSFileEngine); + + if (!((0 == d->fh) && (-1 == d->fd) +#if defined Q_OS_WIN + && (INVALID_HANDLE_VALUE == d->fileHandle) +#endif + )) + return true; + + return false; + +} + void QTemporaryFileEngine::setFileName(const QString &file) { // Really close the file, so we don't leak @@ -316,13 +339,16 @@ void QTemporaryFileEngine::setFileName(const QString &file) bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) { Q_D(QFSFileEngine); + Q_ASSERT(!isReallyOpen()); + + if (!filePathIsTemplate) + return QFSFileEngine::open(openMode); QString qfilename = d->filePath; if(!qfilename.contains(QLatin1String("XXXXXX"))) qfilename += QLatin1String(".XXXXXX"); int suffixLength = qfilename.length() - (qfilename.lastIndexOf(QLatin1String("XXXXXX"), -1, Qt::CaseSensitive) + 6); - d->closeFileHandle = true; char *filename = qstrdup(qfilename.toLocal8Bit()); #ifndef Q_WS_WIN @@ -330,16 +356,20 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) if (fd != -1) { // First open the fd as an external file descriptor to // initialize the engine properly. - QFSFileEngine::open(openMode, fd); + if (QFSFileEngine::open(openMode, fd)) { - // Allow the engine to close the handle even if it's "external". - d->closeFileHandle = true; + // Allow the engine to close the handle even if it's "external". + d->closeFileHandle = true; - // Restore the file names (open() resets them). - d->filePath = QString::fromLocal8Bit(filename); //changed now! - d->nativeInitFileName(); - delete [] filename; - return true; + // Restore the file names (open() resets them). + d->filePath = QString::fromLocal8Bit(filename); //changed now! + filePathIsTemplate = false; + d->nativeInitFileName(); + delete [] filename; + return true; + } + + QT_CLOSE(fd); } delete [] filename; setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, qt_error_string(errno)); @@ -351,6 +381,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) } d->filePath = QString::fromLocal8Bit(filename); + filePathIsTemplate = false; d->nativeInitFileName(); d->closeFileHandle = true; delete [] filename; @@ -364,9 +395,17 @@ bool QTemporaryFileEngine::remove() // Since the QTemporaryFileEngine::close() does not really close the file, // we must explicitly call QFSFileEngine::close() before we remove it. QFSFileEngine::close(); - bool removed = QFSFileEngine::remove(); - d->filePath.clear(); - return removed; + if (QFSFileEngine::remove()) { + d->filePath.clear(); + return true; + } + return false; +} + +bool QTemporaryFileEngine::rename(const QString &newName) +{ + QFSFileEngine::close(); + return QFSFileEngine::rename(newName); } bool QTemporaryFileEngine::close() @@ -388,17 +427,14 @@ protected: bool autoRemove; QString templateName; - mutable QTemporaryFileEngine *fileEngine; }; -QTemporaryFilePrivate::QTemporaryFilePrivate() : autoRemove(true), fileEngine(0) +QTemporaryFilePrivate::QTemporaryFilePrivate() : autoRemove(true) { } QTemporaryFilePrivate::~QTemporaryFilePrivate() { - delete fileEngine; - fileEngine = 0; } //************* QTemporaryFile @@ -430,8 +466,8 @@ QTemporaryFilePrivate::~QTemporaryFilePrivate() file will exist and be kept open internally by QTemporaryFile. The file name of the temporary file can be found by calling fileName(). - Note that this is only defined while the file is open; the function returns - an empty string before the file is opened and after it is closed. + Note that this is only defined after the file is first opened; the function + returns an empty string before this. A temporary file will have some static part of the name and some part that is calculated to be unique. The default filename \c @@ -605,7 +641,8 @@ void QTemporaryFile::setAutoRemove(bool b) QString QTemporaryFile::fileName() const { - if(!isOpen()) + Q_D(const QTemporaryFile); + if(d->fileName.isEmpty()) return QString(); return fileEngine()->fileName(QAbstractFileEngine::DefaultName); } @@ -699,8 +736,12 @@ QTemporaryFile *QTemporaryFile::createLocalFile(QFile &file) QAbstractFileEngine *QTemporaryFile::fileEngine() const { Q_D(const QTemporaryFile); - if(!d->fileEngine) - d->fileEngine = new QTemporaryFileEngine(d->templateName); + if(!d->fileEngine) { + if (d->fileName.isEmpty()) + d->fileEngine = new QTemporaryFileEngine(d->templateName); + else + d->fileEngine = new QTemporaryFileEngine(d->fileName, false); + } return d->fileEngine; } @@ -715,10 +756,13 @@ bool QTemporaryFile::open(OpenMode flags) { Q_D(QTemporaryFile); if (!d->fileName.isEmpty()) { - setOpenMode(flags); - return true; + if (static_cast<QTemporaryFileEngine*>(fileEngine())->isReallyOpen()) { + setOpenMode(flags); + return true; + } } + flags |= QIODevice::ReadWrite; if (QFile::open(flags)) { d->fileName = d->fileEngine->fileName(QAbstractFileEngine::DefaultName); return true; @@ -726,6 +770,8 @@ bool QTemporaryFile::open(OpenMode flags) return false; } +QT_END_NAMESPACE + #endif // QT_NO_TEMPORARYFILE -QT_END_NAMESPACE + diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 9ce9a2e..d1a5cdd 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -4759,6 +4759,12 @@ void QUrl::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &que Inserts the pair \a key = \a value into the query string of the URL. + The key/value pair is encoded before it is added to the query. The + pair is converted into separate strings internally. The \a key and + \a value is first encoded into UTF-8 and then delimited by the + character returned by valueDelimiter(). Each key/value pair is + delimited by the character returned by pairDelimiter(). + \sa addEncodedQueryItem() */ void QUrl::addQueryItem(const QString &key, const QString &value) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 12b80f6..7d8a77a 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1728,7 +1728,7 @@ QString QCoreApplication::applicationDirPath() } QCoreApplicationPrivate *d = self->d_func(); - if (d->cachedApplicationDirPath == QString()) + if (d->cachedApplicationDirPath.isNull()) #if defined(Q_OS_SYMBIAN) { QString appPath; @@ -1781,7 +1781,7 @@ QString QCoreApplication::applicationFilePath() } QCoreApplicationPrivate *d = self->d_func(); - if (d->cachedApplicationFilePath != QString()) + if (!d->cachedApplicationFilePath.isNull()) return d->cachedApplicationFilePath; #if defined( Q_WS_WIN ) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 3282b7c..d745406 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -22,7 +22,7 @@ QT_BEGIN_NAMESPACE #define WAKE_UP_PRIORITY CActive::EPriorityStandard #define TIMER_PRIORITY CActive::EPriorityLow -#define COMPLETE_ZERO_TIMERS_PRIORITY CActive::EPriorityIdle +#define COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY CActive::EPriorityIdle static inline int qt_pipe_write(int socket, const char *data, qint64 len) { @@ -82,6 +82,61 @@ private: QMutex *m_mutex; }; +/* + * This class is designed to aid in implementing event handling in a more round robin fashion. We + * cannot change active objects that we do not own, but the active objects that Qt owns will use + * this as a base class with convenience functions. + * + * Here is how it works: On every RunL, the deriving class should call okToRun(). This will allow + * exactly one run of the active object, and mark it as such. If it is called again, it will return + * false, and add the object to a queue so it can be run later. + * + * The QCompleteDeferredAOs class is a special object that runs after all others, which will + * reactivate the objects that were previously not run. + */ +inline QActiveObject::QActiveObject(TInt priority, QEventDispatcherSymbian *dispatcher) + : CActive(priority), + m_dispatcher(dispatcher), + m_hasAlreadyRun(false), + m_hasRunAgain(false), + m_iterationCount(1) +{ +} + +QActiveObject::~QActiveObject() +{ + if (m_hasRunAgain) + m_dispatcher->removeDeferredActiveObject(this); +} + +bool QActiveObject::okToRun() +{ + Q_ASSERT(!m_hasRunAgain); + + if (!m_hasAlreadyRun || m_dispatcher->iterationCount() != m_iterationCount) { + // First occurrence of this event in this iteration. + m_hasAlreadyRun = true; + m_iterationCount = m_dispatcher->iterationCount(); + return true; + } else { + // The event has already occurred. + m_dispatcher->addDeferredActiveObject(this); + m_hasRunAgain = true; + return false; + } +} + +void QActiveObject::reactivateAndComplete() +{ + iStatus = KRequestPending; + SetActive(); + TRequestStatus *status = &iStatus; + QEventDispatcherSymbian::RequestComplete(status, KErrNone); + + m_hasRunAgain = false; + m_hasAlreadyRun = false; +} + QWakeUpActiveObject::QWakeUpActiveObject(QEventDispatcherSymbian *dispatcher) : CActive(WAKE_UP_PRIORITY), m_dispatcher(dispatcher) @@ -111,8 +166,8 @@ void QWakeUpActiveObject::RunL() m_dispatcher->wakeUpWasCalled(); } -QTimerActiveObject::QTimerActiveObject(SymbianTimerInfo *timerInfo) - : CActive(TIMER_PRIORITY), +QTimerActiveObject::QTimerActiveObject(QEventDispatcherSymbian *dispatcher, SymbianTimerInfo *timerInfo) + : QActiveObject(TIMER_PRIORITY, dispatcher), m_timerInfo(timerInfo) { } @@ -137,6 +192,9 @@ void QTimerActiveObject::DoCancel() void QTimerActiveObject::RunL() { + if (!okToRun()) + return; + if (m_timerInfo->interval > 0) { // Start a new timer immediately so that we don't lose time. iStatus = KRequestPending; @@ -155,7 +213,8 @@ void QTimerActiveObject::RunL() iStatus = KRequestPending; SetActive(); - // We complete it after the processEvents is done. + TRequestStatus *status = &iStatus; + QEventDispatcherSymbian::RequestComplete(status, KErrNone); } } @@ -180,33 +239,29 @@ SymbianTimerInfo::~SymbianTimerInfo() delete timerAO; } -QCompleteZeroTimersActiveObject::QCompleteZeroTimersActiveObject(QEventDispatcherSymbian *dispatcher) - : CActive(COMPLETE_ZERO_TIMERS_PRIORITY), +QCompleteDeferredAOs::QCompleteDeferredAOs(QEventDispatcherSymbian *dispatcher) + : CActive(COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY), m_dispatcher(dispatcher) { CActiveScheduler::Add(this); iStatus = KRequestPending; SetActive(); - TRequestStatus *status = &iStatus; - QEventDispatcherSymbian::RequestComplete(status, KErrNone); } -QCompleteZeroTimersActiveObject::~QCompleteZeroTimersActiveObject() +QCompleteDeferredAOs::~QCompleteDeferredAOs() { Cancel(); } -bool QCompleteZeroTimersActiveObject::ref() +void QCompleteDeferredAOs::complete() { - return (++m_refCount != 0); -} - -bool QCompleteZeroTimersActiveObject::deref() -{ - return (--m_refCount != 0); + if (iStatus.Int() & KRequestPending) { + TRequestStatus *status = &iStatus; + QEventDispatcherSymbian::RequestComplete(status, KErrNone); + } } -void QCompleteZeroTimersActiveObject::DoCancel() +void QCompleteDeferredAOs::DoCancel() { if (iStatus.Int() & KRequestPending) { TRequestStatus *status = &iStatus; @@ -214,14 +269,12 @@ void QCompleteZeroTimersActiveObject::DoCancel() } } -void QCompleteZeroTimersActiveObject::RunL() +void QCompleteDeferredAOs::RunL() { - m_dispatcher->completeZeroTimers(); - iStatus = KRequestPending; SetActive(); - TRequestStatus *status = &iStatus; - QEventDispatcherSymbian::RequestComplete(status, KErrNone); + + m_dispatcher->reactivateDeferredActiveObjects(); } QSelectThread::QSelectThread() @@ -299,6 +352,9 @@ void QSelectThread::run() // ones that return -1 in select // after loop update notifiers for all of them + // as we dont have "exception" notifier type + // we should force monitoring fd_set of this + // type as well // clean @ start FD_ZERO(&readfds); @@ -311,6 +367,11 @@ void QSelectThread::run() fd_set onefds; FD_ZERO(&onefds); FD_SET(i.key()->socket(), &onefds); + + fd_set excfds; + FD_ZERO(&excfds); + FD_SET(i.key()->socket(), &excfds); + maxfd = i.key()->socket() + 1; struct timeval timeout; @@ -320,14 +381,11 @@ void QSelectThread::run() ret = 0; if(i.key()->type() == QSocketNotifier::Read) { - ret = ::select(maxfd, &onefds, 0, 0, &timeout); + ret = ::select(maxfd, &onefds, 0, &excfds, &timeout); if(ret != 0) FD_SET(i.key()->socket(), &readfds); } else if(i.key()->type() == QSocketNotifier::Write) { - ret = ::select(maxfd, 0, &onefds, 0, &timeout); + ret = ::select(maxfd, 0, &onefds, &excfds, &timeout); if(ret != 0) FD_SET(i.key()->socket(), &writefds); - } else { // must be exception fds then - ret = ::select(maxfd, 0, 0, &onefds, &timeout); - if(ret != 0) FD_SET(i.key()->socket(), &exceptionfds); } } // end for @@ -461,8 +519,7 @@ void QSelectThread::stop() } QSocketActiveObject::QSocketActiveObject(QEventDispatcherSymbian *dispatcher, QSocketNotifier *notifier) - : CActive(CActive::EPriorityStandard), - m_dispatcher(dispatcher), + : QActiveObject(CActive::EPriorityStandard, dispatcher), m_notifier(notifier), m_inSocketEvent(false), m_deleteLater(false) @@ -487,6 +544,9 @@ void QSocketActiveObject::DoCancel() void QSocketActiveObject::RunL() { + if (!okToRun()) + return; + m_dispatcher->socketFired(this); } @@ -503,9 +563,10 @@ QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent) : QAbstractEventDispatcher(parent), m_activeScheduler(0), m_wakeUpAO(0), - m_completeZeroTimersAO(0), + m_completeDeferredAOs(0), m_interrupt(false), m_wakeUpDone(0), + m_iterationCount(0), m_noSocketEvents(false) { } @@ -522,6 +583,7 @@ void QEventDispatcherSymbian::startingUp() CActiveScheduler::Install(m_activeScheduler); } m_wakeUpAO = new(ELeave) QWakeUpActiveObject(this); + m_completeDeferredAOs = new(ELeave) QCompleteDeferredAOs(this); // We already might have posted events, wakeup once to process them wakeUp(); } @@ -532,6 +594,7 @@ void QEventDispatcherSymbian::closingDown() m_selectThread.stop(); } + delete m_completeDeferredAOs; delete m_wakeUpAO; if (m_activeScheduler) { delete m_activeScheduler; @@ -542,6 +605,10 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla { Q_D(QAbstractEventDispatcher); + // It is safe if this counter overflows. The main importance is that each + // iteration count is different from the last. + m_iterationCount++; + RThread &thread = d->threadData->symbian_thread_handle; bool block; @@ -628,9 +695,6 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla timeState = SubsequentRun; }; - // Complete zero timers so that we get them next time. - completeZeroTimers(); - emit awake(); m_noSocketEvents = oldNoSocketEventsValue; @@ -735,17 +799,28 @@ bool QEventDispatcherSymbian::sendPostedEvents() //return false; } -void QEventDispatcherSymbian::completeZeroTimers() +inline void QEventDispatcherSymbian::addDeferredActiveObject(QActiveObject *object) { - for (QHash<int, SymbianTimerInfoPtr>::iterator i = m_timerList.begin(); i != m_timerList.end(); ++i) { - if ((*i)->interval == 0 && (*i)->timerAO->iStatus.Int() & KRequestPending) { - TRequestStatus *status = &(*i)->timerAO->iStatus; - QEventDispatcherSymbian::RequestComplete(status, KErrNone); - } + if (m_deferredActiveObjects.isEmpty()) { + m_completeDeferredAOs->complete(); + } + m_deferredActiveObjects.append(object); +} + +inline void QEventDispatcherSymbian::removeDeferredActiveObject(QActiveObject *object) +{ + m_deferredActiveObjects.removeAll(object); +} + +void QEventDispatcherSymbian::reactivateDeferredActiveObjects() +{ + while (!m_deferredActiveObjects.isEmpty()) { + QActiveObject *object = m_deferredActiveObjects.takeFirst(); + object->reactivateAndComplete(); } // We do this because we want to return from processEvents. This is because - // each invocation of processEvents should only run each zero timer once. + // each invocation of processEvents should only run each active object once. // The active scheduler should run them continously, however. m_interrupt = true; } @@ -808,16 +883,9 @@ void QEventDispatcherSymbian::registerTimer ( int timerId, int interval, QObject timer->inTimerEvent = false; timer->receiver = object; timer->dispatcher = this; - timer->timerAO = new(ELeave) QTimerActiveObject(timer.data()); + timer->timerAO = new(ELeave) QTimerActiveObject(this, timer.data()); m_timerList.insert(timerId, timer); - if (interval == 0) { - if (!m_completeZeroTimersAO) { - m_completeZeroTimersAO = new (ELeave) QCompleteZeroTimersActiveObject(this); - } - m_completeZeroTimersAO->ref(); - } - timer->timerAO->Start(); } @@ -828,12 +896,6 @@ bool QEventDispatcherSymbian::unregisterTimer ( int timerId ) } SymbianTimerInfoPtr timerInfo = m_timerList.take(timerId); - if (timerInfo->interval == 0) { - if (!m_completeZeroTimersAO->deref()) { - delete m_completeZeroTimersAO; - m_completeZeroTimersAO = 0; - } - } return true; } diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index b5ce868..393749f 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -45,6 +45,25 @@ QT_BEGIN_NAMESPACE class QEventDispatcherSymbian; class QTimerActiveObject; +class QActiveObject : public CActive +{ +public: + QActiveObject(TInt priority, QEventDispatcherSymbian *dispatcher); + ~QActiveObject(); + + bool okToRun(); + + void reactivateAndComplete(); + +protected: + QEventDispatcherSymbian *m_dispatcher; + +private: + bool m_hasAlreadyRun : 1; + bool m_hasRunAgain : 1; + int m_iterationCount; +}; + class QWakeUpActiveObject : public CActive { public: @@ -76,10 +95,10 @@ struct SymbianTimerInfo : public QSharedData typedef QExplicitlySharedDataPointer<SymbianTimerInfo> SymbianTimerInfoPtr; // This is a bit of a proxy class. See comments in SetActive and Start for details. -class QTimerActiveObject : public CActive +class QTimerActiveObject : public QActiveObject { public: - QTimerActiveObject(SymbianTimerInfo *timerInfo); + QTimerActiveObject(QEventDispatcherSymbian *dispatcher, SymbianTimerInfo *timerInfo); ~QTimerActiveObject(); void Start(); @@ -93,25 +112,23 @@ private: RTimer m_rTimer; }; -class QCompleteZeroTimersActiveObject : public CActive +class QCompleteDeferredAOs : public CActive { public: - QCompleteZeroTimersActiveObject(QEventDispatcherSymbian *dispatcher); - ~QCompleteZeroTimersActiveObject(); + QCompleteDeferredAOs(QEventDispatcherSymbian *dispatcher); + ~QCompleteDeferredAOs(); - bool ref(); - bool deref(); + void complete(); protected: void DoCancel(); void RunL(); private: - int m_refCount; QEventDispatcherSymbian *m_dispatcher; }; -class QSocketActiveObject : public CActive +class QSocketActiveObject : public QActiveObject { public: QSocketActiveObject(QEventDispatcherSymbian *dispatcher, QSocketNotifier *notifier); @@ -124,7 +141,6 @@ protected: void RunL(); private: - QEventDispatcherSymbian *m_dispatcher; QSocketNotifier *m_notifier; bool m_inSocketEvent; bool m_deleteLater; @@ -187,7 +203,12 @@ public: void socketFired(QSocketActiveObject *socketAO); void wakeUpWasCalled(); void reactivateSocketNotifier(QSocketNotifier *notifier); - void completeZeroTimers(); + + void addDeferredActiveObject(QActiveObject *object); + void removeDeferredActiveObject(QActiveObject *object); + void reactivateDeferredActiveObjects(); + + inline int iterationCount() const { return m_iterationCount; } static void RequestComplete(TRequestStatus *&status, TInt reason); static void RequestComplete(RThread &threadHandle, TRequestStatus *&status, TInt reason); @@ -205,20 +226,21 @@ private: QHash<QSocketNotifier *, QSocketActiveObject *> m_notifiers; QWakeUpActiveObject *m_wakeUpAO; - QCompleteZeroTimersActiveObject *m_completeZeroTimersAO; + QCompleteDeferredAOs *m_completeDeferredAOs; volatile bool m_interrupt; QAtomicInt m_wakeUpDone; + unsigned char m_iterationCount; bool m_noSocketEvents; QList<QSocketActiveObject *> m_deferredSocketEvents; + QList<QActiveObject *> m_deferredActiveObjects; + RProcess m_processHandle; }; -#define DEBUG_REQUEST_COMPLETE - -#ifdef DEBUG_REQUEST_COMPLETE +#ifdef QT_DEBUG // EActive is defined to 1 and ERequestPending to 2, but they are both private. // A little dangerous to rely on, but it is only for debugging. # define REQUEST_STATUS_ACTIVE_AND_PENDING 3 @@ -230,7 +252,7 @@ private: #endif // Convenience functions for doing some sanity checking on our own complete code. -// Unless you define DEBUG_REQUEST_COMPLETE, it is exactly equivalent to the Symbian version. +// Unless QT_DEBUG is defined, it is exactly equivalent to the Symbian version. inline void QEventDispatcherSymbian::RequestComplete(TRequestStatus *&status, TInt reason) { VERIFY_PENDING_REQUEST_STATUS diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index f5d3f78..6ea2d9f 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -345,18 +345,6 @@ void QObjectPrivate::derefSender(QObject *sender, int signal) // Q_ASSERT_X(false, "QObjectPrivate::derefSender", "sender not found"); } -void QObjectPrivate::removeSender(QObject *sender, int signal) -{ - for (int i = 0; i < senders.count(); ++i) { - Sender &s = senders[i]; - if (s.sender == sender && s.signal == signal) { - senders.removeAt(i); - return; - } - } - // Q_ASSERT_X(false, "QObjectPrivate::removeSender", "sender not found"); -} - QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver, Sender *sender) { @@ -790,7 +778,7 @@ QObject::~QObject() bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m); c = &connectionList[i]; if (c->receiver) - c->receiver->d_func()->removeSender(this, signal); + c->receiver->d_func()->derefSender(this, signal); if (needToUnlock) m->unlock(); @@ -811,18 +799,22 @@ QObject::~QObject() } // disconnect all senders - for (int i = 0; i < d->senders.count(); ++i) { + for (int i = 0; i < d->senders.count(); ) { QObjectPrivate::Sender *s = &d->senders[i]; - if (!s->sender) - continue; QMutex *m = &s->sender->d_func()->threadData->mutex; bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m); - s = &d->senders[i]; - if (s->sender) - s->sender->d_func()->removeReceiver(s->signal, this); + if (m < locker.mutex()) { + if (i >= d->senders.count() || s != &d->senders[i]) { + if (needToUnlock) + m->unlock(); + continue; + } + } + s->sender->d_func()->removeReceiver(s->signal, this); if (needToUnlock) m->unlock(); + ++i; } d->senders.clear(); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index b324334..0eed938 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -163,7 +163,6 @@ public: QList<Sender> senders; void refSender(QObject *sender, int signal); void derefSender(QObject *sender, int signal); - void removeSender(QObject *sender, int signal); static Sender *setCurrentSender(QObject *receiver, Sender *sender); diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index 2b0e0af..dc9cabf 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -142,6 +142,10 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, detached from the segment, and no references to the segment remain. Do not mix using QtSharedMemory and QSharedMemory. Port everything to QSharedMemory. + + \warning QSharedMemory changes the key in a Qt-specific way. + It is therefore currently not possible to use the shared memory of + non-Qt applications with QSharedMemory. */ /*! diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index c4395d9..b664093 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -56,10 +56,10 @@ #include <fcntl.h> #include <unistd.h> -QT_BEGIN_NAMESPACE - #ifndef QT_NO_SHAREDMEMORY +QT_BEGIN_NAMESPACE + QSharedMemoryPrivate::QSharedMemoryPrivate() : QObjectPrivate(), memory(0), size(0), error(QSharedMemory::NoError), #ifndef QT_NO_SYSTEMSEMAPHORE diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h index 05a9347..0e6def3 100644 --- a/src/corelib/kernel/qsystemsemaphore_p.h +++ b/src/corelib/kernel/qsystemsemaphore_p.h @@ -110,9 +110,9 @@ public: QSystemSemaphore::SystemSemaphoreError error; }; -#endif // QT_NO_SYSTEMSEMAPHORE +QT_END_NAMESPACE +#endif // QT_NO_SYSTEMSEMAPHORE -QT_END_NAMESPACE #endif // QSYSTEMSEMAPHORE_P_H diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 01e81ab..4b3feb0 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -77,7 +77,7 @@ QT_BEGIN_NAMESPACE In multithreaded applications, you can use QTimer in any thread that has an event loop. To start an event loop from a non-GUI - thread, use QThread::exec(). Qt uses the the timer's + thread, use QThread::exec(). Qt uses the timer's \l{QObject::thread()}{thread affinity} to determine which thread will emit the \l{QTimer::}{timeout()} signal. Because of this, you must start and stop the timer in its thread; it is not possible to diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 77d6599..3e4b467 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -819,6 +819,6 @@ bool QTranslator::isEmpty() const Use translate(\a context, \a sourceText, \a comment) instead. */ -#endif // QT_NO_TRANSLATION - QT_END_NAMESPACE + +#endif // QT_NO_TRANSLATION diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 006c635..0d85b93 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1214,8 +1214,9 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler; and versatile, but may prove less memory and speed efficient than storing specific types in standard data structures. - QVariant also supports the notion of null values, where you have - a defined type with no value set. + QVariant also supports the notion of null values, where you can + have a defined type with no value set. However, note that QVariant + types can only be cast when they have had a value set. \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 1 diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h index 633e92c..970cbcc 100644 --- a/src/corelib/tools/qbytearraymatcher.h +++ b/src/corelib/tools/qbytearraymatcher.h @@ -70,7 +70,7 @@ public: inline QByteArray pattern() const { if (q_pattern.isNull()) - return QByteArray((const char*)p.p, p.l); + return QByteArray(reinterpret_cast<const char*>(p.p), p.l); return q_pattern; } diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 21d98b5..2313e0e 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -379,6 +379,107 @@ void QHashData::checkSanity() #endif /*! + \fn uint qHash(const QPair<T1, T2> &key) + \since 4.3 + \relates QHash + + Returns the hash value for the \a key. + + Types \c T1 and \c T2 must be supported by qHash(). +*/ + +/*! \fn uint qHash(char key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(uchar key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(signed char key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(ushort key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(short key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(uint key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(int key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(ulong key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(long key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(quint64 key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(qint64 key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(QChar key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(const QByteArray &key) + \fn uint qHash(const QBitArray &key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(const QString &key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \fn uint qHash(const T *key) + \relates QHash + + Returns the hash value for the \a key. +*/ + +/*! \class QHash \brief The QHash class is a template class that provides a hash-table-based dictionary. @@ -401,7 +502,8 @@ void QHashData::checkSanity() key. With QHash, the items are arbitrarily ordered. \i The key type of a QMap must provide operator<(). The key type of a QHash must provide operator==() and a global - \l{qHash()}{qHash}(Key) function. + hash function called qHash() (see the related non-member + functions). \endlist Here's an example QHash with QString keys and \c int values: @@ -732,7 +834,6 @@ void QHashData::checkSanity() */ /*! \fn const T QHash::value(const Key &key, const T &defaultValue) const - \overload If the hash contains no item with the given \a key, the function returns @@ -1490,121 +1591,6 @@ void QHashData::checkSanity() \sa operator+=(), operator-() */ -/*! \fn uint qHash(char key) - \relates QHash - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(uchar key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(signed char key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(ushort key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(short key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(uint key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(int key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(ulong key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(long key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(quint64 key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(qint64 key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(QChar key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(const QByteArray &key) - \fn uint qHash(const QBitArray &key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(const QString &key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! \fn uint qHash(const T *key) - \relates QHash - \overload - - Returns the hash value for the \a key. -*/ - -/*! - \fn uint qHash(const QPair<T1, T2> &key) - \relates QHash - \since 4.3 - - Returns the hash value for the \a key. - - Types \c T1 and \c T2 must be supported by qHash(). -*/ - /*! \fn QDataStream &operator<<(QDataStream &out, const QHash<Key, T>& hash) \relates QHash diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 3328716..41b4794 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -97,10 +97,7 @@ Q_CORE_EXPORT uint qHash(const QBitArray &key); #endif template <class T> inline uint qHash(const T *key) { - if (sizeof(const T *) > sizeof(uint)) - return qHash(reinterpret_cast<quint64>(key)); - else - return uint(reinterpret_cast<ulong>(key)); + return qHash(reinterpret_cast<quintptr>(key)); } #if defined(Q_CC_MSVC) #pragma warning( pop ) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 4267562..4d042ae 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -78,11 +78,6 @@ QT_END_NAMESPACE #include <qdebug.h> #include <time.h> -#if defined(Q_OS_SYMBIAN) -#include <e32std.h> -#include "private/qcore_symbian_p.h" -#endif - #if defined(Q_OS_LINUX) && !defined(__UCLIBC__) # include <fenv.h> #endif @@ -303,7 +298,7 @@ static bool splitLocaleName(const QString &name, QChar *lang_begin, QChar *cntry return lang_len == 2 || lang_len == 3; } -static void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry) +void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry) { lang = QLocale::C; cntry = QLocale::AnyCountry; @@ -1282,794 +1277,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const } return QVariant(); } -#elif defined(Q_OS_SYMBIAN) - -static TExtendedLocale _s60Locale; - -// Type definitions for runtime resolved function pointers -typedef void (*FormatFunc)(TTime&, TDes&, const TDesC&, const TLocale&); -typedef TPtrC (*FormatSpecFunc)(TExtendedLocale&); - -// Runtime resolved functions -static FormatFunc ptrTimeFormatL = NULL; -static FormatSpecFunc ptrGetTimeFormatSpec = NULL; -static FormatSpecFunc ptrGetLongDateFormatSpec = NULL; -static FormatSpecFunc ptrGetShortDateFormatSpec = NULL; - -// Default functions if functions cannot be resolved -static void defaultTimeFormatL(TTime&, TDes& des, const TDesC&, const TLocale&) -{ - des.Zero(); -} - -static TPtrC defaultFormatSpec(TExtendedLocale&) -{ - return TPtrC(KNullDesC); -} - -/*! - Definition of struct for mapping Symbian to ISO locale -*/ -struct symbianToISO { - int symbian_language; - char iso_name[8]; -}; - -/*! - Mapping from Symbian to ISO locale -*/ -static const symbianToISO symbian_to_iso_list[] = { - { ELangEnglish, "en_GB" }, - { ELangFrench, "fr_FR" }, - { ELangGerman, "de_DE" }, - { ELangSpanish, "es_ES" }, - { ELangItalian, "it_IT" }, - { ELangSwedish, "sv_SE" }, - { ELangDanish, "da_DK" }, - { ELangNorwegian, "no_NO" }, - { ELangFinnish, "fi_FI" }, - { ELangAmerican, "en_US" }, - { ELangPortuguese, "pt_PT" }, - { ELangTurkish, "tr_TR" }, - { ELangIcelandic, "is_IS" }, - { ELangRussian, "ru_RU" }, - { ELangHungarian, "hu_HU" }, - { ELangDutch, "nl_NL" }, - { ELangBelgianFlemish, "nl_BE" }, - { ELangCzech, "cs_CZ" }, - { ELangSlovak, "sk_SK" }, - { ELangPolish, "pl_PL" }, - { ELangSlovenian, "sl_SI" }, - { ELangTaiwanChinese, "zh_TW" }, - { ELangHongKongChinese, "zh_HK" }, - { ELangPrcChinese, "zh_CN" }, - { ELangJapanese, "ja_JP" }, - { ELangThai, "th_TH" }, - { ELangArabic, "ar_AE" }, - { ELangTagalog, "tl_PH" }, - { ELangBulgarian, "bg_BG" }, - { ELangCatalan, "ca_ES" }, - { ELangCroatian, "hr_HR" }, - { ELangEstonian, "et_EE" }, - { ELangFarsi, "fa_IR" }, - { ELangCanadianFrench, "fr_CA" }, - { ELangGreek, "el_GR" }, - { ELangHebrew, "he_IL" }, - { ELangHindi, "hi_IN" }, - { ELangIndonesian, "id_ID" }, - { ELangLatvian, "lv_LV" }, - { ELangLithuanian, "lt_LT" }, - { ELangMalay, "ms_MY" }, - { ELangBrazilianPortuguese, "pt_BR" }, - { ELangRomanian, "ro_RO" }, - { ELangSerbian, "sr_YU" }, - { ELangLatinAmericanSpanish, "es" }, - { ELangUkrainian, "uk_UA" }, - { ELangUrdu, "ur_PK" }, // India/Pakistan - { ELangVietnamese, "vi_VN" }, -#ifdef __E32LANG_H__ -// 5.0 - { ELangBasque, "eu_ES" }, - { ELangGalician, "gl_ES" }, -#endif -#if !defined(__SERIES60_31__) - { ELangEnglish_Apac, "en" }, - { ELangEnglish_Taiwan, "en_TW" }, - { ELangEnglish_HongKong, "en_HK" }, - { ELangEnglish_Prc, "en_CN" }, - { ELangEnglish_Japan, "en_JP"}, - { ELangEnglish_Thailand, "en_TH" }, - { ELangMalay_Apac, "ms" } -#endif -}; - -/*! - Returns ISO name corresponding to the Symbian locale code \a sys_fmt. -*/ -static QByteArray symbianLocaleName(int code) -{ - //Number of Symbian to ISO locale mappings - static const int symbian_to_iso_count - = sizeof(symbian_to_iso_list)/sizeof(symbianToISO); - - int cmp = code - symbian_to_iso_list[0].symbian_language; - if (cmp < 0) - return 0; - - if (cmp == 0) - return symbian_to_iso_list[0].iso_name; - - int begin = 0; - int end = symbian_to_iso_count; - - while (end - begin > 1) { - uint mid = (begin + end)/2; - - const symbianToISO *elt = symbian_to_iso_list + mid; - int cmp = code - elt->symbian_language; - if (cmp < 0) - end = mid; - else if (cmp > 0) - begin = mid; - else - return elt->iso_name; - } - - return 0; -} - - -// order is: normal, abbr, nmode, nmode+abbr -static const char *us_locale_dep[] = { - "MM", "dd", "yyyy", "MM", "dd", - "M", "d", "yy", "M", "d", - "MMMM", "dd", "yyyy", "MMMM", "dd", - "MMM", "d", "yy", "MMM", "d" }; - -static const char *eu_locale_dep[] = { - "dd", "MM", "yyyy", "dd", "MM", - "d", "M", "yy", "d", "M", - "dd", "MMMM", "yyyy", "dd", "MMMM", - "d", "MMM", "yy", "d", "MMM" }; - -static const char *jp_locale_dep[] = { - "yyyy", "MM", "dd", "MM", "dd", - "yy", "M", "d", "M", "d", - "yyyy", "MMMM", "dd", "MMMM", "dd", - "yy", "MMM", "d", "MMM", "d" }; - -/*! - Returns a Qt version of the given \a sys_fmt Symbian locale format string. -*/ -static QString s60ToQtFormat(const QString &sys_fmt) -{ - TLocale *locale = _s60Locale.GetLocale(); - - QString result; - QString other; - QString qtformatchars = QString::fromLatin1("adhmsyzAHM"); - - QChar c; - int i = 0; - bool open_escape = false; - bool abbrev_next = false; - bool locale_indep_ordering = false; - bool minus_mode = false; - bool plus_mode = false; - bool n_mode = false; - TTimeFormat tf = locale->TimeFormat(); - - while (i < sys_fmt.size()) { - - c = sys_fmt.at(i); - - // let formatting thru - if (c.unicode() == '%') { - // if we have gathered string, concat it - if (!other.isEmpty()) { - result += other; - other.clear(); - } - // if we have open escape, end it - if (open_escape) { - result += QLatin1Char('\''); - open_escape = false; - } - - ++i; - if (i >= sys_fmt.size()) - break; - - c = sys_fmt.at(i); - - // process specials - abbrev_next = c.unicode() == '*'; - plus_mode = c.unicode() == '+'; - minus_mode = c.unicode() == '-'; - - if (abbrev_next || plus_mode || minus_mode) { - ++i; - if (i >= sys_fmt.size()) - break; - - c = sys_fmt.at(i); - - if (plus_mode || minus_mode) { - // break on undefined plus/minus mode - if (c.unicode() != 'A' && c.unicode() != 'B') - break; - } - } - - switch (c.unicode()) { - case 'F': - // locale indep mode on - locale_indep_ordering = true; - break; - - case '/': - // date sep 0-3 - ++i; - if (i >= sys_fmt.size()) - break; - - c = sys_fmt.at(i); - if (c.isDigit() && c.digitValue() <= 3) { - TChar s = locale->DateSeparator(c.digitValue()); - TUint val = s; - // some indexes return zero for empty - if (val > 0) - result += QChar(val); - } - break; - - case 'D': - if (!locale_indep_ordering) - break; - - if (!abbrev_next) - result += QLatin1String("dd"); - else - result += QLatin1Char('d'); - - break; - - case 'M': - if (!locale_indep_ordering) - break; - - if (!n_mode) { - if (!abbrev_next) - result += QLatin1String("MM"); - else - result += QLatin1String("M"); - } else { - if (!abbrev_next) - result += QLatin1String("MMMM"); - else - result += QLatin1String("MMM"); - } - - break; - - case 'N': - n_mode = true; - - if (!locale_indep_ordering) - break; - - if (!abbrev_next) - result += QLatin1String("MMMM"); - else - result += QLatin1String("MMM"); - - break; - - case 'Y': - if (!locale_indep_ordering) - break; - - if (!abbrev_next) - result += QLatin1String("yyyy"); - else - result += QLatin1String("yy"); - - break; - - case 'E': - if (!abbrev_next) - result += QLatin1String("dddd"); - else - result += QLatin1String("ddd"); - - break; - - case ':': - // timesep 0-3 - ++i; - if (i >= sys_fmt.size()) - break; - - c = sys_fmt.at(i); - if (c.isDigit() && c.digitValue() <= 3) { - TChar s = locale->TimeSeparator(c.digitValue()); - TUint val = s; - // some indexes return zero for empty - if (val > 0) - result += QChar(val); - } - - break; - - case 'J': - if (tf == ETime24 && !abbrev_next) - result += QLatin1String("hh"); - else - result += QLatin1Char('h'); - - break; - - case 'H': - if (!abbrev_next) - result += QLatin1String("hh"); - else - result += QLatin1Char('h'); - - break; - - case 'I': - result += QLatin1Char('h'); - break; - - case 'T': - if (!abbrev_next) - result += QLatin1String("mm"); - else - result += QLatin1Char('m'); - - break; - - case 'S': - if (!abbrev_next) - result += QLatin1String("ss"); - else - result += QLatin1Char('s'); - - break; - - case 'B': - // only done for 12h clock - if (tf == ETime24) - break; - - // fallthru to A - case 'A': { - // quickie to get capitalization, can't use s60 string as is because Qt 'hh' format's am/pm logic - TAmPmName ampm = TAmPmName(); - TChar first(ampm[0]); - QString qtampm = QString::fromLatin1(first.IsUpper() ? "AP" : "ap"); - - int pos = locale->AmPmSymbolPosition(); - - if ((minus_mode && pos != ELocaleBefore) || - (plus_mode && pos != ELocaleAfter)) - break; - - if (!abbrev_next && locale->AmPmSpaceBetween()) { - if (pos == ELocaleBefore) - qtampm.append(QLatin1Char(' ')); - else - qtampm.prepend(QLatin1Char(' ')); - } - - result += qtampm; - } - break; - - case '.': { - // decimal sep - TChar s = locale->DecimalSeparator(); - TUint val = s; - if (val > 0) - result += QChar(val); - } - break; - - case 'C': - // six digits in s60, three digits in qt - if (!abbrev_next) { - result += QLatin1String("zzz"); - } else { - // next char is number from 0-6, how many digits to display - ++i; - if (i >= sys_fmt.size()) - break; - - c = sys_fmt.at(i); - - if (c.isDigit()) { - // try to match wanted digits - QChar val(c.digitValue()); - - if (val >= 3) { - result += QLatin1String("zzz"); - } else if (val > 0) { - result += QLatin1Char('z'); - } - } - } - break; - - // these cases fallthru - case '1': - case '2': - case '3': - case '4': - case '5': - - // shouldn't parse these with %F - if (locale_indep_ordering) - break; - - TDateFormat df = locale->DateFormat(); - - const char **locale_dep; - switch (df) { - default: // fallthru to american - case EDateAmerican: - locale_dep = us_locale_dep; - break; - case EDateEuropean: - locale_dep = eu_locale_dep; - break; - case EDateJapanese: - locale_dep = jp_locale_dep; - break; - } - int offset = 0; - if (abbrev_next) - offset += 5; - if (n_mode) - offset += 10; - - result += QLatin1String(locale_dep[offset + (c.digitValue()-1)]); - break; - - case '%': // fallthru percent - // any junk gets copied as is - default: - result += c; - break; - - case 'Z': // Qt doesn't support these :( - case 'X': - case 'W': - break; - } - } else { - // double any single quotes, don't begin escape - if (c.unicode() == '\'') { - // end open escape - if (open_escape) { - result += other; - other.clear(); - result += QLatin1Char('\''); - open_escape = false; - } - - other += c; - } - - // gather chars and escape them in one go if any format chars are found - if (!open_escape && qtformatchars.indexOf(c) != -1) { - result += QLatin1Char('\''); - open_escape = true; - } - other += c; - } - - ++i; - } - - if (!other.isEmpty()) - result += other; - if (open_escape) - result += QLatin1Char('\''); - - return result; -} - -/*! - Retrieves Symbian locale decimal separator. -*/ -static QString symbianDecimalPoint() -{ - TLocale *locale = _s60Locale.GetLocale(); - - TChar decPoint = locale->DecimalSeparator(); - int val = decPoint; - return QChar(val); -} - -/*! - Retrieves Symbian locale group separator. -*/ -static QString symbianGroupSeparator() -{ - TLocale *locale = _s60Locale.GetLocale(); - - TChar grpSep = locale->ThousandsSeparator(); - int val = grpSep; - return QChar(val); -} - -/*! - Retrieves Symbian locale zero digit. -*/ -static QString symbianZeroDigit() -{ - TLocale *locale = _s60Locale.GetLocale(); - - // TDigitType enumeration value returned by TLocale - // will always correspond to zero digit unicode value. - TDigitType digit = locale->DigitType(); - return QChar(digit); -} - -/*! - Retrieves a day name from Symbian locale. The \a day is an integer - from 1 to 7. When \a short_format is true the method returns - the day in short format. Otherwise it returns the day in a long format. -*/ -static QString symbianDayName(int day, bool short_format) -{ - day -= 1; - - if (day < 0 || day > 6) - return QString(); - - if (short_format) { - return qt_TDes2QStringL(TDayNameAbb(TDay(day))); - } else { - return qt_TDes2QStringL(TDayName(TDay(day))); - } -} - -/*! - Retrieves a month name from Symbian locale. The \a month is an integer - from 1 to 12. When \a short_format is true the method returns - the month in short format. Otherwise it returns the month in a long format. -*/ -static QString symbianMonthName(int month, bool short_format) -{ - month -= 1; - if (month < 0 || month > 11) - return QString(); - - if (short_format) { - return qt_TDes2QStringL(TMonthNameAbb(TMonth(month))); - } else { - return qt_TDes2QStringL(TMonthName(TMonth(month))); - } -} - -/*! - Retrieves date format from Symbian locale and - transforms it to Qt format. - - When \a short_format is true the method returns - short date format. Otherwise it returns the long format. -*/ -static QString symbianDateFormat(bool short_format) -{ - TPtrC dateFormat; - - if (short_format) { - dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); - } else { - dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); - } - - return s60ToQtFormat(qt_TDesC2QStringL(dateFormat)); -} - -/*! - Retrieves time format from Symbian locale and - transforms it to Qt format. -*/ -static QString symbianTimeFormat() -{ - return s60ToQtFormat(qt_TDesC2QStringL(ptrGetTimeFormatSpec(_s60Locale))); -} - -/*! - Returns localized string representation of given \a date - formatted with Symbian locale date format. - - If \a short_format is true the format will be a short version. - Otherwise it uses a longer version. -*/ -static QString symbianDateToString(const QDate &date, bool short_format) -{ - int month = date.month() - 1; - int day = date.day() - 1; - int year = date.year(); - - TDateTime dateTime; - dateTime.Set(year, TMonth(month), day, 0, 0, 0, 0); - - TTime timeStr(dateTime); - TBuf<KMaxLongDateFormatSpec*2> buffer; - - TPtrC dateFormat; - if (short_format) { - dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); - } else { - dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); - } - - TRAPD(err, ptrTimeFormatL(timeStr, buffer, dateFormat, *_s60Locale.GetLocale());) - - if (err == KErrNone) - return qt_TDes2QStringL(buffer); - else - return QString(); -} - -/*! - Returns localized string representation of given \a time - formatted with Symbian locale time format. -*/ -static QString symbianTimeToString(const QTime &time) -{ - int hour = time.hour(); - int minute = time.minute(); - int second = time.second(); - int milliseconds = 0; - - TDateTime dateTime; - dateTime.Set(0, TMonth(0), 0, hour, minute, second, milliseconds); - - TTime timeStr(dateTime); - TBuf<KMaxTimeFormatSpec*2> buffer; - - TRAPD(err, ptrTimeFormatL( - timeStr, - buffer, - ptrGetTimeFormatSpec(_s60Locale), - *_s60Locale.GetLocale()); - ) - - if (err == KErrNone) - return qt_TDes2QStringL(buffer); - else - return QString(); -} - -/*! - Returns the measurement system stored in Symbian locale - - \sa QLocale::MeasurementSystem -*/ -static QLocale::MeasurementSystem symbianMeasurementSystem() -{ - TLocale *locale = _s60Locale.GetLocale(); - - TUnitsFormat unitFormat = locale->UnitsGeneral(); - if (unitFormat == EUnitsImperial) - return QLocale::ImperialSystem; - else - return QLocale::MetricSystem; -} - -QLocale QSystemLocale::fallbackLocale() const -{ - // load system data before query calls - static bool initDone = false; - if (!initDone) { - _s60Locale.LoadSystemSettings(); - - // Initialize platform version dependent function pointers - ptrTimeFormatL = reinterpret_cast<FormatFunc> - (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL)); - ptrGetTimeFormatSpec = reinterpret_cast<FormatSpecFunc> - (qt_resolveS60PluginFunc(S60Plugin_GetTimeFormatSpec)); - ptrGetLongDateFormatSpec = reinterpret_cast<FormatSpecFunc> - (qt_resolveS60PluginFunc(S60Plugin_GetLongDateFormatSpec)); - ptrGetShortDateFormatSpec = reinterpret_cast<FormatSpecFunc> - (qt_resolveS60PluginFunc(S60Plugin_GetShortDateFormatSpec)); - if (!ptrTimeFormatL) - ptrTimeFormatL = &defaultTimeFormatL; - if (!ptrGetTimeFormatSpec) - ptrGetTimeFormatSpec = &defaultFormatSpec; - if (!ptrGetLongDateFormatSpec) - ptrGetLongDateFormatSpec = &defaultFormatSpec; - if (!ptrGetShortDateFormatSpec) - ptrGetShortDateFormatSpec = &defaultFormatSpec; - } - - TLanguage lang = User::Language(); - QString locale = symbianLocaleName(lang); - return QLocale(locale); -} - -/*! - Generic query method for locale data. Provides indirection. - Denotes the \a type of the query - with \a in as input data depending on the query. - - \sa QSystemLocale::QueryType -*/ -QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const -{ - switch(type) { - case DecimalPoint: - return symbianDecimalPoint(); - case GroupSeparator: - return symbianGroupSeparator(); - - case ZeroDigit: - return symbianZeroDigit(); - - case DayNameLong: - case DayNameShort: - return symbianDayName(in.toInt(), (type == DayNameShort) ); - - case MonthNameLong: - case MonthNameShort: - return symbianMonthName(in.toInt(), (type == MonthNameShort) ); - - case DateFormatLong: - case DateFormatShort: - return symbianDateFormat( (type == DateFormatShort) ); - case TimeFormatLong: - case TimeFormatShort: - return symbianTimeFormat(); - case DateTimeFormatLong: - case DateTimeFormatShort: - return symbianDateFormat( (type == DateTimeFormatShort) ) + QLatin1Char(' ') + symbianTimeFormat(); - case DateToStringShort: - case DateToStringLong: - return symbianDateToString(in.toDate(), (type == DateToStringShort) ); - case TimeToStringShort: - case TimeToStringLong: - return symbianTimeToString(in.toTime()); - case DateTimeToStringShort: - case DateTimeToStringLong: { - const QDateTime dt = in.toDateTime(); - return symbianDateToString(dt.date(), (type == DateTimeToStringShort) ) - + QLatin1Char(' ') + symbianTimeToString(dt.time()); - } - case MeasurementSystem: - return static_cast<int>(symbianMeasurementSystem()); - case LanguageId: - case CountryId: { - TLanguage language = User::Language(); - QString locale = symbianLocaleName(language); - QLocale::Language lang; - QLocale::Country cntry; - getLangAndCountry(locale, lang, cntry); - if (type == LanguageId) - return lang; - // few iso codes have no country and will use this - if (cntry == QLocale::AnyCountry) - return fallbackLocale().country(); - - return cntry; - } - case NegativeSign: - case PositiveSign: - case AMText: - case PMText: - break; - default: - break; - } - return QVariant(); -} - -#elif defined(Q_OS_UNIX) +#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) static uint unixGetSystemMeasurementSystem() { @@ -2113,7 +1322,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant /* in */) const } } -#else +#elif !defined(Q_OS_SYMBIAN) /*! Returns a fallback locale, that will get used for everything that @@ -2387,7 +1596,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) defaults to the default locale (see setDefault()). \endlist - The "C" locale is identical to \l{English}/\l{UnitedStates}. + The "C" locale is identical in behavior to \l{English}/\l{UnitedStates}. Use language() and country() to determine the actual language and country values used. @@ -2430,7 +1639,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) This enumerated type is used to specify a language. - \value C The "C" locale is English/UnitedStates. + \value C The "C" locale is identical in behavior to English/UnitedStates. \value Abkhazian \value Afan \value Afar diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp new file mode 100644 index 0000000..b58a5d5 --- /dev/null +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -0,0 +1,840 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDate> +#include <QLocale> +#include <QTime> +#include <QVariant> + +#include <e32std.h> +#include "private/qcore_symbian_p.h" + +// Located in qlocale.cpp +extern void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry); + +QT_BEGIN_NAMESPACE + +static TExtendedLocale _s60Locale; + +// Type definitions for runtime resolved function pointers +typedef void (*FormatFunc)(TTime&, TDes&, const TDesC&, const TLocale&); +typedef TPtrC (*FormatSpecFunc)(TExtendedLocale&); + +// Runtime resolved functions +static FormatFunc ptrTimeFormatL = NULL; +static FormatSpecFunc ptrGetTimeFormatSpec = NULL; +static FormatSpecFunc ptrGetLongDateFormatSpec = NULL; +static FormatSpecFunc ptrGetShortDateFormatSpec = NULL; + +// Default functions if functions cannot be resolved +static void defaultTimeFormatL(TTime&, TDes& des, const TDesC&, const TLocale&) +{ + des.Zero(); +} + +static TPtrC defaultFormatSpec(TExtendedLocale&) +{ + return TPtrC(KNullDesC); +} + +/*! + Definition of struct for mapping Symbian to ISO locale +*/ +struct symbianToISO { + int symbian_language; + char iso_name[8]; +}; + + +/*! + Mapping from Symbian to ISO locale +*/ +static const symbianToISO symbian_to_iso_list[] = { + { ELangEnglish, "en_GB" }, + { ELangFrench, "fr_FR" }, + { ELangGerman, "de_DE" }, + { ELangSpanish, "es_ES" }, + { ELangItalian, "it_IT" }, + { ELangSwedish, "sv_SE" }, + { ELangDanish, "da_DK" }, + { ELangNorwegian, "no_NO" }, + { ELangFinnish, "fi_FI" }, + { ELangAmerican, "en_US" }, + { ELangPortuguese, "pt_PT" }, + { ELangTurkish, "tr_TR" }, + { ELangIcelandic, "is_IS" }, + { ELangRussian, "ru_RU" }, + { ELangHungarian, "hu_HU" }, + { ELangDutch, "nl_NL" }, + { ELangBelgianFlemish, "nl_BE" }, + { ELangCzech, "cs_CZ" }, + { ELangSlovak, "sk_SK" }, + { ELangPolish, "pl_PL" }, + { ELangSlovenian, "sl_SI" }, + { ELangTaiwanChinese, "zh_TW" }, + { ELangHongKongChinese, "zh_HK" }, + { ELangPrcChinese, "zh_CN" }, + { ELangJapanese, "ja_JP" }, + { ELangThai, "th_TH" }, + { ELangArabic, "ar_AE" }, + { ELangTagalog, "tl_PH" }, + { ELangBulgarian, "bg_BG" }, + { ELangCatalan, "ca_ES" }, + { ELangCroatian, "hr_HR" }, + { ELangEstonian, "et_EE" }, + { ELangFarsi, "fa_IR" }, + { ELangCanadianFrench, "fr_CA" }, + { ELangGreek, "el_GR" }, + { ELangHebrew, "he_IL" }, + { ELangHindi, "hi_IN" }, + { ELangIndonesian, "id_ID" }, + { ELangLatvian, "lv_LV" }, + { ELangLithuanian, "lt_LT" }, + { ELangMalay, "ms_MY" }, + { ELangBrazilianPortuguese, "pt_BR" }, + { ELangRomanian, "ro_RO" }, + { ELangSerbian, "sr_YU" }, + { ELangLatinAmericanSpanish, "es" }, + { ELangUkrainian, "uk_UA" }, + { ELangUrdu, "ur_PK" }, // India/Pakistan + { ELangVietnamese, "vi_VN" }, +#ifdef __E32LANG_H__ +// 5.0 + { ELangBasque, "eu_ES" }, + { ELangGalician, "gl_ES" }, +#endif +#if !defined(__SERIES60_31__) + { ELangEnglish_Apac, "en" }, + { ELangEnglish_Taiwan, "en_TW" }, + { ELangEnglish_HongKong, "en_HK" }, + { ELangEnglish_Prc, "en_CN" }, + { ELangEnglish_Japan, "en_JP"}, + { ELangEnglish_Thailand, "en_TH" }, + { ELangMalay_Apac, "ms" } +#endif +}; + +/*! + Returns ISO name corresponding to the Symbian locale code \a sys_fmt. +*/ +static QByteArray symbianLocaleName(int code) +{ + //Number of Symbian to ISO locale mappings + static const int symbian_to_iso_count + = sizeof(symbian_to_iso_list)/sizeof(symbianToISO); + + int cmp = code - symbian_to_iso_list[0].symbian_language; + if (cmp < 0) + return 0; + + if (cmp == 0) + return symbian_to_iso_list[0].iso_name; + + int begin = 0; + int end = symbian_to_iso_count; + + while (end - begin > 1) { + uint mid = (begin + end)/2; + + const symbianToISO *elt = symbian_to_iso_list + mid; + int cmp = code - elt->symbian_language; + if (cmp < 0) + end = mid; + else if (cmp > 0) + begin = mid; + else + return elt->iso_name; + } + + return 0; +} + + +// order is: normal, abbr, nmode, nmode+abbr +static const char *us_locale_dep[] = { + "MM", "dd", "yyyy", "MM", "dd", + "M", "d", "yy", "M", "d", + "MMMM", "dd", "yyyy", "MMMM", "dd", + "MMM", "d", "yy", "MMM", "d" }; + +static const char *eu_locale_dep[] = { + "dd", "MM", "yyyy", "dd", "MM", + "d", "M", "yy", "d", "M", + "dd", "MMMM", "yyyy", "dd", "MMMM", + "d", "MMM", "yy", "d", "MMM" }; + +static const char *jp_locale_dep[] = { + "yyyy", "MM", "dd", "MM", "dd", + "yy", "M", "d", "M", "d", + "yyyy", "MMMM", "dd", "MMMM", "dd", + "yy", "MMM", "d", "MMM", "d" }; + +/*! + Returns a Qt version of the given \a sys_fmt Symbian locale format string. +*/ +static QString s60ToQtFormat(const QString &sys_fmt) +{ + TLocale *locale = _s60Locale.GetLocale(); + + QString result; + QString other; + QString qtformatchars = QString::fromLatin1("adhmsyzAHM"); + + QChar c; + int i = 0; + bool open_escape = false; + bool abbrev_next = false; + bool locale_indep_ordering = false; + bool minus_mode = false; + bool plus_mode = false; + bool n_mode = false; + TTimeFormat tf = locale->TimeFormat(); + + while (i < sys_fmt.size()) { + + c = sys_fmt.at(i); + + // let formatting thru + if (c.unicode() == '%') { + // if we have gathered string, concat it + if (!other.isEmpty()) { + result += other; + other.clear(); + } + // if we have open escape, end it + if (open_escape) { + result += QLatin1Char('\''); + open_escape = false; + } + + ++i; + if (i >= sys_fmt.size()) + break; + + c = sys_fmt.at(i); + + // process specials + abbrev_next = c.unicode() == '*'; + plus_mode = c.unicode() == '+'; + minus_mode = c.unicode() == '-'; + + if (abbrev_next || plus_mode || minus_mode) { + ++i; + if (i >= sys_fmt.size()) + break; + + c = sys_fmt.at(i); + + if (plus_mode || minus_mode) { + // break on undefined plus/minus mode + if (c.unicode() != 'A' && c.unicode() != 'B') + break; + } + } + + switch (c.unicode()) { + case 'F': + // locale indep mode on + locale_indep_ordering = true; + break; + + case '/': + // date sep 0-3 + ++i; + if (i >= sys_fmt.size()) + break; + + c = sys_fmt.at(i); + if (c.isDigit() && c.digitValue() <= 3) { + TChar s = locale->DateSeparator(c.digitValue()); + TUint val = s; + // some indexes return zero for empty + if (val > 0) + result += QChar(val); + } + break; + + case 'D': + if (!locale_indep_ordering) + break; + + if (!abbrev_next) + result += QLatin1String("dd"); + else + result += QLatin1Char('d'); + + break; + + case 'M': + if (!locale_indep_ordering) + break; + + if (!n_mode) { + if (!abbrev_next) + result += QLatin1String("MM"); + else + result += QLatin1String("M"); + } else { + if (!abbrev_next) + result += QLatin1String("MMMM"); + else + result += QLatin1String("MMM"); + } + + break; + + case 'N': + n_mode = true; + + if (!locale_indep_ordering) + break; + + if (!abbrev_next) + result += QLatin1String("MMMM"); + else + result += QLatin1String("MMM"); + + break; + + case 'Y': + if (!locale_indep_ordering) + break; + + if (!abbrev_next) + result += QLatin1String("yyyy"); + else + result += QLatin1String("yy"); + + break; + + case 'E': + if (!abbrev_next) + result += QLatin1String("dddd"); + else + result += QLatin1String("ddd"); + + break; + + case ':': + // timesep 0-3 + ++i; + if (i >= sys_fmt.size()) + break; + + c = sys_fmt.at(i); + if (c.isDigit() && c.digitValue() <= 3) { + TChar s = locale->TimeSeparator(c.digitValue()); + TUint val = s; + // some indexes return zero for empty + if (val > 0) + result += QChar(val); + } + + break; + + case 'J': + if (tf == ETime24 && !abbrev_next) + result += QLatin1String("hh"); + else + result += QLatin1Char('h'); + + break; + + case 'H': + if (!abbrev_next) + result += QLatin1String("hh"); + else + result += QLatin1Char('h'); + + break; + + case 'I': + result += QLatin1Char('h'); + break; + + case 'T': + if (!abbrev_next) + result += QLatin1String("mm"); + else + result += QLatin1Char('m'); + + break; + + case 'S': + if (!abbrev_next) + result += QLatin1String("ss"); + else + result += QLatin1Char('s'); + + break; + + case 'B': + // only done for 12h clock + if (tf == ETime24) + break; + + // fallthru to A + case 'A': { + // quickie to get capitalization, can't use s60 string as is because Qt 'hh' format's am/pm logic + TAmPmName ampm = TAmPmName(); + TChar first(ampm[0]); + QString qtampm = QString::fromLatin1(first.IsUpper() ? "AP" : "ap"); + + int pos = locale->AmPmSymbolPosition(); + + if ((minus_mode && pos != ELocaleBefore) || + (plus_mode && pos != ELocaleAfter)) + break; + + if (!abbrev_next && locale->AmPmSpaceBetween()) { + if (pos == ELocaleBefore) + qtampm.append(QLatin1Char(' ')); + else + qtampm.prepend(QLatin1Char(' ')); + } + + result += qtampm; + } + break; + + case '.': { + // decimal sep + TChar s = locale->DecimalSeparator(); + TUint val = s; + if (val > 0) + result += QChar(val); + } + break; + + case 'C': + // six digits in s60, three digits in qt + if (!abbrev_next) { + result += QLatin1String("zzz"); + } else { + // next char is number from 0-6, how many digits to display + ++i; + if (i >= sys_fmt.size()) + break; + + c = sys_fmt.at(i); + + if (c.isDigit()) { + // try to match wanted digits + QChar val(c.digitValue()); + + if (val >= 3) { + result += QLatin1String("zzz"); + } else if (val > 0) { + result += QLatin1Char('z'); + } + } + } + break; + + // these cases fallthru + case '1': + case '2': + case '3': + case '4': + case '5': + + // shouldn't parse these with %F + if (locale_indep_ordering) + break; + + TDateFormat df = locale->DateFormat(); + + const char **locale_dep; + switch (df) { + default: // fallthru to american + case EDateAmerican: + locale_dep = us_locale_dep; + break; + case EDateEuropean: + locale_dep = eu_locale_dep; + break; + case EDateJapanese: + locale_dep = jp_locale_dep; + break; + } + int offset = 0; + if (abbrev_next) + offset += 5; + if (n_mode) + offset += 10; + + result += QLatin1String(locale_dep[offset + (c.digitValue()-1)]); + break; + + case '%': // fallthru percent + // any junk gets copied as is + default: + result += c; + break; + + case 'Z': // Qt doesn't support these :( + case 'X': + case 'W': + break; + } + } else { + // double any single quotes, don't begin escape + if (c.unicode() == '\'') { + // end open escape + if (open_escape) { + result += other; + other.clear(); + result += QLatin1Char('\''); + open_escape = false; + } + + other += c; + } + + // gather chars and escape them in one go if any format chars are found + if (!open_escape && qtformatchars.indexOf(c) != -1) { + result += QLatin1Char('\''); + open_escape = true; + } + other += c; + } + + ++i; + } + + if (!other.isEmpty()) + result += other; + if (open_escape) + result += QLatin1Char('\''); + + return result; +} + +/*! + Retrieves Symbian locale decimal separator. +*/ +static QString symbianDecimalPoint() +{ + TLocale *locale = _s60Locale.GetLocale(); + + TChar decPoint = locale->DecimalSeparator(); + int val = decPoint; + return QChar(val); +} + +/*! + Retrieves Symbian locale group separator. +*/ +static QString symbianGroupSeparator() +{ + TLocale *locale = _s60Locale.GetLocale(); + + TChar grpSep = locale->ThousandsSeparator(); + int val = grpSep; + return QChar(val); +} + +/*! + Retrieves Symbian locale zero digit. +*/ +static QString symbianZeroDigit() +{ + TLocale *locale = _s60Locale.GetLocale(); + + // TDigitType enumeration value returned by TLocale + // will always correspond to zero digit unicode value. + TDigitType digit = locale->DigitType(); + return QChar(digit); +} + +/*! + Retrieves a day name from Symbian locale. The \a day is an integer + from 1 to 7. When \a short_format is true the method returns + the day in short format. Otherwise it returns the day in a long format. +*/ +static QString symbianDayName(int day, bool short_format) +{ + day -= 1; + + if (day < 0 || day > 6) + return QString(); + + if (short_format) { + return qt_TDes2QStringL(TDayNameAbb(TDay(day))); + } else { + return qt_TDes2QStringL(TDayName(TDay(day))); + } +} + +/*! + Retrieves a month name from Symbian locale. The \a month is an integer + from 1 to 12. When \a short_format is true the method returns + the month in short format. Otherwise it returns the month in a long format. +*/ +static QString symbianMonthName(int month, bool short_format) +{ + month -= 1; + if (month < 0 || month > 11) + return QString(); + + if (short_format) { + return qt_TDes2QStringL(TMonthNameAbb(TMonth(month))); + } else { + return qt_TDes2QStringL(TMonthName(TMonth(month))); + } +} + +/*! + Retrieves date format from Symbian locale and + transforms it to Qt format. + + When \a short_format is true the method returns + short date format. Otherwise it returns the long format. +*/ +static QString symbianDateFormat(bool short_format) +{ + TPtrC dateFormat; + + if (short_format) { + dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); + } else { + dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); + } + + return s60ToQtFormat(qt_TDesC2QStringL(dateFormat)); +} + +/*! + Retrieves time format from Symbian locale and + transforms it to Qt format. +*/ +static QString symbianTimeFormat() +{ + return s60ToQtFormat(qt_TDesC2QStringL(ptrGetTimeFormatSpec(_s60Locale))); +} + +/*! + Returns localized string representation of given \a date + formatted with Symbian locale date format. + + If \a short_format is true the format will be a short version. + Otherwise it uses a longer version. +*/ +static QString symbianDateToString(const QDate &date, bool short_format) +{ + int month = date.month() - 1; + int day = date.day() - 1; + int year = date.year(); + + TDateTime dateTime; + dateTime.Set(year, TMonth(month), day, 0, 0, 0, 0); + + TTime timeStr(dateTime); + TBuf<KMaxLongDateFormatSpec*2> buffer; + + TPtrC dateFormat; + if (short_format) { + dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); + } else { + dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); + } + + TRAPD(err, ptrTimeFormatL(timeStr, buffer, dateFormat, *_s60Locale.GetLocale());) + + if (err == KErrNone) + return qt_TDes2QStringL(buffer); + else + return QString(); +} + +/*! + Returns localized string representation of given \a time + formatted with Symbian locale time format. +*/ +static QString symbianTimeToString(const QTime &time) +{ + int hour = time.hour(); + int minute = time.minute(); + int second = time.second(); + int milliseconds = 0; + + TDateTime dateTime; + dateTime.Set(0, TMonth(0), 0, hour, minute, second, milliseconds); + + TTime timeStr(dateTime); + TBuf<KMaxTimeFormatSpec*2> buffer; + + TRAPD(err, ptrTimeFormatL( + timeStr, + buffer, + ptrGetTimeFormatSpec(_s60Locale), + *_s60Locale.GetLocale()); + ) + + if (err == KErrNone) + return qt_TDes2QStringL(buffer); + else + return QString(); +} + +/*! + Returns the measurement system stored in Symbian locale + + \sa QLocale::MeasurementSystem +*/ +static QLocale::MeasurementSystem symbianMeasurementSystem() +{ + TLocale *locale = _s60Locale.GetLocale(); + + TUnitsFormat unitFormat = locale->UnitsGeneral(); + if (unitFormat == EUnitsImperial) + return QLocale::ImperialSystem; + else + return QLocale::MetricSystem; +} + +QLocale QSystemLocale::fallbackLocale() const +{ + // load system data before query calls + static bool initDone = false; + if (!initDone) { + _s60Locale.LoadSystemSettings(); + + // Initialize platform version dependent function pointers + ptrTimeFormatL = reinterpret_cast<FormatFunc> + (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL)); + ptrGetTimeFormatSpec = reinterpret_cast<FormatSpecFunc> + (qt_resolveS60PluginFunc(S60Plugin_GetTimeFormatSpec)); + ptrGetLongDateFormatSpec = reinterpret_cast<FormatSpecFunc> + (qt_resolveS60PluginFunc(S60Plugin_GetLongDateFormatSpec)); + ptrGetShortDateFormatSpec = reinterpret_cast<FormatSpecFunc> + (qt_resolveS60PluginFunc(S60Plugin_GetShortDateFormatSpec)); + if (!ptrTimeFormatL) + ptrTimeFormatL = &defaultTimeFormatL; + if (!ptrGetTimeFormatSpec) + ptrGetTimeFormatSpec = &defaultFormatSpec; + if (!ptrGetLongDateFormatSpec) + ptrGetLongDateFormatSpec = &defaultFormatSpec; + if (!ptrGetShortDateFormatSpec) + ptrGetShortDateFormatSpec = &defaultFormatSpec; + } + + TLanguage lang = User::Language(); + QString locale = symbianLocaleName(lang); + return QLocale(locale); +} + +/*! + Generic query method for locale data. Provides indirection. + Denotes the \a type of the query + with \a in as input data depending on the query. + + \sa QSystemLocale::QueryType +*/ +QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const +{ + switch(type) { + case DecimalPoint: + return symbianDecimalPoint(); + case GroupSeparator: + return symbianGroupSeparator(); + + case ZeroDigit: + return symbianZeroDigit(); + + case DayNameLong: + case DayNameShort: + return symbianDayName(in.toInt(), (type == DayNameShort) ); + + case MonthNameLong: + case MonthNameShort: + return symbianMonthName(in.toInt(), (type == MonthNameShort) ); + + case DateFormatLong: + case DateFormatShort: + return symbianDateFormat( (type == DateFormatShort) ); + case TimeFormatLong: + case TimeFormatShort: + return symbianTimeFormat(); + case DateTimeFormatLong: + case DateTimeFormatShort: + return symbianDateFormat( (type == DateTimeFormatShort) ) + QLatin1Char(' ') + symbianTimeFormat(); + case DateToStringShort: + case DateToStringLong: + return symbianDateToString(in.toDate(), (type == DateToStringShort) ); + case TimeToStringShort: + case TimeToStringLong: + return symbianTimeToString(in.toTime()); + case DateTimeToStringShort: + case DateTimeToStringLong: { + const QDateTime dt = in.toDateTime(); + return symbianDateToString(dt.date(), (type == DateTimeToStringShort) ) + + QLatin1Char(' ') + symbianTimeToString(dt.time()); + } + case MeasurementSystem: + return static_cast<int>(symbianMeasurementSystem()); + case LanguageId: + case CountryId: { + TLanguage language = User::Language(); + QString locale = symbianLocaleName(language); + QLocale::Language lang; + QLocale::Country cntry; + getLangAndCountry(locale, lang, cntry); + if (type == LanguageId) + return lang; + // few iso codes have no country and will use this + if (cntry == QLocale::AnyCountry) + return fallbackLocale().country(); + + return cntry; + } + case NegativeSign: + case PositiveSign: + case AMText: + case PMText: + break; + default: + break; + } + return QVariant(); +} + +QT_END_NAMESPACE diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 3930a0d..5602170 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -901,7 +901,7 @@ void QRect::moveCenter(const QPoint &p) /*! \fn bool QRect::contains(const QPoint &point, bool proper) const - Returns true if the the given \a point is inside or on the edge of + Returns true if the given \a point is inside or on the edge of the rectangle, otherwise returns false. If \a proper is true, this function only returns true if the given \a point is \e inside the rectangle (i.e., not on the edge). diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index b8c3f3d..88b8b8c 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -244,6 +244,7 @@ namespace QtSharedPointer { template <class X> friend class ExternalRefCount; template <class X> friend class QWeakPointer; template <class X, class Y> friend QSharedPointer<X> qSharedPointerCastHelper(const QSharedPointer<Y> &src, X *); + template <class X, class Y> friend QSharedPointer<X> qSharedPointerDynamicCastHelper(const QSharedPointer<Y> &src, X *); template <class X, class Y> friend QSharedPointer<X> qSharedPointerConstCastHelper(const QSharedPointer<Y> &src, X *); template <class X, class Y> friend QSharedPointer<X> QtSharedPointer::qStrongRefFromWeakHelper(const QWeakPointer<Y> &src, X *); #endif @@ -521,6 +522,14 @@ namespace QtSharedPointer { return result; } template <class X, class T> + Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCastHelper(const QSharedPointer<T> &src, X *) + { + QSharedPointer<X> result; + register T *ptr = src.data(); + result.internalSet(src.d, dynamic_cast<X *>(ptr)); + return result; + } + template <class X, class T> Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCastHelper(const QSharedPointer<T> &src, X *) { QSharedPointer<X> result; @@ -556,9 +565,7 @@ template <class X, class T> Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &src) { X *x = 0; - if (QtSharedPointer::qVerifyDynamicCast(src.data(), x)) - return QtSharedPointer::qSharedPointerCastHelper(src, x); - return QSharedPointer<X>(); + return QtSharedPointer::qSharedPointerDynamicCastHelper(src, x); } template <class X, class T> Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer<T> &src) @@ -570,17 +577,13 @@ template <class X, class T> Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast(const QSharedPointer<T> &src) { X *x = 0; - if (QtSharedPointer::qVerifyConstCast(src.data(), x)) - return QtSharedPointer::qSharedPointerConstCastHelper(src, x); - return QSharedPointer<X>(); + return QtSharedPointer::qSharedPointerConstCastHelper(src, x); } template <class X, class T> Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast(const QWeakPointer<T> &src) { X *x = 0; - if (QtSharedPointer::qVerifyConstCast(src.data(), x)) - return QtSharedPointer::qSharedPointerCastHelper(src, x); - return QSharedPointer<X>(); + return QtSharedPointer::qSharedPointerConstCastHelper(src, x); } template <class X, class T> diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index 76a5484..bbf6c2a 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -781,7 +781,7 @@ void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode) \fn QDataStream &operator<<(QDataStream &stream, const QSizeF &size) \relates QSizeF - Writes the the given \a size to the given \a stream and returns a + Writes the given \a size to the given \a stream and returns a reference to the stream. \sa {Format of the QDataStream Operators} diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 375d672..c3649e3 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -743,7 +743,9 @@ int QString::grow(int size) /*! \since 4.2 - Returns a copy of the \a string string encoded in ucs4. + Returns a copy of the \a string, where the encoding of \a string depends on + the size of wchar. If wchar is 4 bytes, the \a string is interpreted as ucs-4, + if wchar is 2 bytes it is interpreted as ucs-2. If \a size is -1 (default), the \a string has to be 0 terminated. diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 386321f1..e22f122 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -397,7 +397,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r \fn QString QStringList::join(const QString &separator) const Joins all the string list's strings into a single string with each - element separated by the the given \a separator (which can be an + element separated by the given \a separator (which can be an empty string). \sa QString::split() diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index 2979a09..3a03558 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -225,7 +225,9 @@ void QTimeLinePrivate::setCurrentTime(int msecs) valueForTime() and emitting valueChanged(). By default, valueForTime() applies an interpolation algorithm to generate these value. You can choose from a set of predefined timeline algorithms by calling - setCurveShape(). By default, QTimeLine uses the EaseInOut curve shape, + setCurveShape(). + + Note that by default, QTimeLine uses the EaseInOut curve shape, which provides a value that grows slowly, then grows steadily, and finally grows slowly. For a custom timeline, you can reimplement valueForTime(), in which case QTimeLine's curveShape property is ignored. diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 45e92bf..c2381ce 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -65,6 +65,7 @@ SOURCES += \ tools/qvector.cpp \ tools/qvsnprintf.cpp +symbian:SOURCES+=tools/qlocale_symbian.cpp #zlib support contains(QT_CONFIG, zlib) { diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 2c27381..f40a45f 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1125,12 +1125,7 @@ void QDBusConnectionPrivate::objectDestroyed(QObject *obj) void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, int signalId, const QVariantList &args) { - int mciid = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTERFACE); - Q_ASSERT(mciid != -1); - - QMetaClassInfo mci = mo->classInfo(mciid); - Q_ASSERT(mci.value()); - const char *interface = mci.value(); + QString interface = qDBusInterfaceFromMetaObject(mo); QMetaMethod mm = mo->method(signalId); QByteArray memberName = mm.signature(); @@ -1146,12 +1141,12 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in } QDBusReadLocker locker(RelaySignalAction, this); - QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/"), QLatin1String(interface), + QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/"), interface, QLatin1String(memberName)); message.setArguments(args); DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message); if (!msg) { - qWarning("QDBusConnection: Could not emit signal %s.%s", interface, memberName.constData()); + qWarning("QDBusConnection: Could not emit signal %s.%s", qPrintable(interface), memberName.constData()); return; } diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 15a99af..220faa3 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -706,15 +706,10 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) Constructs a message box with no text and no buttons. \a parent is passed to the QDialog constructor. - If \a parent is 0, the message box is an \l{Qt::ApplicationModal} - {application modal} dialog box. If \a parent is a widget, the - message box is \l{Qt::WindowModal} {window modal} relative to \a - parent. - - On Mac OS X, if \a parent is not 0 and you want your message box - to appear as a Qt::Sheet of that parent, set the message box's - \l{setWindowModality()} {window modality} to Qt::WindowModal - (default). Otherwise, the message box will be a standard dialog. + On Mac OS X, if you want your message box to appear + as a Qt::Sheet of its \a parent, set the message box's + \l{setWindowModality()} {window modality} to Qt::WindowModal or use open(). + Otherwise, the message box will be a standard dialog. */ QMessageBox::QMessageBox(QWidget *parent) diff --git a/src/gui/dialogs/qpagesetupdialog.cpp b/src/gui/dialogs/qpagesetupdialog.cpp index 63775d2..682071a 100644 --- a/src/gui/dialogs/qpagesetupdialog.cpp +++ b/src/gui/dialogs/qpagesetupdialog.cpp @@ -180,6 +180,12 @@ void QPageSetupDialog::open(QObject *receiver, const char *member) QDialog::open(); } +#if defined(Q_WS_MAC) || defined(Q_OS_WIN) +/*! \fn void QPageSetupDialog::setVisible(bool visible) + \reimp +*/ +#endif + QT_END_NAMESPACE #endif diff --git a/src/gui/dialogs/qpagesetupdialog_mac.mm b/src/gui/dialogs/qpagesetupdialog_mac.mm index 401d95f..24aef34 100644 --- a/src/gui/dialogs/qpagesetupdialog_mac.mm +++ b/src/gui/dialogs/qpagesetupdialog_mac.mm @@ -251,9 +251,6 @@ QPageSetupDialog::QPageSetupDialog(QWidget *parent) d->ep = static_cast<QMacPrintEngine *>(d->printer->paintEngine())->d_func(); } -/*! - \reimp -*/ void QPageSetupDialog::setVisible(bool visible) { Q_D(QPageSetupDialog); diff --git a/src/gui/dialogs/qsidebar.cpp b/src/gui/dialogs/qsidebar.cpp index 26108d7..000a06b 100644 --- a/src/gui/dialogs/qsidebar.cpp +++ b/src/gui/dialogs/qsidebar.cpp @@ -249,9 +249,9 @@ void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move) continue; for (int j = 0; move && j < rowCount(); ++j) { #if defined(Q_OS_WIN) - if (index(j, 0).data(UrlRole).toUrl().toLocalFile().toLower() == url.toLocalFile().toLower()) { + if (QDir::cleanPath(index(j, 0).data(UrlRole).toUrl().toLocalFile()).toLower() == QDir::cleanPath(url.toLocalFile()).toLower()) { #else - if (index(j, 0).data(UrlRole) == url) { + if (QDir::cleanPath(index(j, 0).data(UrlRole).toUrl().toLocalFile()) == QDir::cleanPath(url.toLocalFile())) { #endif removeRow(j); if (j <= row) diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp index 32395c4..298f23f 100644 --- a/src/gui/dialogs/qwizard.cpp +++ b/src/gui/dialogs/qwizard.cpp @@ -1465,7 +1465,7 @@ void QWizardPrivate::handleAeroStyleChange() return; // prevent recursion inHandleAeroStyleChange = true; - vistaHelper->backButton()->disconnect(); + vistaHelper->disconnectBackButton(); q->removeEventFilter(vistaHelper); if (isVistaThemeEnabled()) { @@ -1491,7 +1491,7 @@ void QWizardPrivate::handleAeroStyleChange() q->setMouseTracking(true); // ### original value possibly different q->unsetCursor(); // ### ditto antiFlickerWidget->move(0, 0); - vistaHelper->backButton()->hide(); + vistaHelper->hideBackButton(); vistaHelper->setTitleBarIconAndCaptionVisible(true); } diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp index 64696de..8aad4af 100644 --- a/src/gui/dialogs/qwizard_win.cpp +++ b/src/gui/dialogs/qwizard_win.cpp @@ -239,9 +239,11 @@ void QVistaBackButton::paintEvent(QPaintEvent *) QVistaHelper::QVistaHelper(QWizard *wizard) : pressed(false) , wizard(wizard) + , backButton_(0) { is_vista = resolveSymbols(); - backButton_ = new QVistaBackButton(wizard); + if (is_vista) + backButton_ = new QVistaBackButton(wizard); } QVistaHelper::~QVistaHelper() @@ -310,6 +312,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter) QRect(0, 0, wizard->width(), titleBarSize() + topOffset()), painter->paintEngine()->getDC()); + Q_ASSERT(backButton_); const int btnTop = backButton_->mapToParent(QPoint()).y(); const int btnHeight = backButton_->size().height(); const int verticalCenter = (btnTop + btnHeight / 2); diff --git a/src/gui/dialogs/qwizard_win_p.h b/src/gui/dialogs/qwizard_win_p.h index cbb3b17..148be26 100644 --- a/src/gui/dialogs/qwizard_win_p.h +++ b/src/gui/dialogs/qwizard_win_p.h @@ -94,6 +94,8 @@ public: void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); QVistaBackButton *backButton() const { return backButton_; } + void disconnectBackButton() { if (backButton_) backButton_->disconnect(); } + void hideBackButton() { if (backButton_) backButton_->hide(); } void setWindowPosHack(); QColor basicWindowFrameColor(); enum VistaState { VistaAero, VistaBasic, Classic, Dirty }; diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index 6741f2c..39a74d5 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -1394,7 +1394,7 @@ QImage::Format QScreenPrivate::preferredImageFormat() const altered. Note that the default implementations of these functions do nothing. - Reimplement the the mapFromDevice() and mapToDevice() functions to + Reimplement the mapFromDevice() and mapToDevice() functions to map objects from the framebuffer coordinate system to the coordinate space used by the application, and vice versa. Be aware that the default implementations simply return the given objects diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp index c72ea91..283bbd3 100644 --- a/src/gui/embedded/qsoundqss_qws.cpp +++ b/src/gui/embedded/qsoundqss_qws.cpp @@ -52,6 +52,7 @@ #include <qalgorithms.h> #include <qtimer.h> #include <qpointer.h> +#include <qendian.h> #include <unistd.h> #include <stdlib.h> @@ -335,7 +336,13 @@ public: virtual int readySamples(int) = 0; int getSample(int off, int bps) { - return (bps == 1) ? (data[out+off] - 128) * 128 : ((short*)data)[(out/2)+off]; + + // + // 16-bit audio data is converted to native endian so that it can be scaled + // Yes, this is ugly on a BigEndian machine + // Perhaps it shouldn't be scaled at all + // + return (bps == 1) ? (data[out+off] - 128) * 128 : qToLittleEndian(((short*)data)[(out/2)+off]); } int add(int* mixl, int* mixr, int count) @@ -547,7 +554,7 @@ public: wavedata_remaining = 0; mFinishedRead = true; } else if ( qstrncmp(chunk.id,"data",4) == 0 ) { - wavedata_remaining = chunk.size; + wavedata_remaining = qToLittleEndian( chunk.size ); //out = max = sound_buffer_size; @@ -572,10 +579,23 @@ public: //qDebug("couldn't ready chunkdata"); mFinishedRead = true; } + #define WAVE_FORMAT_PCM 1 - else if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { - //qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); - mFinishedRead = true; + else + { + /* + ** Endian Fix the chuck data + */ + chunkdata.formatTag = qToLittleEndian( chunkdata.formatTag ); + chunkdata.channels = qToLittleEndian( chunkdata.channels ); + chunkdata.samplesPerSec = qToLittleEndian( chunkdata.samplesPerSec ); + chunkdata.avgBytesPerSec = qToLittleEndian( chunkdata.avgBytesPerSec ); + chunkdata.blockAlign = qToLittleEndian( chunkdata.blockAlign ); + chunkdata.wBitsPerSample = qToLittleEndian( chunkdata.wBitsPerSample ); + if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { + qWarning("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); + mFinishedRead = true; + } } } else { // ignored chunk @@ -1166,9 +1186,15 @@ bool QWSSoundServerPrivate::openDevice() if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &v)) qWarning("Could not set fragments to %08x",v); #ifdef QT_QWS_SOUND_16BIT - v=AFMT_S16_LE; if (ioctl(fd, SNDCTL_DSP_SETFMT, &v)) + // + // Use native endian + // Since we have manipulated the data volume the data + // is now in native format, even though its stored + // as little endian in the WAV file + // + v=AFMT_S16_NE; if (ioctl(fd, SNDCTL_DSP_SETFMT, &v)) qWarning("Could not set format %d",v); - if (AFMT_S16_LE != v) + if (AFMT_S16_NE != v) qDebug("Want format %d got %d", AFMT_S16_LE, v); #else v=AFMT_U8; if (ioctl(fd, SNDCTL_DSP_SETFMT, &v)) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 30c15bc..4908296 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2572,6 +2572,10 @@ QTransform QGraphicsItem::sceneTransform() const */ QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) const { + // Ensure we return the standard transform if we're not untransformable. + if (!d_ptr->itemIsUntransformable()) + return sceneTransform() * viewportTransform; + // Find the topmost item that ignores view transformations. const QGraphicsItem *untransformedAncestor = this; QList<const QGraphicsItem *> parents; diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index eaa97ff..b46e05e 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -255,7 +255,7 @@ QGraphicsItem *QGraphicsLayoutItemPrivate::parentItem() const passing a QGraphicsLayoutItem pointer to QGraphicsLayoutItem's protected constructor, or by calling setParentLayoutItem(). The parentLayoutItem() function returns a pointer to the item's layoutItem - parent. If the item's parent is 0 or if the the parent does not inherit + parent. If the item's parent is 0 or if the parent does not inherit from QGraphicsItem, the parentLayoutItem() function then returns 0. isLayout() returns true if the QGraphicsLayoutItem subclass is itself a layout, or false otherwise. diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 13f70e5..b89e352 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2289,12 +2289,7 @@ void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRect // Calculate a simple level-of-detail metric. // ### almost identical code in QGraphicsView::paintEvent() // and QGraphicsView::render() - consider refactoring - QTransform itemToDeviceTransform; - if (item->d_ptr->itemIsUntransformable()) { - itemToDeviceTransform = item->deviceTransform(painterTransform); - } else { - itemToDeviceTransform = item->sceneTransform() * painterTransform; - } + QTransform itemToDeviceTransform = item->deviceTransform(painterTransform); option.levelOfDetail = qSqrt(itemToDeviceTransform.map(v1).length() * itemToDeviceTransform.map(v2).length()); option.matrix = itemToDeviceTransform.toAffine(); //### discards perspective @@ -5078,11 +5073,7 @@ void QGraphicsScene::drawItems(QPainter *painter, // optimization, but it's hit very rarely. for (int i = clippers.size() - 1; i >= 0; --i) { QGraphicsItem *clipper = clippers[i]; - if (clipper->d_ptr->itemIsUntransformable()) { - painter->setWorldTransform(clipper->deviceTransform(viewTransform), false); - } else { - painter->setWorldTransform(clipper->sceneTransform() * viewTransform, false); - } + painter->setWorldTransform(clipper->deviceTransform(viewTransform), false); childClippers.append(clipper); painter->save(); @@ -5093,12 +5084,8 @@ void QGraphicsScene::drawItems(QPainter *painter, } // Set up the painter transform - if (item->d_ptr->itemIsUntransformable()) { - painter->setWorldTransform(item->deviceTransform(viewTransform), false); - } else { - painter->setWorldTransform(item->sceneTransform() * viewTransform, false); - } - + painter->setWorldTransform(item->deviceTransform(viewTransform), false); + // Save painter bool saveState = (d->painterStateProtection || (item->flags() & QGraphicsItem::ItemClipsToShape)); if (saveState) diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp index b819c2c..0ffd2b1 100644 --- a/src/gui/graphicsview/qgraphicssceneevent.cpp +++ b/src/gui/graphicsview/qgraphicssceneevent.cpp @@ -844,7 +844,7 @@ QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent() /*! Returns the position of the mouse cursor in item coordinates at the moment - the the context menu was requested. + the context menu was requested. \sa scenePos(), screenPos() */ @@ -992,7 +992,7 @@ QGraphicsSceneHoverEvent::~QGraphicsSceneHoverEvent() /*! Returns the position of the mouse cursor in item coordinates at the moment - the the hover event was sent. + the hover event was sent. \sa scenePos(), screenPos() */ @@ -1017,7 +1017,7 @@ void QGraphicsSceneHoverEvent::setPos(const QPointF &pos) /*! Returns the position of the mouse cursor in scene coordinates at the - moment the the hover event was sent. + moment the hover event was sent. \sa pos(), screenPos() */ @@ -1042,7 +1042,7 @@ void QGraphicsSceneHoverEvent::setScenePos(const QPointF &pos) /*! Returns the position of the mouse cursor in screen coordinates at the - moment the the hover event was sent. + moment the hover event was sent. \sa pos(), scenePos() */ @@ -1138,7 +1138,7 @@ void QGraphicsSceneHoverEvent::setLastScreenPos(const QPoint &pos) /*! \since 4.4 - Returns the keyboard modifiers at the moment the the hover event was sent. + Returns the keyboard modifiers at the moment the hover event was sent. */ Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const { @@ -1184,7 +1184,7 @@ QGraphicsSceneHelpEvent::~QGraphicsSceneHelpEvent() /*! Returns the position of the mouse cursor in scene coordinates at the - moment the the help event was sent. + moment the help event was sent. \sa screenPos() */ @@ -1209,7 +1209,7 @@ void QGraphicsSceneHelpEvent::setScenePos(const QPointF &pos) /*! Returns the position of the mouse cursor in screen coordinates at the - moment the the help event was sent. + moment the help event was sent. \sa scenePos() */ diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 05e4907..a795fb4 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -1153,11 +1153,7 @@ void QGraphicsViewPrivate::generateStyleOptions(const QList<QGraphicsItem *> &it // Calculate a simple level-of-detail metric. // ### almost identical code in QGraphicsScene::render() // and QGraphicsView::render() - consider refactoring - if (item->d_ptr->itemIsUntransformable()) { - itemToViewportTransform = item->deviceTransform(worldTransform); - } else { - itemToViewportTransform = item->sceneTransform() * worldTransform; - } + itemToViewportTransform = item->deviceTransform(worldTransform); if (itemToViewportTransform.type() <= QTransform::TxTranslate) { // Translation and rotation only? The LOD is 1. @@ -1681,6 +1677,7 @@ void QGraphicsView::setScene(QGraphicsScene *scene) disconnect(d->scene, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(updateSceneRect(QRectF))); d->scene->d_func()->views.removeAll(this); + d->connectedToScene = false; } // Assign the new scene and update the contents (scrollbars, etc.)). @@ -2159,12 +2156,7 @@ void QGraphicsView::render(QPainter *painter, const QRectF &target, const QRect // Calculate a simple level-of-detail metric. // ### almost identical code in QGraphicsScene::render() // and QGraphicsView::paintEvent() - consider refactoring - QTransform itemToViewportTransform; - if (item->d_ptr->itemIsUntransformable()) { - itemToViewportTransform = item->deviceTransform(painterMatrix); - } else { - itemToViewportTransform = item->sceneTransform() * painterMatrix; - } + QTransform itemToViewportTransform = item->deviceTransform(painterMatrix); option->levelOfDetail = qSqrt(itemToViewportTransform.map(v1).length() * itemToViewportTransform.map(v2).length()); option->matrix = itemToViewportTransform.toAffine(); diff --git a/src/gui/gui.pro b/src/gui/gui.pro index d3b7388..30aaa51 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -42,4 +42,7 @@ QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist DEFINES += Q_INTERNAL_QAPP_SRC -symbian:TARGET.UID3=0x2001B2DD
\ No newline at end of file +symbian:TARGET.UID3=0x2001B2DD + +# ro-section in gui can exceed default allocated space, so more rw-section little further +symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000"
\ No newline at end of file diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 3c71f15..a880a13 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -854,6 +854,9 @@ void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state) QImageWriter::supportedImageFormats() functions to retrieve a complete list of the supported file formats. + Note: When you add a non-empty filename to a QIcon, the icon becomes + non-null, even if the file doesn't exist or points to a corrupt file. + \sa addPixmap() */ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State state) @@ -919,7 +922,7 @@ QList<QSize> QIcon::availableSizes(Mode mode, State state) const \relates QIcon \since 4.2 - Writes the given \a icon to the the given \a stream as a PNG + Writes the given \a icon to the given \a stream as a PNG image. If the icon contains more than one image, all images will be written to the stream. Note that writing the stream to a file will not produce a valid image file. diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index c7a20db..70d4e2c 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4996,7 +4996,7 @@ QPoint QImage::offset() const /*! \fn void QImage::setOffset(const QPoint& offset) - Sets the the number of pixels by which the image is intended to be + Sets the number of pixels by which the image is intended to be offset by when positioning relative to other images, to \a offset. \sa offset(), {QImage#Image Information}{Image Information} diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 82be1b9..3ef5be3 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1236,7 +1236,7 @@ bool QPixmap::convertFromImage(const QImage &image, ColorMode mode) /*! \relates QPixmap - Writes the given \a pixmap to the the given \a stream as a PNG + Writes the given \a pixmap to the given \a stream as a PNG image. Note that writing the stream to a file will not produce a valid image file. diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index 3ec441b..cbe9004 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -319,6 +319,7 @@ static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h) } else { qWarning("qt_fromWinHBITMAP(), failed to get bitmap bits"); } + qFree(data); return image; } diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index d1f3791..159a997 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1338,7 +1338,7 @@ QSize QAbstractItemView::iconSize() const /*! \property QAbstractItemView::textElideMode - \brief the the position of the "..." in elided text. + \brief the position of the "..." in elided text. The default value for all item views is Qt::ElideRight. */ @@ -3221,9 +3221,9 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const option.state &= ~QStyle::State_MouseOver; option.font = font(); -#ifdef Q_WS_WIN - // Note this is currently required on Windows - // do give non-focused item views inactive appearance +#ifndef Q_WS_MAC + // On mac the focus appearance follows window activation + // not widget activation if (!hasFocus()) option.state &= ~QStyle::State_Active; #endif diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 147f523..fda6255 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -47,6 +47,7 @@ #include <qbrush.h> #include <qlineedit.h> #include <qtextedit.h> +#include <qplaintextedit.h> #include <qpainter.h> #include <qpalette.h> #include <qpoint.h> @@ -218,7 +219,7 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const editor widget, which is a widget that is placed on top of the view while editing takes place. Editors are created with a QItemEditorFactory; a default static instance provided by - QItemEditorFactory is installed on all item delagates. You can set + QItemEditorFactory is installed on all item delegates. You can set a custom factory using setItemEditorFactory() or set a new default factory with QItemEditorFactory::setDefaultFactory(). It is the data stored in the item model with the Qt::EditRole that is edited. @@ -1194,7 +1195,7 @@ bool QItemDelegate::eventFilter(QObject *object, QEvent *event) case Qt::Key_Enter: case Qt::Key_Return: #ifndef QT_NO_TEXTEDIT - if (qobject_cast<QTextEdit*>(editor)) + if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor)) return false; // don't filter enter key events for QTextEdit // We want the editor to be able to process the key press // before committing the data (e.g. so it can do diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 7a366d1..bf3b43c 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -1158,7 +1158,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, /*! \fn void QListWidget::addItem(QListWidgetItem *item) - Inserts the \a item at the the end of the list widget. + Inserts the \a item at the end of the list widget. \warning A QListWidgetItem can only be added to a QListWidget once. Adding the same QListWidgetItem multiple diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index 4dc54a1..b75f151 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -47,6 +47,7 @@ #include <qbrush.h> #include <qlineedit.h> #include <qtextedit.h> +#include <qplaintextedit.h> #include <qpainter.h> #include <qpalette.h> #include <qpoint.h> @@ -646,7 +647,7 @@ bool QStyledItemDelegate::eventFilter(QObject *object, QEvent *event) case Qt::Key_Enter: case Qt::Key_Return: #ifndef QT_NO_TEXTEDIT - if (qobject_cast<QTextEdit*>(editor)) + if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor)) return false; // don't filter enter key events for QTextEdit // We want the editor to be able to process the key press // before committing the data (e.g. so it can do diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 1906025..fb002a3 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2054,12 +2054,10 @@ QWidget *QApplication::focusWidget() void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) { - if (focus && focus->window() #ifndef QT_NO_GRAPHICSVIEW - && focus->window()->graphicsProxyWidget() -#endif - ) + if (focus && focus->window()->graphicsProxyWidget()) return; +#endif hidden_focus_widget = 0; diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 72c2855..dd51fcd 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -302,7 +302,6 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons QWidget *alienWidget; QPoint widgetPos = QPoint(aPenEventLocation.iX, aPenEventLocation.iY); QPoint globalPos = QPoint(aPenEventScreenLocation.iX,aPenEventScreenLocation.iY); - //### possible bug, within manhattan lenght if the target is slipped outside .... alienWidget = qwidget->childAt(widgetPos); if (!alienWidget) alienWidget = qwidget; @@ -321,6 +320,7 @@ void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) QMouseEvent::Type type; Qt::MouseButton button; mapS60MouseEventTypeToQt(&type, &button, &pEvent); + if (m_previousEventLongTap) if (type == QEvent::MouseButtonRelease){ button = Qt::RightButton; @@ -368,27 +368,30 @@ void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) button, QApplicationPrivate::mouse_buttons, mapToQtModifiers(pEvent.iModifiers)); events.append(Event(S60->lastPointerEventTarget,mEventLeave)); } - QMouseEvent mEventEnter(QEvent::Enter, alienWidget->mapFrom(qwidget, widgetPos), globalPos, + QMouseEvent mEventEnter(QEvent::Enter, alienWidget->mapFromGlobal(globalPos), globalPos, button, QApplicationPrivate::mouse_buttons, mapToQtModifiers(pEvent.iModifiers)); + events.append(Event(alienWidget,mEventEnter)); } S60->lastCursorPos = globalPos; S60->lastPointerEventPos = widgetPos; S60->lastPointerEventTarget = alienWidget; - - QMouseEvent mEvent(type, alienWidget->mapFrom(qwidget, widgetPos), globalPos, - button, QApplicationPrivate::mouse_buttons, mapToQtModifiers(pEvent.iModifiers)); - events.append(Event(alienWidget,mEvent)); - QEventDispatcherS60 *dispatcher; - // It is theoretically possible for someone to install a different event dispatcher. - if (dispatcher = qobject_cast<QEventDispatcherS60 *>(alienWidget->d_func()->threadData->eventDispatcher)) { - if (dispatcher->excludeUserInputEvents()) { - for (int i=0;i < events.count();++i) - { - Event next = events[i]; - dispatcher->saveInputEvent(this, next.first, new QMouseEvent(next.second)); + if (alienWidget) + { + QMouseEvent mEvent(type, alienWidget->mapFromGlobal(globalPos), globalPos, + button, QApplicationPrivate::mouse_buttons, mapToQtModifiers(pEvent.iModifiers)); + events.append(Event(alienWidget,mEvent)); + QEventDispatcherS60 *dispatcher; + // It is theoretically possible for someone to install a different event dispatcher. + if (dispatcher = qobject_cast<QEventDispatcherS60 *>(alienWidget->d_func()->threadData->eventDispatcher)) { + if (dispatcher->excludeUserInputEvents()) { + for (int i=0;i < events.count();++i) + { + Event next = events[i]; + dispatcher->saveInputEvent(this, next.first, new QMouseEvent(next.second)); + } + return; } - return; } } for (int i=0;i < events.count();++i) @@ -672,6 +675,10 @@ void QSymbianControl::HandleResourceChange(int resourceType) CCoeControl::HandleResourceChange(resourceType); } +void QSymbianControl::CancelLongTapTimer() +{ + m_longTapDetector->Cancel(); +} TTypeUid::Ptr QSymbianControl::MopSupplyObject(TTypeUid id) { @@ -786,6 +793,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created)); WId id = popup->effectiveWinId(); id->SetPointerCapture(true); + id->SetGloballyCapturing(true); autoGrabWindow = id; } @@ -797,6 +805,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) popup->focusWidget()->setFocus(Qt::PopupFocusReason); } else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup if (QWidget *fw = QApplication::focusWidget()) { + static_cast<QSymbianControl*>(fw->effectiveWinId())->CancelLongTapTimer(); QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); q_func()->sendEvent(fw, &e); } @@ -816,6 +825,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created)); WId id = popup->effectiveWinId(); id->SetPointerCapture(false); + id->SetGloballyCapturing(false); if (QWidgetPrivate::mouseGrabber != 0) QWidgetPrivate::mouseGrabber->grabMouse(); diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index 917b5d5..bab3449 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -466,7 +466,7 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode) The \a mode argument is used to control which part of the system clipboard is used. If \a mode is QClipboard::Clipboard, this - function clears the the global clipboard contents. If \a mode is + function clears the global clipboard contents. If \a mode is QClipboard::Selection, this function clears the global mouse selection contents. If \a mode is QClipboard::FindBuffer, this function clears the search string buffer. diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm index c69826f..b2941fe 100644 --- a/src/gui/kernel/qcocoapanel_mac.mm +++ b/src/gui/kernel/qcocoapanel_mac.mm @@ -107,9 +107,16 @@ QT_USE_NAMESPACE - (void)sendEvent:(NSEvent *)event { - [self retain]; - QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; + + // Cocoa can hold onto the window after we've disavowed its knowledge. So, + // if we get sent an event afterwards just have it go through the super's + // version and don't do any stuff with Qt. + if (!widget) { + [super sendEvent:event]; + return; + } + [self retain]; QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget)); Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]); diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm index 89f481f..8e62f02 100644 --- a/src/gui/kernel/qcocoawindow_mac.mm +++ b/src/gui/kernel/qcocoawindow_mac.mm @@ -128,12 +128,19 @@ QT_USE_NAMESPACE - (void)sendEvent:(NSEvent *)event { - [self retain]; - QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; + + // Cocoa can hold onto the window after we've disavowed its knowledge. So, + // if we get sent an event afterwards just have it go through the super's + // version and don't do any stuff with Qt. + if (!widget) { + [super sendEvent:event]; + return; + } + + [self retain]; QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget)); Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]); - // sometimes need to redirect mouse events to the popup. QWidget *popup = qAppInstance()->activePopupWidget(); if (popup && popup != widget) { diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 8c7e47d..2aed287 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -675,12 +675,13 @@ QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta, The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride. - If \a key is 0, the event is not a result of - a known key; for example, it may be the result of a compose - sequence or keyboard macro. The \a modifiers holds the keyboard - modifiers, and the given \a text is the Unicode text that the - key generated. If \a autorep is true, isAutoRepeat() will be - true. \a count is the number of keys involved in the event. + Int \a key is the code for the Qt::Key that the event loop should listen + for. If \a key is 0, the event is not a result of a known key; for + example, it may be the result of a compose sequence or keyboard macro. + The \a modifiers holds the keyboard modifiers, and the given \a text + is the Unicode text that the key generated. If \a autorep is true, + isAutoRepeat() will be true. \a count is the number of keys involved + in the event. */ QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text, bool autorep, ushort count) diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index ed9654b..86894b4 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -753,6 +753,7 @@ bool QShortcutMap::correctGraphicsWidgetContext(Qt::ShortcutContext context, QGr tw = tw->parentWidget(); return tw == w; } + return false; } // Below is Qt::WindowShortcut context diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 35755c3..4eac35e 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -108,6 +108,7 @@ public: void setWidget(QWidget *w); void sendInputEvent(QWidget *widget, QInputEvent *inputEvent); void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; } + void CancelLongTapTimer(); protected: void Draw(const TRect& aRect) const; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 06f618d..dae4179 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2361,13 +2361,26 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool ) { Q_Q(QWidget); - createExtra(); - QStyle *oldStyle = q->style(); #ifndef QT_NO_STYLE_STYLESHEET - QStyle *origStyle = extra->style; + QStyle *origStyle = 0; +#endif + +#ifdef Q_WS_MAC + // the metalhack boolean allows Qt/Mac to do a proper re-polish depending + // on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever + // set when changing that attribute and passes the widget's CURRENT style. + // therefore no need to do a reassignment. + if (!metalHack) #endif - extra->style = newStyle; + { + createExtra(); + +#ifndef QT_NO_STYLE_STYLESHEET + origStyle = extra->style; +#endif + extra->style = newStyle; + } // repolish if (q->windowType() != Qt::Desktop) { @@ -6287,7 +6300,7 @@ QByteArray QWidget::saveGeometry() const returns false. If the restored geometry is off-screen, it will be modified to be - inside the the available screen geometry. + inside the available screen geometry. To restore geometry saved using QSettings, you can use code like this: diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index b315eaf..f863428 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -786,16 +786,6 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event, // By also setting the current modal window back into the event, we // help Carbon determining which window is supposed to be raised. handled_event = qApp->activePopupWidget() ? true : false; - QWidget *top = 0; - if (!QApplicationPrivate::tryModalHelper(widget, &top) && top && top != widget){ - if(!qt_mac_is_macsheet(top) || top->parentWidget() != widget) { - handled_event = true; - WindowPtr topWindowRef = qt_mac_window_for(top); - SetEventParameter(event, kEventParamModalWindow, typeWindowRef, sizeof(topWindowRef), &topWindowRef); - HIModalClickResult clickResult = kHIModalClickIsModal; - SetEventParameter(event, kEventParamModalClickResult, typeModalClickResult, sizeof(clickResult), &clickResult); - } - } #endif } else if(ekind == kEventWindowClose) { widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); @@ -4045,8 +4035,8 @@ void QWidgetPrivate::applyMaxAndMinSizeOnWindow() NSSize max = NSMakeSize(SF(extra->maxw), SF(extra->maxh)); NSSize min = NSMakeSize(SF(extra->minw), SF(extra->minh)); #undef SF - [qt_mac_window_for(q) setMinSize:min]; - [qt_mac_window_for(q) setMaxSize:max]; + [qt_mac_window_for(q) setContentMinSize:min]; + [qt_mac_window_for(q) setContentMaxSize:max]; #endif } diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 5d7d4ab..c50004e 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -1369,7 +1369,7 @@ QColor QColor::toRgb() const */ QColor QColor::toHsv() const { - if (!isValid()) + if (!isValid() || cspec == Hsv) return *this; if (cspec != Rgb) @@ -1421,7 +1421,7 @@ QColor QColor::toHsv() const */ QColor QColor::toCmyk() const { - if (!isValid()) + if (!isValid() || cspec == Cmyk) return *this; if (cspec != Rgb) return toRgb().toCmyk(); @@ -2241,4 +2241,12 @@ QDataStream &operator>>(QDataStream &stream, QColor &color) \sa QColor::rgb(), QColor::rgba() */ +/*! \fn void QColormap::initialize() + \internal +*/ + +/*! \fn void QColormap::cleanup() + \internal +*/ + QT_END_NAMESPACE diff --git a/src/gui/painting/qcolormap_x11.cpp b/src/gui/painting/qcolormap_x11.cpp index ccf6955..c9186b1 100644 --- a/src/gui/painting/qcolormap_x11.cpp +++ b/src/gui/painting/qcolormap_x11.cpp @@ -337,8 +337,6 @@ static void init_direct(QColormapPrivate *d, bool ownColormap) static QColormap **cmaps = 0; -/*! \internal -*/ void QColormap::initialize() { Display *display = QX11Info::display(); @@ -578,8 +576,6 @@ void QColormap::initialize() } } -/*! \internal -*/ void QColormap::cleanup() { Display *display = QX11Info::display(); diff --git a/src/gui/painting/qemulationpaintengine.cpp b/src/gui/painting/qemulationpaintengine.cpp index 3397c45..175f1ab 100644 --- a/src/gui/painting/qemulationpaintengine.cpp +++ b/src/gui/painting/qemulationpaintengine.cpp @@ -123,14 +123,30 @@ void QEmulationPaintEngine::stroke(const QVectorPath &path, const QPen &pen) real_engine->stroke(path, bgPen); } - QBrush brush = pen.brush(); + QPen copy = pen; Qt::BrushStyle style = qbrush_style(brush); if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) { const QGradient *g = brush.gradient(); + if (g->coordinateMode() > QGradient::LogicalMode) { - QPaintEngineEx::stroke(path, pen); - return; + if (g->coordinateMode() == QGradient::StretchToDeviceMode) { + QTransform mat = brush.transform(); + mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); + brush.setTransform(mat); + copy.setBrush(brush); + real_engine->stroke(path, copy); + return; + } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) { + QTransform mat = brush.transform(); + QRealRect r = path.controlPointRect(); + mat.translate(r.x1, r.y1); + mat.scale(r.x2 - r.x1, r.y2 - r.y1); + brush.setTransform(mat); + copy.setBrush(brush); + real_engine->stroke(path, copy); + return; + } } } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index baa9ce3..cc48d24 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7159,14 +7159,14 @@ QPoint QPainter::xFormDev(const QPoint &p) const \fn QRect QPainter::xFormDev(const QRect &rectangle) const \overload - Use combineMatrix() combined with QMatrix::inverted() instead. + Use mapRect() combined with QMatrix::inverted() instead. \oldcode QPainter painter(this); QRect transformed = painter.xFormDev(rectangle); \newcode QPainter painter(this); - QRect transformed = rectangle * painter.combinedMatrix().inverted(); + QRect transformed = painter.combinedMatrix().inverted(rectangle); \endcode */ diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index e1f5eea..9ce16d3 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1006,7 +1006,7 @@ void QPainterPath::addPolygon(const QPolygonF &polygon) /*! \fn void QPainterPath::addEllipse(const QRectF &boundingRectangle) - Creates an ellipse within the the specified \a boundingRectangle + Creates an ellipse within the specified \a boundingRectangle and adds it to the painter path as a closed subpath. The ellipse is composed of a clockwise curve, starting and diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 1ea40ba..3fd1ffb 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -88,11 +88,12 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti, ti.ascent.toReal(), ti.descent.toReal()); #endif - int glyph_width = metrics.width.ceil().toInt() + margin * 2; - int glyph_height = metrics.height.ceil().toInt() + margin * 2; + int glyph_width = metrics.width.ceil().toInt(); + int glyph_height = metrics.height.ceil().toInt(); if (glyph_height == 0 || glyph_width == 0) continue; - + glyph_width += margin * 2 + 2; + glyph_height += margin * 2 + 2; // align to 8-bit boundary if (m_type == QFontEngineGlyphCache::Raster_Mono) glyph_width = (glyph_width+7)&~7; @@ -188,11 +189,7 @@ void QImageTextureGlyphCache::createTextureData(int width, int height) int QImageTextureGlyphCache::glyphMargin() const { -#ifdef Q_WS_MAC return 2; -#else - return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; -#endif } void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g) diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 2383272..cec2d16 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1355,7 +1355,8 @@ static inline QHomogeneousCoordinate mapHomogeneous(const QTransform &transform, return c; } -static inline bool lineTo_clipped(QPainterPath &path, const QTransform &transform, const QPointF &a, const QPointF &b, bool needsMoveTo) +static inline bool lineTo_clipped(QPainterPath &path, const QTransform &transform, const QPointF &a, const QPointF &b, + bool needsMoveTo, bool needsLineTo = true) { QHomogeneousCoordinate ha = mapHomogeneous(transform, a); QHomogeneousCoordinate hb = mapHomogeneous(transform, b); @@ -1388,7 +1389,8 @@ static inline bool lineTo_clipped(QPainterPath &path, const QTransform &transfor if (needsMoveTo) path.moveTo(ha.toPoint()); - path.lineTo(hb.toPoint()); + if (needsLineTo) + path.lineTo(hb.toPoint()); return true; } @@ -1455,7 +1457,7 @@ static QPainterPath mapProjective(const QTransform &transform, const QPainterPat } if (path.elementCount() > 0 && lastMoveTo != last) - lineTo_clipped(result, transform, last, lastMoveTo, needsMoveTo); + lineTo_clipped(result, transform, last, lastMoveTo, needsMoveTo, false); return result; } diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index 0842ec7..d8a67c2 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -633,31 +633,14 @@ GtkStyle* QGtk::gtkStyle(const QString &path) return 0; } -#ifdef Q_OS_LINUX -QT_END_NAMESPACE - -int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); -int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); - -QT_BEGIN_NAMESPACE -#endif - void QGtk::initGtkWidgets() { // From gtkmain.c - - uid_t ruid, rgid, euid, egid, suid, sgid; - -#ifdef Q_OS_LINUX - if (getresuid (&ruid, &euid, &suid) != 0 || getresgid (&rgid, &egid, &sgid) != 0) -#endif - { - suid = ruid = getuid (); - sgid = rgid = getgid (); - euid = geteuid (); - egid = getegid (); - } - if (ruid != euid || ruid != suid || rgid != egid || rgid != sgid) { + uid_t ruid = getuid (); + uid_t rgid = getgid (); + uid_t euid = geteuid (); + uid_t egid = getegid (); + if (ruid != euid || rgid != egid) { qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this " "therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', " "\'kdesudo\' or a similar tool.\n\n" diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 3cae08a..f3d1537 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -1693,7 +1693,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { pr.setHeight(pmSize.height() + 6); - tr.adjust(0, pr.height(), 0, -3); + tr.adjust(0, pr.height() - 1, 0, -3); pr.translate(shiftX, shiftY); if (!hasArrow) { drawItemPixmap(p, pr, Qt::AlignCenter, pm); diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index ca71da2..86653df 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -140,10 +140,7 @@ static const char * const dock_widget_restore_xpm[] = class QGtkStyleFilter : public QObject { public: - QGtkStyleFilter() { - qApp->installEventFilter(this); - } - + QGtkStyleFilter() {} private: bool eventFilter(QObject *obj, QEvent *e); }; @@ -167,7 +164,12 @@ class QGtkStylePrivate : public QCleanlooksStylePrivate public: QGtkStylePrivate() : QCleanlooksStylePrivate() - {} + { + QGtk::initGtkWidgets(); + if (QGtk::isThemeAvailable()) + qApp->installEventFilter(&filter); + + } QGtkStyleFilter filter; }; @@ -243,7 +245,6 @@ static QString uniqueName(const QString &key, const QStyleOption *option, const QGtkStyle::QGtkStyle() : QCleanlooksStyle(*new QGtkStylePrivate) { - QGtk::initGtkWidgets(); } /*! diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 7a870fe..1be3d6e 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -39,6 +39,11 @@ ** ****************************************************************************/ +/* + Note: The qdoc comments for QMacStyle are contained in + .../doc/src/qstyles.qdoc. +*/ + #include "qmacstyle_mac.h" #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) @@ -1988,87 +1993,12 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD p->drawPixmap(int(macRect.origin.x), int(macRect.origin.y) + finalyoff, width, height, pm); } -/*! - \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 -*/ - -/*! - Constructs a QMacStyle object. -*/ QMacStyle::QMacStyle() : QWindowsStyle() { d = new QMacStylePrivate(this); } -/*! - Destructs a QMacStyle object. -*/ QMacStyle::~QMacStyle() { delete qt_mac_backgroundPattern; @@ -2142,7 +2072,6 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint } } -/*! \reimp */ void QMacStyle::polish(QPalette &pal) { if (!qt_mac_backgroundPattern) { @@ -2166,17 +2095,14 @@ void QMacStyle::polish(QPalette &pal) } } -/*! \reimp */ void QMacStyle::polish(QApplication *) { } -/*! \reimp */ void QMacStyle::unpolish(QApplication *) { } -/*! \reimp */ void QMacStyle::polish(QWidget* w) { d->addWidget(w); @@ -2240,7 +2166,6 @@ void QMacStyle::polish(QWidget* w) } } -/*! \reimp */ void QMacStyle::unpolish(QWidget* w) { d->removeWidget(w); @@ -2271,7 +2196,6 @@ void QMacStyle::unpolish(QWidget* w) QWindowsStyle::unpolish(w); } -/*! \reimp */ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const { int controlSize = getControlSize(opt, widget); @@ -2650,7 +2574,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW return ret; } -/*! \reimp */ QPalette QMacStyle::standardPalette() const { QPalette pal = QWindowsStyle::standardPalette(); @@ -2660,7 +2583,6 @@ QPalette QMacStyle::standardPalette() const return pal; } -/*! \reimp */ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *hret) const { @@ -2955,7 +2877,6 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w return ret; } -/*! \reimp */ QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const { @@ -2981,7 +2902,6 @@ QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixm } -/*! \reimp */ QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const { @@ -3012,31 +2932,7 @@ QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOpt } return icon.pixmap(size, size); } -/*! - \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. -*/ - -/*! - \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() -*/ void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy) { switch (policy) { @@ -3049,29 +2945,11 @@ void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy) } } -/*! - \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() -*/ QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w) { return w->testAttribute(Qt::WA_MacShowFocusRect) ? FocusEnabled : FocusDisabled; } -/*! - \obsolete - - Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, - or Qt::WA_MacNormalSize instead. -*/ void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy) { QWidget *wadget = const_cast<QWidget *>(widget); @@ -3080,12 +2958,6 @@ void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy poli wadget->setAttribute(Qt::WA_MacMiniSize, policy == SizeMini); } -/*! - \obsolete - - Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, - or Qt::WA_MacNormalSize instead. -*/ QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget) { while (widget) { @@ -3101,7 +2973,6 @@ QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget) return SizeDefault; } -/*! \reimp */ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const { @@ -3534,7 +3405,6 @@ static inline QPixmap darkenPixmap(const QPixmap &pixmap) -/*! \reimp */ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const { @@ -4558,7 +4428,7 @@ static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect rect->adjust(left, top, right, bottom); } } -/*! \reimp */ + QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const { @@ -4852,7 +4722,6 @@ static inline void drawToolbarButtonArrow(const QRect &toolButtonRect, ThemeDraw HIThemeDrawPopupArrow(&hirect, &padi, cg, kHIThemeOrientationNormal); } -/*! \reimp */ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const { @@ -5235,7 +5104,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex arrowOpt.state = tb->state; arrowOpt.palette = tb->palette; drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); - } else if (tb->features & QStyleOptionToolButton::HasMenu) { + } else if ((tb->features & QStyleOptionToolButton::HasMenu) + && (tb->toolButtonStyle != Qt::ToolButtonTextOnly && !tb->icon.isNull())) { drawToolbarButtonArrow(tb->rect, tds, cg); } if (tb->state & State_On) { @@ -5349,7 +5219,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } } -/*! \reimp */ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget) const @@ -5480,7 +5349,6 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, return sc; } -/*! \reimp */ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const { @@ -5820,7 +5688,6 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op return ret; } -/*! \reimp */ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const { @@ -6107,9 +5974,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, return sz; } -/*! - \reimp -*/ void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const { @@ -6118,9 +5982,6 @@ void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPale QWindowsStyle::drawItemText(p, r, flags, pal, enabled, text, textRole); } -/*! - \reimp -*/ bool QMacStyle::event(QEvent *e) { if(e->type() == QEvent::FocusIn) { @@ -6195,9 +6056,6 @@ void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayI } } -/*! - \internal -*/ QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt, const QWidget *widget) const { @@ -6311,9 +6169,6 @@ QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const Q return QWindowsStyle::standardIconImplementation(standardIcon, opt, widget); } -/*! - \internal -*/ int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index caac359..071b60a 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -10,33 +10,39 @@ ****************************************************************************/ #include "qs60style_p.h" + #include "qapplication.h" #include "qpainter.h" #include "qstyleoption.h" #include "qresizeevent" #include "qpixmapcache" -#include "qlistview.h" + #include "qcalendarwidget.h" -#include "qtabbar.h" +#include "qdial.h" +#include "qdialog.h" +#include "qerrormessage.h" +#include "qgroupbox.h" +#include "qheaderview.h" +#include "qlist.h" #include "qlistwidget.h" +#include "qlistview.h" #include "qmenu.h" -#include "qpushbutton.h" #include "qmenubar.h" +#include "qmessagebox.h" +#include "qpushbutton.h" +#include "qscrollarea.h" +#include "qscrollbar.h" +#include "qtabbar.h" #include "qtablewidget.h" +#include "qtableview.h" #include "qtoolbar.h" -#include "qgroupbox.h" #include "qtoolbutton.h" +#include "qtreeview.h" + #include "private/qtoolbarextension_p.h" #include "private/qcombobox_p.h" #include "private/qwidget_p.h" -#include "qscrollbar.h" -#include "qlist.h" -#include "qtableview.h" -#include "qheaderview.h" -#include "qtreeview.h" -#include "qdialog.h" -#include "qmessagebox.h" -#include "qerrormessage.h" +#include "private/qapplication_p.h" #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) @@ -105,113 +111,13 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme {SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter}, {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, + {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, }; static const int frameElementsCount = int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); const int KNotFound = -1; -void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart, - QPainter *painter, const QRect &rect, SkinElementFlags flags) -{ - static const bool doCache = -#if defined(Q_WS_S60) - // Freezes on 3.1. Anyways, caching is only really needed on touch UI - !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); -#else - true; -#endif - const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags)); - if (!skinPartPixMap.isNull()) - painter->drawPixmap(rect.topLeft(), skinPartPixMap); -} - -void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags) -{ - static const bool doCache = -#if defined(Q_WS_S60) - // Freezes on 3.1. Anyways, caching is only really needed on touch UI - !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); -#else - true; -#endif - const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags)); - if (!frameElementPixMap.isNull()) - painter->drawPixmap(rect.topLeft(), frameElementPixMap); -} - -void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start, - QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end, - Qt::Orientation orientation, QPainter *painter, const QRect &rect, - SkinElementFlags flags) -{ - QSize startEndSize(partSize(start, flags)); - startEndSize.scale(rect.size(), Qt::KeepAspectRatio); - - QRect startRect = QRect(rect.topLeft(), startEndSize); - QRect middleRect = rect; - QRect endRect; - - if (orientation == Qt::Horizontal) { - startRect.setWidth(qMin(rect.width() / 2 - 1, startRect.width())); - endRect = startRect.translated(rect.width() - startRect.width(), 0); - middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); - } else { - startRect.setHeight(qMin(rect.height() / 2 - 1, startRect.height())); - endRect = startRect.translated(0, rect.height() - startRect.height()); - middleRect.adjust(0, startRect.height(), 0, -startRect.height()); - } - -#if 0 - painter->save(); - painter->setOpacity(.3); - painter->fillRect(startRect, Qt::red); - painter->fillRect(middleRect, Qt::green); - painter->fillRect(endRect, Qt::blue); - painter->restore(); -#else - drawPart(start, painter, startRect, flags); - if (middleRect.isValid()) - drawPart(middle, painter, middleRect, flags); - drawPart(end, painter, endRect, flags); -#endif -} - -QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, - const QSize &size, SkinElementFlags flags) -{ - QPixmap result; - const QString cacheKey = - QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinElementFlags=%4") - .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags); - if (!QPixmapCache::find(cacheKey, result)) { - result = QS60StylePrivate::part(part, size, flags); - QPixmapCache::insert(cacheKey, result); - } - return result; -} - -QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags) -{ - QPixmap result; - const QString cacheKey = - QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4") - .arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags); - if (!QPixmapCache::find(cacheKey, result)) { - result = QS60StylePrivate::frame(frame, size, flags); - QPixmapCache::insert(cacheKey, result); - } - return result; -} - -void QS60StylePrivate::refreshUI() -{ - foreach (QWidget *topLevelWidget, QApplication::allWidgets()) { - topLevelWidget->updateGeometry(); - QCoreApplication::postEvent(topLevelWidget, new QResizeEvent(topLevelWidget->size(), topLevelWidget->size())); - } -} - void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, const QRect &rect, SkinElementFlags flags) { @@ -331,78 +237,14 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed, QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, Qt::Vertical, painter, rect, flags | SF_PointNorth); break; + case SE_ButtonInactive: + drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); + break; default: break; } } -QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) -{ - QSize result(20, 20); - switch (part) - { - case QS60StyleEnums::SP_QgnGrafBarProgress: - result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth)); - break; - case QS60StyleEnums::SP_QgnGrafTabActiveM: - case QS60StyleEnums::SP_QgnGrafTabPassiveM: - case QS60StyleEnums::SP_QgnGrafTabActiveR: - case QS60StyleEnums::SP_QgnGrafTabPassiveR: - case QS60StyleEnums::SP_QgnGrafTabPassiveL: - case QS60StyleEnums::SP_QgnGrafTabActiveL: - break; - case QS60StyleEnums::SP_QgnIndiSliderEdit: - result.scale(pixelMetric(QStyle::PM_SliderLength), - pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); - break; - - case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: - case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: - case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: - case QS60StyleEnums::SP_QsnCpScrollBgBottom: - case QS60StyleEnums::SP_QsnCpScrollBgMiddle: - case QS60StyleEnums::SP_QsnCpScrollBgTop: - case QS60StyleEnums::SP_QsnCpScrollHandleBottom: - case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: - case QS60StyleEnums::SP_QsnCpScrollHandleTop: - result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); - result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent)); - break; - default: - // Generic frame part size gathering. - for (int i = 0; i < frameElementsCount; ++i) - { - switch (m_frameElementsData[i].center - part) { - case 8: /* CornerTl */ - case 7: /* CornerTr */ - case 6: /* CornerBl */ - case 5: /* CornerBr */ - result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); - // Falltrough intended... - case 4: /* SideT */ - case 3: /* SideB */ - result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight)); - break; - case 2: /* SideL */ - case 1: /* SideR */ - result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); - break; - case 0: /* center */ - default: - break; - } - } - break; - } - if (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)) { - const int temp = result.width(); - result.setWidth(result.height()); - result.setHeight(temp); - } - return result; -} - - void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part, QPainter *painter, const QRect &rect, SkinElementFlags flags) { @@ -428,6 +270,109 @@ void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) } } +QVariant QS60StylePrivate::styleProperty(const char *name) const +{ + if (name == propertyKeyLayouts) { +#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) + static QStringList layouts; + if (layouts.isEmpty()) + for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++) + layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName); + return layouts; +#else + qFatal("Cannot return list of 'canned' static layouts. Dynamic layouts are used!"); +#endif + } + return QVariant(); +} + +QColor QS60StylePrivate::stateColor(const QColor& color, const QStyleOption *option) +{ + QColor retColor (color); + if (option && !(option->state & QStyle::State_Enabled)) { + QColor hsvColor = retColor.toHsv(); + int colorSat = hsvColor.saturation(); + int colorVal = hsvColor.value(); + colorSat = (colorSat!=0) ? (colorSat>>1) : 128; + colorVal = (colorVal!=0) ? (colorVal>>1) : 128; + hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal); + retColor = hsvColor.toRgb(); + } + return retColor; +} + +QColor QS60StylePrivate::lighterColor(const QColor &baseColor) +{ + QColor result(baseColor); + bool modifyColor = false; + if (result.saturation() == 0) { + result.setHsv(result.hue(), 128, result.value()); + modifyColor = true; + } + if (result.value() == 0) { + result.setHsv(result.hue(), result.saturation(), 128); + modifyColor = true; + } + if (modifyColor) + result = result.lighter(175); + else + result = result.lighter(225); + return result; +} + +bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget) +{ + return (qobject_cast<const QMessageBox *> (widget) || + qobject_cast<const QErrorMessage *> (widget)); +} + +QFont QS60StylePrivate::s60Font( + QS60StyleEnums::FontCategories fontCategory, int pointSize) const +{ + QFont result; + int actualPointSize = pointSize; + if (actualPointSize <= 0) { + const QFont appFont = QApplication::font(); + actualPointSize = appFont.pointSize(); + if (actualPointSize <= 0) + actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY(); + } + Q_ASSERT(actualPointSize > 0); + const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); + if (!m_mappedFontsCache.contains(key)) { + result = s60Font_specific(fontCategory, actualPointSize); + m_mappedFontsCache.insert(key, result); + } else { + result = m_mappedFontsCache.value(key); + if (result.pointSize() != actualPointSize) + result.setPointSize(actualPointSize); + } + return result; +} + +void QS60StylePrivate::clearCaches(QS60StylePrivate::CacheClearReason reason) +{ + switch(reason){ + case CC_LayoutChange: + // when layout changes, the colors remain in cache, but graphics and fonts can change + m_mappedFontsCache.clear(); + m_backgroundValid = false; + QPixmapCache::clear(); + break; + case CC_ThemeChange: + m_colorCache.clear(); + QPixmapCache::clear(); + m_backgroundValid = false; + case CC_UndefinedChange: + default: + m_colorCache.clear(); + m_mappedFontsCache.clear(); + QPixmapCache::clear(); + m_backgroundValid = false; + break; + } +} + // Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use // for QPalette::Button and QPalette::ToolTipBase. Therefore we need to guesstimate // this by calculating average rgb values for button pixels. @@ -449,7 +394,6 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme const int pixels = frameImage.numBytes()/sizeof(QRgb); const int bytesPerLine = frameImage.bytesPerLine(); Q_ASSERT(bytesPerLine); - const int rows = frameImage.numBytes()/(sizeof(QRgb)*bytesPerLine); int estimatedRed = 0; int estimatedGreen = 0; @@ -490,11 +434,6 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme } -int QS60StylePrivate::focusRectPenWidth() -{ - return pixelMetric(QS60Style::PM_DefaultFrameWidth); -} - void QS60StylePrivate::setThemePalette(QApplication *app) const { if (!app) @@ -524,7 +463,7 @@ void QS60StylePrivate::setThemePalette(QApplication *app) const widgetPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); widgetPalette.setColor(QPalette::Base, Qt::transparent); // set button and tooltipbase based on pixel colors - QColor buttonColor = colorFromFrameGraphics(QS60StylePrivate::SF_ButtonNormal); + const QColor buttonColor = colorFromFrameGraphics(QS60StylePrivate::SF_ButtonNormal); widgetPalette.setColor(QPalette::Button, buttonColor ); widgetPalette.setColor(QPalette::Light, widgetPalette.color(QPalette::Button).lighter()); widgetPalette.setColor(QPalette::Dark, widgetPalette.color(QPalette::Button).darker()); @@ -537,46 +476,10 @@ void QS60StylePrivate::setThemePalette(QApplication *app) const app->setPalette(widgetPalette); } -void QS60StylePrivate::setBackgroundTexture(QApplication *app) const +void QS60StylePrivate::setThemePalette(QWidget *widget) const { - if (!app) - return; - QPalette applicationPalette = app->palette(); - applicationPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); - app->setPalette(applicationPalette); -} - -void QS60Style::polish(QApplication *application) -{ - Q_D(const QS60Style); - originalPalette = application->palette(); - d->setThemePalette(application); -} - -void QS60Style::polish(QWidget *widget) -{ - Q_D(const QS60Style); - QCommonStyle::polish(widget); - - if (!widget) + if(!widget) return; - - if (QS60StylePrivate::isSkinnableDialog(widget)) { - widget->setAttribute(Qt::WA_StyledBackground); - } else if (false -#ifndef QT_NO_MENU - || qobject_cast<const QMenu *> (widget) -#endif // QT_NO_MENU - ) { - widget->setAttribute(Qt::WA_StyledBackground); - } else if (false -#ifndef QT_NO_COMBOBOX - || qobject_cast<const QComboBoxListView *>(widget) -#endif //QT_NO_COMBOBOX - ) { - widget->setAttribute(Qt::WA_StyledBackground); - } - QPalette widgetPalette = widget->palette(); // widget specific colors and fonts @@ -585,16 +488,19 @@ void QS60Style::polish(QWidget *widget) QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); QApplication::setPalette(widgetPalette, "QSlider"); } else if (qobject_cast<QPushButton *>(widget)){ - const QFont suggestedFont = d->s60Font( + const QFont suggestedFont = s60Font( QS60StyleEnums::FC_Primary, widget->font().pointSizeF()); widget->setFont(suggestedFont); widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + const QStyleOption opt; + widgetPalette.setColor(QPalette::Disabled, QPalette::ButtonText, + QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt)); QApplication::setPalette(widgetPalette, "QPushButton"); } else if (qobject_cast<QToolButton *>(widget)){ - const QFont suggestedFont = d->s60Font( + const QFont suggestedFont = s60Font( QS60StyleEnums::FC_Primary, widget->font().pointSizeF()); widget->setFont(suggestedFont); widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, @@ -603,7 +509,7 @@ void QS60Style::polish(QWidget *widget) QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); QApplication::setPalette(widgetPalette, "QToolButton"); } else if (qobject_cast<QHeaderView *>(widget)){ - const QFont suggestedFont = d->s60Font( + const QFont suggestedFont = s60Font( QS60StyleEnums::FC_Secondary, widget->font().pointSizeF()); widget->setFont(suggestedFont); widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, @@ -626,142 +532,216 @@ void QS60Style::polish(QWidget *widget) QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); QApplication::setPalette(widgetPalette, "QTableView"); } else if (qobject_cast<QGroupBox *>(widget)){ - const QFont suggestedFont = d->s60Font( + const QFont suggestedFont = s60Font( QS60StyleEnums::FC_Title, widget->font().pointSizeF()); widget->setFont(suggestedFont); } else if (qobject_cast<QLineEdit *>(widget)) { - widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, + widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QLineEdit"); - + } else if (qobject_cast<QDial *> (widget)) { + const QColor color(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + widgetPalette.setColor(QPalette::WindowText, color); + widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); + widgetPalette.setColor(QPalette::Dark, color.darker()); + widgetPalette.setColor(QPalette::Light, color.lighter()); + QApplication::setPalette(widgetPalette, "QDial"); + } else if (qobject_cast<QScrollArea *>(widget)) { + widgetPalette.setBrush(QPalette::Window, QBrush()); + QApplication::setPalette(widgetPalette, "QScrollArea"); } } -void QS60Style::unpolish(QApplication *application) +void QS60StylePrivate::setBackgroundTexture(QApplication *app) const { - application->setPalette(originalPalette); + if (!app) + return; + QPalette applicationPalette = app->palette(); + applicationPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); + app->setPalette(applicationPalette); } -void QS60Style::unpolish(QWidget *widget) +int QS60StylePrivate::focusRectPenWidth() { - if (QS60StylePrivate::isSkinnableDialog(widget)) { - widget->setAttribute(Qt::WA_StyledBackground, false); - } else if (false -#ifndef QT_NO_MENU - || qobject_cast<const QMenu *> (widget) -#endif // QT_NO_MENU - ) { - widget->setAttribute(Qt::WA_StyledBackground, false); - } else if (false -#ifndef QT_NO_COMBOBOX - || qobject_cast<const QComboBoxListView *>(widget) -#endif //QT_NO_COMBOBOX - ) { - widget->setAttribute(Qt::WA_StyledBackground, false); - } + return pixelMetric(QS60Style::PM_DefaultFrameWidth); +} - if (widget) { - widget->setPalette(QPalette()); - } +#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) +void QS60StylePrivate::setCurrentLayout(int index) +{ + m_pmPointer = data[index]; +} +#endif - QCommonStyle::unpolish(widget); + +void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart, + QPainter *painter, const QRect &rect, SkinElementFlags flags) +{ + static const bool doCache = +#if defined(Q_WS_S60) + // Freezes on 3.1. Anyways, caching is only really needed on touch UI + !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); +#else + true; +#endif + const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags)); + if (!skinPartPixMap.isNull()) + painter->drawPixmap(rect.topLeft(), skinPartPixMap); } -QVariant QS60StylePrivate::styleProperty(const char *name) const +void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags) { - if (name == propertyKeyLayouts) { -#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) - static QStringList layouts; - if (layouts.isEmpty()) - for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++) - layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName); - return layouts; + static const bool doCache = +#if defined(Q_WS_S60) + // Freezes on 3.1. Anyways, caching is only really needed on touch UI + !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); #else - qFatal("Cannot return list of 'canned' static layouts. Dynamic layouts are used!"); + true; #endif - } - return QVariant(); + const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags)); + if (!frameElementPixMap.isNull()) + painter->drawPixmap(rect.topLeft(), frameElementPixMap); } -QFont QS60StylePrivate::s60Font( - QS60StyleEnums::FontCategories fontCategory, int pointSize) const +void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start, + QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end, + Qt::Orientation orientation, QPainter *painter, const QRect &rect, + SkinElementFlags flags) { - QFont result; - int actualPointSize = pointSize; - if (actualPointSize <= 0) { - const QFont appFont = QApplication::font(); - actualPointSize = appFont.pointSize(); - if (actualPointSize <= 0) - actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY(); - } - Q_ASSERT(actualPointSize > 0); - const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); - if (!m_mappedFontsCache.contains(key)) { - result = s60Font_specific(fontCategory, actualPointSize); - m_mappedFontsCache.insert(key, result); + QSize startEndSize(partSize(start, flags)); + startEndSize.scale(rect.size(), Qt::KeepAspectRatio); + + QRect startRect = QRect(rect.topLeft(), startEndSize); + QRect middleRect = rect; + QRect endRect; + + if (orientation == Qt::Horizontal) { + startRect.setWidth(qMin(rect.width() / 2 - 1, startRect.width())); + endRect = startRect.translated(rect.width() - startRect.width(), 0); + middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); } else { - result = m_mappedFontsCache.value(key); - if (result.pointSize() != actualPointSize) - result.setPointSize(actualPointSize); + startRect.setHeight(qMin(rect.height() / 2 - 1, startRect.height())); + endRect = startRect.translated(0, rect.height() - startRect.height()); + middleRect.adjust(0, startRect.height(), 0, -startRect.height()); } - return result; -} -//todo: you could pass a reason to clear cache here, so that we could -// deduce whether or not the specific cache needs to be cleared -void QS60StylePrivate::clearCaches() -{ - m_colorCache.clear(); - m_mappedFontsCache.clear(); - QPixmapCache::clear(); - m_backgroundValid = false; +#if 0 + painter->save(); + painter->setOpacity(.3); + painter->fillRect(startRect, Qt::red); + painter->fillRect(middleRect, Qt::green); + painter->fillRect(endRect, Qt::blue); + painter->restore(); +#else + drawPart(start, painter, startRect, flags); + if (middleRect.isValid()) + drawPart(middle, painter, middleRect, flags); + drawPart(end, painter, endRect, flags); +#endif } -QColor QS60StylePrivate::lighterColor(const QColor &baseColor) +QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, + const QSize &size, SkinElementFlags flags) { - QColor result(baseColor); - bool modifyColor = false; - if (result.saturation() == 0) { - result.setHsv(result.hue(), 128, result.value()); - modifyColor = true; - } - if (result.value() == 0) { - result.setHsv(result.hue(), result.saturation(), 128); - modifyColor = true; + QPixmap result; + const QString cacheKey = + QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4") + .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags); + if (!QPixmapCache::find(cacheKey, result)) { + result = QS60StylePrivate::part(part, size, flags); + QPixmapCache::insert(cacheKey, result); } - if (modifyColor) - result = result.lighter(175); - else - result = result.lighter(225); return result; } -bool QS60StylePrivate::isSkinnableDialog(const QWidget *widget) +QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags) { - return (qobject_cast<const QMessageBox *> (widget) || - qobject_cast<const QErrorMessage *> (widget)); + QPixmap result; + const QString cacheKey = + QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4") + .arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags); + if (!QPixmapCache::find(cacheKey, result)) { + result = QS60StylePrivate::frame(frame, size, flags); + QPixmapCache::insert(cacheKey, result); + } + return result; } -#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) -void QS60StylePrivate::setCurrentLayout(int index) +void QS60StylePrivate::refreshUI() { - m_pmPointer = data[index]; + foreach (QWidget *topLevelWidget, QApplication::allWidgets()) { + topLevelWidget->updateGeometry(); + //todo: study how we can get rid of this. Apparently scrollbars cache pixelmetrics values, and we need them to update themselves + // maybe styleChanged event is enough? + //QCoreApplication::postEvent(topLevelWidget, new QEvent(QEvent::StyleChange)); + QCoreApplication::postEvent(topLevelWidget, new QResizeEvent(topLevelWidget->size(), topLevelWidget->size())); + } } -#endif -QColor QS60StylePrivate::stateColor(const QColor& color, const QStyleOption *option) +QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) { - QColor retColor (color); - if (option && !(option->state & QStyle::State_Enabled)) { - QColor hsvColor = retColor.toHsv(); - int colorSat = hsvColor.saturation(); - int colorVal = hsvColor.value(); - colorSat = (colorSat!=0) ? (colorSat>>1) : 128; - colorVal = (colorVal!=0) ? (colorVal>>1) : 128; - hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal); - retColor = hsvColor.toRgb(); + QSize result(20, 20); + switch (part) + { + case QS60StyleEnums::SP_QgnGrafBarProgress: + result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth)); + break; + case QS60StyleEnums::SP_QgnGrafTabActiveM: + case QS60StyleEnums::SP_QgnGrafTabPassiveM: + case QS60StyleEnums::SP_QgnGrafTabActiveR: + case QS60StyleEnums::SP_QgnGrafTabPassiveR: + case QS60StyleEnums::SP_QgnGrafTabPassiveL: + case QS60StyleEnums::SP_QgnGrafTabActiveL: + break; + case QS60StyleEnums::SP_QgnIndiSliderEdit: + result.scale(pixelMetric(QStyle::PM_SliderLength), + pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); + break; + + case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: + case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: + case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: + case QS60StyleEnums::SP_QsnCpScrollBgBottom: + case QS60StyleEnums::SP_QsnCpScrollBgMiddle: + case QS60StyleEnums::SP_QsnCpScrollBgTop: + case QS60StyleEnums::SP_QsnCpScrollHandleBottom: + case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: + case QS60StyleEnums::SP_QsnCpScrollHandleTop: + result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); + result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent)); + break; + default: + // Generic frame part size gathering. + for (int i = 0; i < frameElementsCount; ++i) + { + switch (m_frameElementsData[i].center - part) { + case 8: /* CornerTl */ + case 7: /* CornerTr */ + case 6: /* CornerBl */ + case 5: /* CornerBr */ + result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); + // Falltrough intended... + case 4: /* SideT */ + case 3: /* SideB */ + result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight)); + break; + case 2: /* SideL */ + case 1: /* SideR */ + result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); + break; + case 0: /* center */ + default: + break; + } + } + break; } - return retColor; + if (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)) { + const int temp = result.width(); + result.setWidth(result.height()); + result.setHeight(temp); + } + return result; } /*! @@ -793,8 +773,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; SubControls sub = option->subControls; - Q_D(const QS60Style); - switch (control) { #ifndef QT_NO_SCROLLBAR case CC_ScrollBar: @@ -807,18 +785,18 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const QS60StylePrivate::SkinElements grooveElement = horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical; QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags); - - QStyle::SubControls subControls = optionSlider->subControls; - + + QStyle::SubControls subControls = optionSlider->subControls; + // select correct slider (horizontal/vertical/pressed) const bool sliderPressed = ((optionSlider->state & QStyle::State_Sunken) && (subControls & SC_ScrollBarSlider)); const QS60StylePrivate::SkinElements handleElement = - horizontal ? - ( sliderPressed ? - QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal : - QS60StylePrivate::SE_ScrollBarHandleHorizontal ) : - ( sliderPressed ? - QS60StylePrivate::SE_ScrollBarHandlePressedVertical : + horizontal ? + ( sliderPressed ? + QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal : + QS60StylePrivate::SE_ScrollBarHandleHorizontal ) : + ( sliderPressed ? + QS60StylePrivate::SE_ScrollBarHandlePressedVertical : QS60StylePrivate::SE_ScrollBarHandleVertical); QS60StylePrivate::drawSkinElement(handleElement, painter, scrollBarSlider, flags); } @@ -864,7 +842,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const bool direction = cmb->direction == Qt::LeftToRight; // Button frame - //todo: why calc rect here for button? Is there no suitable SE_xxx for that? QStyleOptionFrame buttonOption; buttonOption.QStyleOption::operator=(*cmb); const int maxHeight = cmbxFrame.height(); @@ -874,20 +851,14 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom buttonOption.rect = buttonRect; buttonOption.state = cmb->state & (State_Enabled | State_MouseOver); drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); - // todo: we could draw qgn_prop_set_button skin item here // draw label background - label itself is drawn separately const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit; QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); if (sub & SC_ComboBoxArrow) { - const int iconRectWidth = buttonOption.rect.width()>>1; - const int nudgeWidth = iconRectWidth>>1; - // Draw the little arrow - const QRect arrowRect(((buttonOption.rect.left()+buttonOption.rect.right())>>1) - nudgeWidth, - buttonOption.rect.center().y()-(buttonOption.rect.height()>>2)+nudgeWidth, iconRectWidth, iconRectWidth); - + buttonOption.rect.adjust(1, 1, -1, -1); painter->save(); painter->setPen(option->palette.buttonText().color()); drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget); @@ -1129,18 +1100,15 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom } break; #endif //QT_NO_GROUPBOX - - //todo: remove non-used complex widgets in final version - case CC_TitleBar: -#ifdef QT3_SUPPORT - case CC_Q3ListView: -#endif //QT3_SUPPORT #ifndef QT_NO_DIAL case CC_Dial: + if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { + QStyleOptionSlider optionSlider = *slider; + QCommonStyle::drawComplexControl(control, &optionSlider, painter, widget); + } + break; #endif //QT_NO_DIAL -#ifndef QT_NO_WORKSPACE - case CC_MdiControls: -#endif //QT_NO_WORKSPACE + default: QCommonStyle::drawComplexControl(control, option, painter, widget); } @@ -1161,21 +1129,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); - if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) { - if (buttonWidget->isCheckable()) { - QStyleOptionButton checkopt = subopt; - - const int indicatorHeight(pixelMetric(PM_IndicatorHeight)); - const int verticalAdjust = (option->rect.height() - indicatorHeight) >> 1; - - checkopt.rect.adjust(pixelMetric(PM_ButtonMargin), verticalAdjust, 0, 0); - checkopt.rect.setWidth(pixelMetric(PM_IndicatorWidth)); - checkopt.rect.setHeight(indicatorHeight); - - drawPrimitive(PE_IndicatorCheckBox, &checkopt, painter, widget); - } - } - drawControl(CE_PushButtonLabel, &subopt, painter, widget); if (btn->state & State_HasFocus) { QStyleOptionFocusRect fropt; @@ -1187,29 +1140,35 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, break; case CE_PushButtonBevel: if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { - const bool isPressed = option->state & QStyle::State_Sunken; - if (button->features & QStyleOptionButton::Flat) { - const QS60StyleEnums::SkinParts skinPart = - isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter; - QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); + const bool isDisabled = !(option->state & QStyle::State_Enabled); + const bool isFlat = button->features & QStyleOptionButton::Flat; + QS60StyleEnums::SkinParts skinPart; + QS60StylePrivate::SkinElements skinElement; + if (!isDisabled) { + const bool isPressed = (option->state & QStyle::State_Sunken) || + (option->state & QStyle::State_On); + if (isFlat) { + skinPart = + isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter; + } else { + skinElement = + isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; + } } else { - const QS60StylePrivate::SkinElements skinElement = - isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; + if (isFlat) + skinPart =QS60StyleEnums::SP_QsnFrButtonCenterInactive; + else + skinElement = QS60StylePrivate::SE_ButtonInactive; + } + if (isFlat) + QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); + else QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); } - } break; case CE_PushButtonLabel: if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { QStyleOptionButton optionButton = *button; - - if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) { - if (buttonWidget->isCheckable()) { - // space for check box. - optionButton.rect.adjust(pixelMetric(PM_IndicatorWidth) - + pixelMetric(PM_ButtonMargin) + pixelMetric(PM_CheckBoxLabelSpacing), 0, 0, 0); - } - } QCommonStyle::drawControl(element, &optionButton, painter, widget); } break; @@ -1229,13 +1188,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, case CE_ToolButtonLabel: if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { QStyleOptionToolButton optionToolButton = *toolBtn; - - if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken) + + if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken) && (optionToolButton.state & State_Enabled)) { - + const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off; const QPixmap pm(optionToolButton.icon.pixmap(optionToolButton.rect.size().boundedTo(optionToolButton.iconSize), - QIcon::Normal, state)); + QIcon::Normal, state)); optionToolButton.icon = generatedIconPixmap(QIcon::Selected, pm, &optionToolButton); } @@ -1320,21 +1279,24 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); - // draw the background - const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option); - const QTableView *table = qobject_cast<const QTableView *>(widget); - if (table && tableOption) { - const QModelIndex index = tableOption->index; - //todo: Draw cell background only once - for the first cell. - QStyleOptionViewItemV4 voptAdj2 = voptAdj2; - const QModelIndex indexFirst = table->model()->index(0,0); - const QModelIndex indexLast = table->model()->index( - table->model()->rowCount()-1,table->model()->columnCount()-1); - if (table->viewport()) - voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(), - table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect()); - drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget); - } + // draw themed background for table unless background brush has been defined. + if (vopt->backgroundBrush == Qt::NoBrush) { + // draw the background + const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option); + const QTableView *table = qobject_cast<const QTableView *>(widget); + if (table && tableOption) { + const QModelIndex index = tableOption->index; + //todo: Draw cell background only once - for the first cell. + QStyleOptionViewItemV4 voptAdj2 = voptAdj2; + const QModelIndex indexFirst = table->model()->index(0,0); + const QModelIndex indexLast = table->model()->index( + table->model()->rowCount()-1,table->model()->columnCount()-1); + if (table->viewport()) + voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(), + table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect()); + drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget); + } + } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);} // draw the focus rect if (isSelected) @@ -1444,7 +1406,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const int tabOverlap = QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap) - borderThickness; //todo: draw navi wipe behind tabbar - must be drawn with first draw - //QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, windowRect, flags); if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| @@ -1721,7 +1682,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, break; #endif //QT_NO_MENU - //todo: remove non-used widgets in final version case CE_MenuEmptyArea: #ifndef QT_NO_MENUBAR case CE_MenuBarEmptyArea: @@ -1830,6 +1790,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, break; #endif //QT_NO_TOOLBAR + //todo: remove non-used widgets in final version case CE_ShapedFrame: case CE_MenuVMargin: case CE_MenuHMargin: @@ -1919,8 +1880,12 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); // ... or normal "tick" selection at the end. } else if (option->state & QStyle::State_Selected) { + QRect tickRect = option->rect; + const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); + // adjust tickmark rect to exclude frame border + tickRect.adjust(0,-frameBorderWidth,0,-frameBorderWidth); QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; - QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, + QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, (flags | QS60StylePrivate::SF_ColorSkinned)); } } @@ -1964,70 +1929,43 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_IndicatorArrowRight: case PE_IndicatorArrowUp: { - if (option->rect.width() <= 1 || option->rect.height() <= 1) - break; - QRect r = option->rect; - int size = qMin(r.height(), r.width()); - int border = size/5; - int sqsize = 2*(size>>1); - QImage image(sqsize, sqsize, QImage::Format_ARGB32); - image.fill(Qt::transparent); - QPainter imagePainter(&image); - - QPolygon a; - int halfsqsize = sqsize>>1; - int borderlessSqSize = sqsize - border; - switch (element) { - case PE_IndicatorArrowUp: - a.setPoints(3, border, halfsqsize, halfsqsize, border, borderlessSqSize, halfsqsize); - break; - case PE_IndicatorArrowDown: - a.setPoints(3, border, halfsqsize, halfsqsize, borderlessSqSize, borderlessSqSize, halfsqsize); - break; - case PE_IndicatorArrowRight: - a.setPoints(3, borderlessSqSize, halfsqsize, halfsqsize, border, halfsqsize, borderlessSqSize); - break; - case PE_IndicatorArrowLeft: - a.setPoints(3, border, halfsqsize, halfsqsize, border, halfsqsize, borderlessSqSize); - break; - default: - break; - } - - int bsx = 0; - int bsy = 0; - - if (option->state & State_Sunken) { - bsx = pixelMetric(PM_ButtonShiftHorizontal); - bsy = pixelMetric(PM_ButtonShiftVertical); - } - - QRect bounds = a.boundingRect(); - int sx = halfsqsize - bounds.center().x() - 1; - int sy = halfsqsize - bounds.center().y() - 1; - QPalette themeColor = option->palette; - imagePainter.translate(sx + bsx, sy + bsy); - imagePainter.setPen(themeColor.buttonText().color()); - - if (!(option->state & State_Enabled)) { - imagePainter.translate(1, 1); - imagePainter.setPen(themeColor.light().color()); - imagePainter.drawPolygon(a); - imagePainter.translate(-1, -1); - imagePainter.setPen(themeColor.mid().color()); - } - imagePainter.drawPolygon(a); - imagePainter.end(); - int xOffset = r.x() + ((r.width() - size)>>1); - int yOffset = r.y() + ((r.height() - size)>>1); - - painter->drawImage(xOffset, yOffset, image); + QS60StyleEnums::SkinParts skinPart; + if (element==PE_IndicatorArrowDown) + skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowDown; + else if (element==PE_IndicatorArrowLeft) + skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowLeft; + else if (element==PE_IndicatorArrowRight) + skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowRight; + else if (element==PE_IndicatorArrowUp) + skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowUp; + + QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); } break; #endif //QT_NO_TOOLBUTTON #ifndef QT_NO_SPINBOX case PE_IndicatorSpinDown: case PE_IndicatorSpinUp: + if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { + QStyleOptionSpinBox optionSpinBox = *spinBox; + const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? + QS60StyleEnums::SP_QgnGrafScrollArrowUp : + QS60StyleEnums::SP_QgnGrafScrollArrowDown; + const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6; + optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); + QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags); + } +#ifndef QT_NO_COMBOBOX + else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { + // We want to draw down arrow here for comboboxes as well. + const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; + QStyleOptionFrame comboBox = *cmb; + const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6; + comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); + QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags); + } +#endif //QT_NO_COMBOBOX + break; case PE_IndicatorSpinMinus: case PE_IndicatorSpinPlus: if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { @@ -2075,7 +2013,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti } break; case PE_Widget: - if (QS60StylePrivate::isSkinnableDialog(widget) || + if (QS60StylePrivate::drawsOwnThemeBackground(widget) || qobject_cast<const QComboBoxListView *>(widget) || qobject_cast<const QMenu *> (widget)) { QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu; @@ -2170,30 +2108,27 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti drawSkinPart = true; } - if ( drawSkinPart ) { - QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, - (flags | QS60StylePrivate::SF_ColorSkinned)); - } - + if ( drawSkinPart ) + QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); + if (option->state & State_Children) { - QS60StyleEnums::SkinParts skinPart = - (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; + QS60StyleEnums::SkinParts skinPart = + (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; int minDimension = qMin(option->rect.width(), option->rect.height()); const int resizeValue = minDimension >> 1; minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); int verticalMagic(0); // magic values for positioning svg icon. - if (option->rect.width() <= option->rect.height()) - verticalMagic = 3; + if (option->rect.width() <= option->rect.height()) + verticalMagic = 3; iconRect.translate(3, verticalMagic - resizeValue); - iconRect.adjust(-3,5,0,0); - QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); - } + QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); + } + } } - } - break; - + break; + // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases case PE_FrameLineEdit: case PE_IndicatorButtonDropDown: @@ -2261,7 +2196,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, case CT_PushButton: sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) - if (buttonWidget->isCheckable()) + if (buttonWidget->isCheckable()) sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); break; case CT_LineEdit: @@ -2305,6 +2240,8 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_ComboBox_PopupFrameStyle: retValue = QFrame::NoFrame; break; + case SH_Dial_BackgroundRole: + retValue = QPalette::Base; default: break; } @@ -2388,10 +2325,8 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; - const int buttonMargin = 2; //spinbox->frame ? /*QS60StylePrivate::pixelMetric(QStyle::PM_ButtonMargin)*/2 : 0; - const int buttonWidth = - QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2*buttonMargin; - //todo: buttonMargin commented out as WAY too big in pixel metrics + const int buttonMargin = spinbox->frame ? 2 : 0; + const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2*buttonMargin; QSize buttonSize; buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); buttonSize.setWidth(buttonWidth); @@ -2439,8 +2374,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple ret = cmb->rect; const int width = cmb->rect.width(); const int height = cmb->rect.height(); - //todo: buttonMargin commented out as WAY too big in pixel metrics - const int buttonMargin = cmb->frame ? /*QS60StylePrivate::pixelMetric(QStyle::PM_ButtonMargin)*/2 : 0; + const int buttonMargin = cmb->frame ? 2 : 0; // lets use spinbox frame here as well, as no combobox specific value available. const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize); @@ -2478,7 +2412,6 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple //slightly indent text and boxes, so that dialog border does not mess with them. const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); - const int bottomMargin = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutBottomMargin); ret.adjust(2,horizontalSpacing-3,0,0); break; case SC_GroupBoxFrame: { @@ -2509,7 +2442,6 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con case SE_LineEditContents: { // in S60 the input text box doesn't start from line Edit's TL, but // a bit indented. - // todo: Should we NOT do this for combo boxes and spin boxes? QRect lineEditRect = opt->rect; int adjustment = opt->rect.height()>>2; lineEditRect.adjust(adjustment,0,0,0); @@ -2583,13 +2515,10 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con } } else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; - const bool subMenu = menuItem->menuItemType == QStyleOptionMenuItem::SubMenu; int indicatorWidth = checkable ? pixelMetric(PM_ListViewIconSize, opt, widget) : pixelMetric(PM_SmallIconSize, opt, widget); ret = menuItem->rect; - const int verticalSpacing = - QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); if (element == SE_ItemViewItemDecoration) { if (menuItem->direction == Qt::RightToLeft) @@ -2673,6 +2602,87 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con return ret; } +void QS60Style::polish(QWidget *widget) +{ + Q_D(const QS60Style); + QCommonStyle::polish(widget); + + if (!widget) + return; + + if (false +#ifndef QT_NO_SCROLLBAR + || qobject_cast<QScrollBar *>(widget) +#endif + ) { + widget->setAttribute(Qt::WA_OpaquePaintEvent, false); + } + + if (QS60StylePrivate::drawsOwnThemeBackground(widget)) { + widget->setAttribute(Qt::WA_StyledBackground); + } else if (false +#ifndef QT_NO_MENU + || qobject_cast<const QMenu *> (widget) +#endif // QT_NO_MENU + ) { + widget->setAttribute(Qt::WA_StyledBackground); + } else if (false +#ifndef QT_NO_COMBOBOX + || qobject_cast<const QComboBoxListView *>(widget) +#endif //QT_NO_COMBOBOX + ) { + widget->setAttribute(Qt::WA_StyledBackground); + } + d->setThemePalette(widget); +} + +void QS60Style::unpolish(QWidget *widget) +{ + if (false + #ifndef QT_NO_SCROLLBAR + || qobject_cast<QScrollBar *>(widget) + #endif + ) { + widget->setAttribute(Qt::WA_OpaquePaintEvent); + } + + if (QS60StylePrivate::drawsOwnThemeBackground(widget)) { + widget->setAttribute(Qt::WA_StyledBackground, false); + } else if (false +#ifndef QT_NO_MENU + || qobject_cast<const QMenu *> (widget) +#endif // QT_NO_MENU + ) { + widget->setAttribute(Qt::WA_StyledBackground, false); + } else if (false +#ifndef QT_NO_COMBOBOX + || qobject_cast<const QComboBoxListView *>(widget) +#endif //QT_NO_COMBOBOX + ) { + widget->setAttribute(Qt::WA_StyledBackground, false); + } + + if (widget) { + widget->setPalette(QPalette()); + } + + QCommonStyle::unpolish(widget); +} + +void QS60Style::polish(QApplication *application) +{ + Q_D(const QS60Style); + originalPalette = application->palette(); + d->setThemePalette(application); +} + +void QS60Style::unpolish(QApplication *application) +{ + QPalette newPalette = qApp->style()->standardPalette(); + application->setPalette(newPalette); + QApplicationPrivate::setSystemPalette(originalPalette); +} + void QS60Style::setStyleProperty(const char *name, const QVariant &value) { Q_D(QS60Style); diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index e0b3a2a..ba7dca3 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -79,6 +79,10 @@ public: SP_QgnGrafBarFrameSideL, SP_QgnGrafBarFrameSideR, SP_QgnGrafBarProgress, + SP_QgnGrafScrollArrowDown, + SP_QgnGrafScrollArrowLeft, + SP_QgnGrafScrollArrowRight, + SP_QgnGrafScrollArrowUp, SP_QgnGrafTabActiveL, SP_QgnGrafTabActiveM, SP_QgnGrafTabActiveR, @@ -109,7 +113,7 @@ public: SP_QgnPropFolderCurrent, SP_QgnPropFolderSmall, SP_QgnPropFolderSmallNew, - SP_QgnPropPhoneMemcLarge, + SP_QgnPropPhoneMemcLarge, SP_QsnCpScrollHandleBottomPressed, //ScrollBar handle, pressed state SP_QsnCpScrollHandleMiddlePressed, SP_QsnCpScrollHandleTopPressed, @@ -227,7 +231,16 @@ public: SP_QsnFrSctrlButtonSideBPressed, SP_QsnFrSctrlButtonSideLPressed, SP_QsnFrSctrlButtonSideRPressed, - SP_QsnFrSctrlButtonCenterPressed + SP_QsnFrSctrlButtonCenterPressed, + SP_QsnFrButtonCornerTlInactive, // Inactive button + SP_QsnFrButtonCornerTrInactive, + SP_QsnFrButtonCornerBlInactive, + SP_QsnFrButtonCornerBrInactive, + SP_QsnFrButtonSideTInactive, + SP_QsnFrButtonSideBInactive, + SP_QsnFrButtonSideLInactive, + SP_QsnFrButtonSideRInactive, + SP_QsnFrButtonCenterInactive }; enum ColorLists { @@ -288,6 +301,7 @@ public: SE_PanelBackground, SE_ScrollBarHandlePressedHorizontal, //only for 5.0+ SE_ScrollBarHandlePressedVertical, + SE_ButtonInactive, }; enum SkinFrameElements { @@ -303,7 +317,8 @@ public: SF_ToolBar, SF_ToolBarButton, SF_ToolBarButtonPressed, - SF_PanelBackground + SF_PanelBackground, + SF_ButtonInactive, }; enum SkinElementFlag { @@ -316,6 +331,13 @@ public: SF_StateDisabled = 0x0020, SF_ColorSkinned = 0x0040, }; + + enum CacheClearReason { + CC_UndefinedChange = 0, + CC_LayoutChange, + CC_ThemeChange + }; + Q_DECLARE_FLAGS(SkinElementFlags, SkinElementFlag) // draws skin element @@ -340,14 +362,18 @@ public: int index, const QStyleOption *option); // gets state specific color static QColor stateColor(const QColor &color, const QStyleOption *option); + // gets lighter color than base color static QColor lighterColor(const QColor &baseColor); - static bool isSkinnableDialog(const QWidget *widget); + //deduces if the given widget should have separately themeable background + static bool drawsOwnThemeBackground(const QWidget *widget); // gets layout static const QHash<QStyle::PixelMetric, int> &s60StyleLayout(); QFont s60Font(QS60StyleEnums::FontCategories fontCategory, int pointSize = -1) const; - void clearCaches(); + // clears all style caches (fonts, colors, pixmaps) + void clearCaches(CacheClearReason reason = CC_UndefinedChange); + // returns themed background texture static QPixmap backgroundTexture(); static bool isTouchSupported(); @@ -356,6 +382,7 @@ public: // calculates average color based on button skin graphics (minus borders). QColor colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const; void setThemePalette(QApplication *application) const; + void setThemePalette(QWidget *widget) const; void setBackgroundTexture(QApplication *application) const; static int focusRectPenWidth(); @@ -393,19 +420,20 @@ private: static void drawFrame(SkinFrameElements frame, QPainter *painter, const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags); - static QSize partSize(QS60StyleEnums::SkinParts part, - SkinElementFlags flags = KDefaultSkinElementFlags); - static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size, - SkinElementFlags flags = KDefaultSkinElementFlags); static QPixmap cachedPart(QS60StyleEnums::SkinParts part, const QSize &size, SkinElementFlags flags = KDefaultSkinElementFlags); static QPixmap cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags = KDefaultSkinElementFlags); + + static void refreshUI(); + + static QSize partSize(QS60StyleEnums::SkinParts part, + SkinElementFlags flags = KDefaultSkinElementFlags); + static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size, + SkinElementFlags flags = KDefaultSkinElementFlags); static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize); - static void refreshUI(); - static QSize screenSize(); static bool m_backgroundValid; diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 17c1ebe..65336ae 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -191,6 +191,26 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const return styleProperty(name); } +QPixmap QS60StylePrivate::backgroundTexture() +{ + static QPixmap result; + // Poor mans caching. + Making sure that there is always only one background image in memory at a time + +/* + TODO: 1) Hold the background QPixmap as pointer in a static class member. + Also add a deleteBackground() function and call that in ~QS60StylePrivate() + 2) Don't cache the background at all as soon as we have native pixmap support +*/ + + if (!m_backgroundValid) { + result = QPixmap(); + const QSize size = QApplication::activeWindow()?QApplication::activeWindow()->size():QSize(100, 100); + result = part(QS60StyleEnums::SP_QsnBgScreen, size); + m_backgroundValid = true; + } + return result; +} + bool QS60StylePrivate::isTouchSupported() { #ifdef QT_KEYPAD_NAVIGATION @@ -266,8 +286,10 @@ QStringList QS60Style::colorListKeys() void QS60Style::setS60Theme(const QHash<QString, QPicture> &parts, const QHash<QPair<QString , int>, QColor> &colors) { + Q_D(QS60Style); QS60StyleModeSpecifics::m_partPictures = parts; QS60StyleModeSpecifics::m_colors = colors; + d->clearCaches(QS60StylePrivate::CC_ThemeChange); } QT_END_NAMESPACE diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_symbian.cpp index 199e7ff..3fc4c8c 100644 --- a/src/gui/styles/qs60style_symbian.cpp +++ b/src/gui/styles/qs60style_symbian.cpp @@ -80,6 +80,8 @@ public: const QSize &size, QS60StylePrivate::SkinElementFlags flags); static QColor colorValue(const TAknsItemID &colorGroup, int colorIndex); static QPixmap fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format); + static bool disabledPartGraphic(QS60StyleEnums::SkinParts &part); + static bool disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame); static QPixmap generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags); private: @@ -108,6 +110,10 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafScrollArrowUp */ {KAknsIIDQgnGrafScrollArrowUp, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafTabActiveL */ {KAknsIIDQgnGrafTabActiveL, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafTabActiveM */ {KAknsIIDQgnGrafTabActiveM, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafTabActiveR */ {KAknsIIDQgnGrafTabActiveR, EDrawIcon, ES60_AllReleases, -1,-1}, @@ -157,7 +163,7 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QsnCpScrollHandleMiddle */ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QsnCpScrollHandleTop */ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, + /* SP_QsnFrButtonTbCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, //todo: use "normal button" from 5.0 onwards /* SP_QsnFrButtonTbCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, /* SP_QsnFrButtonTbCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, /* SP_QsnFrButtonTbCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, @@ -271,15 +277,27 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QsnFrSctrlButtonCenter */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2309}, /*KAknsIIDQgnFrSctrlButtonCenter*/ // No pressed state for toolbar button in 3.1/3.2. - /* SP_QsnFrSctrlButtonCornerTlPressed */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2621}, /*KAknsIIDQsnFrSctrlButtonCornerTlPressed*/ - /* SP_QsnFrSctrlButtonCornerTrPressed */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2622}, - /* SP_QsnFrSctrlButtonCornerBlPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2623}, - /* SP_QsnFrSctrlButtonCornerBrPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2624}, - /* SP_QsnFrSctrlButtonSideTPressed */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2625}, - /* SP_QsnFrSctrlButtonSideBPressed */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2626}, - /* SP_QsnFrSctrlButtonSideLPressed */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2627}, - /* SP_QsnFrSctrlButtonSideRPressed */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2628}, - /* SP_QsnFrSctrlButtonCenterPressed */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2629} + /* SP_QsnFrSctrlButtonCornerTlPressed */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2621}, /*KAknsIIDQsnFrSctrlButtonCornerTlPressed*/ + /* SP_QsnFrSctrlButtonCornerTrPressed */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2622}, + /* SP_QsnFrSctrlButtonCornerBlPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2623}, + /* SP_QsnFrSctrlButtonCornerBrPressed */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2624}, + /* SP_QsnFrSctrlButtonSideTPressed */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2625}, + /* SP_QsnFrSctrlButtonSideBPressed */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2626}, + /* SP_QsnFrSctrlButtonSideLPressed */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2627}, + /* SP_QsnFrSctrlButtonSideRPressed */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2628}, + /* SP_QsnFrSctrlButtonCenterPressed */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2629}, + + // No inactive button graphics in 3.1/3.2 + /* SP_QsnFrButtonCornerTlInactive */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b1}, /*KAknsIIDQsnFrButtonCornerTlInactive*/ + /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b2}, + /* SP_QsnFrButtonCornerBlInactive */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b3}, + /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b4}, + /* SP_QsnFrButtonSideTInactive */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b5}, + /* SP_QsnFrButtonSideBInactive */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b6}, + /* SP_QsnFrButtonSideLInactive */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b7}, + /* SP_QsnFrButtonSideRInactive */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b8}, + /* SP_QsnFrButtonCenterInactive */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon,ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b9} + }; QPixmap QS60StyleModeSpecifics::skinnedGraphics( @@ -319,7 +337,7 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics( } void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex) -{ +{ switch(stylepart) { case QS60StyleEnums::SP_QgnGrafBarWait: fallbackFileName = KAvkonBitmapFile(); @@ -373,19 +391,19 @@ void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &style fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_checkbox_on; break; - case QS60StyleEnums::SP_QgnIndiHlColSuper: + case QS60StyleEnums::SP_QgnIndiHlColSuper: fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x4456; /* EMbmAvkonQgn_indi_hl_col_super */ break; - case QS60StyleEnums::SP_QgnIndiHlExpSuper: + case QS60StyleEnums::SP_QgnIndiHlExpSuper: fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x4458; /* EMbmAvkonQgn_indi_hl_exp_super */ break; - case QS60StyleEnums::SP_QgnIndiHlLineBranch: + case QS60StyleEnums::SP_QgnIndiHlLineBranch: fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x445A; /* EMbmAvkonQgn_indi_hl_line_branch */ break; - case QS60StyleEnums::SP_QgnIndiHlLineEnd: + case QS60StyleEnums::SP_QgnIndiHlLineEnd: fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x445C; /* EMbmAvkonQgn_indi_hl_line_end */ break; @@ -482,8 +500,8 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsL( TInt fallbackGraphicID = -1; HBufC* iconFile = HBufC::NewLC( KMaxFileName ); TPtr fileNamePtr = iconFile->Des(); - fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID); - + fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID); + TAknsItemID colorGroup = KAknsIIDQsnIconColors; int colorIndex = 0; colorGroupAndIndex(stylepart, colorGroup, colorIndex); @@ -649,6 +667,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL( HBufC* iconFile = HBufC::NewLC( KMaxFileName ); TPtr fileNamePtr = iconFile->Des(); fallbackInfo(part, fileNamePtr, fallbackGraphicID); + // todo: could we instead use AknIconUtils::AvkonIconFileName(); to avoid allocating each time? CFbsBitmap *icon = 0; CFbsBitmap *iconMask = 0; @@ -670,7 +689,6 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL( CleanupStack::PushL(background); User::LeaveIfError(background->Create(targetSize, EColor16MA)); - // todo: push background into CleanupStack CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(background); CleanupStack::PushL(dev); CFbsBitGc* gc = NULL; @@ -803,7 +821,7 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme switch(frameElement) { case QS60StylePrivate::SF_ToolTip: - if (QSysInfo::s60Version()==QSysInfo::SV_S60_5_0 || QSysInfo::s60Version()==QSysInfo::SV_S60_3_2) { + if (QSysInfo::s60Version()!=QSysInfo::SV_S60_3_1) { centerId.Set(EAknsMajorGeneric, 0x19c2); frameId.Set(EAknsMajorSkin, 0x5300); } else { @@ -831,17 +849,19 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect) { - TInt widthShrink = 0; - TInt heightShrink = 0; + TInt widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); + TInt heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight); switch(frameElement) { case QS60StylePrivate::SF_PanelBackground: // panel should have slightly slimmer border to enable thin line of background graphics between closest component - widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)-2; - heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight)-2; + widthShrink = widthShrink-2; + heightShrink = heightShrink-2; + break; + case QS60StylePrivate::SF_ToolTip: + widthShrink = widthShrink>>1; + heightShrink = heightShrink>>1; break; default: - widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); - heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight); break; } TRect innerRect(outerRect); @@ -942,9 +962,8 @@ QFont QS60StylePrivate::s60Font_specific( #ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED void QS60StylePrivate::setActiveLayout() { - //todo: how to find layouts that are of same size (QVGA1 vs. QVGA2) const QSize activeScreenSize(screenSize()); - int activeLayoutIndex = 0; + int activeLayoutIndex = -1; const bool mirrored = !QApplication::isLeftToRight(); const short screenHeight = (short)activeScreenSize.height(); const short screenWidth = (short)activeScreenSize.width(); @@ -956,6 +975,28 @@ void QS60StylePrivate::setActiveLayout() break; } } + + //not found, lets try without mirroring info + if (activeLayoutIndex==-1){ + for (int i=0; i<m_numberOfLayouts; i++) { + if (screenHeight==m_layoutHeaders[i].height && + screenWidth==m_layoutHeaders[i].width) { + activeLayoutIndex = i; + break; + } + } + } + + //not found, lets try with either of dimensions + if (activeLayoutIndex==-1){ + const QSysInfo::S60Version currentRelease = QSysInfo::s60Version(); + const bool landscape = screenHeight < screenWidth; + + activeLayoutIndex = (currentRelease == QSysInfo::SV_S60_3_1 || currentRelease == QSysInfo::SV_S60_3_2) ? 0 : 4; + activeLayoutIndex += (!landscape) ? 2 : 0; + activeLayoutIndex += (!mirrored) ? 1 : 0; + } + m_pmPointer = data[activeLayoutIndex]; } #endif // QT_S60STYLE_LAYOUTDATA_SIMULATED @@ -973,6 +1014,23 @@ QS60StylePrivate::~QS60StylePrivate() m_backgroundValid = false; } +void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value) +{ + if (name == QLatin1String("foo")) { + // BaR + } else { + setStyleProperty(name, value); + } +} + +QVariant QS60StylePrivate::styleProperty_specific(const char *name) const +{ + if (name == QLatin1String("foo")) + return QLatin1String("Bar"); + else + return styleProperty(name); +} + short QS60StylePrivate::pixelMetric(int metric) { #ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED @@ -987,6 +1045,66 @@ short QS60StylePrivate::pixelMetric(int metric) #endif // QT_S60STYLE_LAYOUTDATA_SIMULATED } +QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, + int index, const QStyleOption *option) +{ + static const TAknsItemID *idMap[] = { + &KAknsIIDQsnHighlightColors, + &KAknsIIDQsnIconColors, + &KAknsIIDQsnLineColors, + &KAknsIIDQsnOtherColors, + &KAknsIIDQsnParentColors, + &KAknsIIDQsnTextColors + }; + Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0])); + const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1); + return option ? QS60StylePrivate::stateColor(color, option) : color; +} + +// In some cases, the AVKON UI themegraphic is already in 'disabled state'. +// If so, return true for these parts. +bool QS60StyleModeSpecifics::disabledPartGraphic(QS60StyleEnums::SkinParts &part) +{ + bool disabledGraphic = false; + switch(part){ + // inactive button graphics are available from 5.0 onwards + case QS60StyleEnums::SP_QsnFrButtonCornerTlInactive: + case QS60StyleEnums::SP_QsnFrButtonCornerTrInactive: + case QS60StyleEnums::SP_QsnFrButtonCornerBlInactive: + case QS60StyleEnums::SP_QsnFrButtonCornerBrInactive: + case QS60StyleEnums::SP_QsnFrButtonSideTInactive: + case QS60StyleEnums::SP_QsnFrButtonSideBInactive: + case QS60StyleEnums::SP_QsnFrButtonSideLInactive: + case QS60StyleEnums::SP_QsnFrButtonSideRInactive: + case QS60StyleEnums::SP_QsnFrButtonCenterInactive: + if (!(QSysInfo::s60Version()==QSysInfo::SV_S60_3_1 || + QSysInfo::s60Version()==QSysInfo::SV_S60_3_2)) + disabledGraphic = true; + break; + default: + break; + } + return disabledGraphic; +} + +// In some cases, the AVKON UI themegraphic is already in 'disabled state'. +// If so, return true for these frames. +bool QS60StyleModeSpecifics::disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame) +{ + bool disabledGraphic = false; + switch(frame){ + // inactive button graphics are available from 5.0 onwards + case QS60StylePrivate::SF_ButtonInactive: + if (!(QSysInfo::s60Version()==QSysInfo::SV_S60_3_1 || + QSysInfo::s60Version()==QSysInfo::SV_S60_3_2)) + disabledGraphic = true; + break; + default: + break; + } + return disabledGraphic; +} + QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags) { @@ -998,8 +1116,8 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin // AVKON UI has a abnormal handling for scrollbar graphics. It is possible that the root // skin does not contain mandatory graphics for scrollbar pressed states. Therefore, AVKON UI // creates dynamically these graphics by modifying the normal state scrollbar graphics slightly. - // S60Style needs to work similarly. Therefore if skingraphics call provides to be a miss - // (i.e. result is not valid), style needs to draw normal graphics instead and apply some + // S60Style needs to work similarly. Therefore if skingraphics call provides to be a miss + // (i.e. result is not valid), style needs to draw normal graphics instead and apply some // modifications (similar to generatedIconPixmap()) to the result. case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: updatedPart = QS60StyleEnums::SP_QsnCpScrollHandleBottom; @@ -1019,8 +1137,8 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin QPixmap result = skinnedGraphics(updatedPart, size, flags); // TODO: fix this QStyleOption opt; - // opt.palette = q->standardPalette(); - + //opt.palette = q->standardPalette(); + // For now, always generate new icon based on "selected". In the future possibly, expand // this to consist other possibilities as well. result = QApplication::style()->generatedIconPixmap(QIcon::Selected, result, &opt); @@ -1037,7 +1155,7 @@ QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, : QS60StyleModeSpecifics::skinnedGraphics(part, size, flags); QS60WindowSurface::lockBitmapHeap(); - if (flags & SF_StateDisabled) { + if (flags & SF_StateDisabled && !QS60StyleModeSpecifics::disabledPartGraphic(part)) { // TODO: fix this QStyleOption opt; // opt.palette = q->standardPalette(); @@ -1046,7 +1164,7 @@ QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, if (!result) result = QS60StyleModeSpecifics::generateMissingThemeGraphic(part, size, flags); - + return result; } @@ -1056,7 +1174,7 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin QPixmap result = QS60StyleModeSpecifics::skinnedGraphics(frame, size, flags); QS60WindowSurface::lockBitmapHeap(); - if (flags & SF_StateDisabled) { + if (flags & SF_StateDisabled && !QS60StyleModeSpecifics::disabledFrameGraphic(frame)) { // TODO: fix this QStyleOption opt; // opt.palette = q->standardPalette(); @@ -1065,39 +1183,6 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin return result; } -void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value) -{ - if (name == QLatin1String("foo")) { - // BaR - } else { - setStyleProperty(name, value); - } -} - -QVariant QS60StylePrivate::styleProperty_specific(const char *name) const -{ - if (name == QLatin1String("foo")) - return QLatin1String("Bar"); - else - return styleProperty(name); -} - -QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, - int index, const QStyleOption *option) -{ - static const TAknsItemID *idMap[] = { - &KAknsIIDQsnHighlightColors, - &KAknsIIDQsnIconColors, - &KAknsIIDQsnLineColors, - &KAknsIIDQsnOtherColors, - &KAknsIIDQsnParentColors, - &KAknsIIDQsnTextColors - }; - Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0])); - const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1); - return option ? QS60StylePrivate::stateColor(color, option) : color; -} - // If the public SDK returns compressed images, please let us also uncompress those! void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap* aTrgBitmap, CFbsBitmap* aSrcBitmap) { @@ -1249,17 +1334,15 @@ void QS60StyleModeSpecifics::colorGroupAndIndex( { switch(skinID) { case QS60StyleEnums::SP_QgnIndiSubMenu: - case QS60StyleEnums::SP_QgnIndiHlColSuper: - case QS60StyleEnums::SP_QgnIndiHlExpSuper: - case QS60StyleEnums::SP_QgnIndiHlLineBranch: - case QS60StyleEnums::SP_QgnIndiHlLineEnd: - case QS60StyleEnums::SP_QgnIndiHlLineStraight: + colorGroup = KAknsIIDQsnIconColors; + colorIndex = EAknsCIQsnIconColorsCG1; + break; case QS60StyleEnums::SP_QgnIndiRadiobuttOff: case QS60StyleEnums::SP_QgnIndiRadiobuttOn: case QS60StyleEnums::SP_QgnIndiCheckboxOff: case QS60StyleEnums::SP_QgnIndiCheckboxOn: colorGroup = KAknsIIDQsnIconColors; - colorIndex = EAknsCIQsnIconColorsCG1; + colorIndex = EAknsCIQsnIconColorsCG14; break; default: break; @@ -1269,7 +1352,7 @@ void QS60StyleModeSpecifics::colorGroupAndIndex( void QS60Style::handleDynamicLayoutVariantSwitch() { Q_D(QS60Style); - d->clearCaches(); + d->clearCaches(QS60StylePrivate::CC_LayoutChange); #ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED d->setActiveLayout(); #endif // QT_S60STYLE_LAYOUTDATA_SIMULATED @@ -1282,11 +1365,12 @@ void QS60Style::handleDynamicLayoutVariantSwitch() void QS60Style::handleSkinChange() { Q_D(QS60Style); - d->clearCaches(); + d->clearCaches(QS60StylePrivate::CC_ThemeChange); d->setThemePalette(qApp); foreach (QWidget *topLevelWidget, QApplication::allWidgets()){ QEvent e(QEvent::StyleChange); QApplication::sendEvent(topLevelWidget, &e); + d->setThemePalette(topLevelWidget); topLevelWidget->ensurePolished(); } } diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 5a97086..0bd2d9a 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1162,13 +1162,20 @@ static bool setFontWeightFromValue(const Value &value, QFont *font) return true; } -static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font) +/** \internal + * parse the font family from the values (starting from index \a start) + * and set it the \a font + * \returns true if a family was extracted. + */ +static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font, int start = 0) { QString family; - for (int i = 0; i < values.count(); ++i) { + for (int i = start; i < values.count(); ++i) { const Value &v = values.at(i); - if (v.type == Value::TermOperatorComma) - break; + if (v.type == Value::TermOperatorComma) { + family += QLatin1Char(','); + continue; + } const QString str = v.variant.toString(); if (str.isEmpty()) break; @@ -1222,9 +1229,7 @@ static void parseShorthandFontProperty(const QVector<Value> &values, QFont *font } if (i < values.count()) { - QString fam = values.at(i).variant.toString(); - if (!fam.isEmpty()) - font->setFamily(fam); + setFontFamilyFromValues(values, font, i); } } diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 6ee1d03..4d316f6 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1911,6 +1911,20 @@ void QFont::insertSubstitutions(const QString &familyName, } } +/*! \fn void QFont::initialize() + \internal + + Internal function that initializes the font system. The font cache + and font dict do not alloc the keys. The key is a QString which is + shared between QFontPrivate and QXFontName. +*/ + +/*! \fn void QFont::cleanup() + \internal + + Internal function that cleans up the font system. +*/ + // ### mark: should be called removeSubstitutions() /*! Removes all the substitutions for \a familyName. diff --git a/src/gui/text/qfont_x11.cpp b/src/gui/text/qfont_x11.cpp index 710792c..6b0e46c 100644 --- a/src/gui/text/qfont_x11.cpp +++ b/src/gui/text/qfont_x11.cpp @@ -129,13 +129,6 @@ Q_GUI_EXPORT void qt_x11_set_fallback_font_family(int script, const QString &fam int QFontPrivate::defaultEncodingID = -1; -/*! - Internal function that initializes the font system. - - \internal - The font cache and font dict do not alloc the keys. The key is a QString - which is shared between QFontPrivate and QXFontName. -*/ void QFont::initialize() { extern int qt_encoding_id_for_mib(int mib); // from qfontdatabase_x11.cpp @@ -184,10 +177,6 @@ void QFont::initialize() QFontPrivate::defaultEncodingID = qt_encoding_id_for_mib(mib); } -/*! \internal - - Internal function that cleans up the font system. -*/ void QFont::cleanup() { QFontCache::cleanup(); diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index 15e626e..70e1599 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -494,7 +494,7 @@ static inline bool isFixedPitch(char **tokens) Fills in a font definition (QFontDef) from an XLFD (X Logical Font Description). - Returns true if the the given xlfd is valid. + Returns true if the given xlfd is valid. */ bool qt_fillFontDef(const QByteArray &xlfd, QFontDef *fd, int dpi, QtFontDesc *desc) { diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 7a236fd..6f5ee1f 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -613,7 +613,7 @@ QFontEngineFT::QFontEngineFT(const QFontDef &fd) subpixelType = Subpixel_None; lcdFilterType = 0; #if defined(FT_LCD_FILTER_H) - lcdFilterType = (int) FT_LCD_FILTER_DEFAULT; + lcdFilterType = (int)((quintptr) FT_LCD_FILTER_DEFAULT); #endif defaultFormat = Format_None; canUploadGlyphsToServer = false; diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 425cab2..d397e4a 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -553,7 +553,9 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph) 8, im.bytesPerLine(), colorspace, cgflags); CGContextSetFontSize(ctx, fontDef.pixelSize); - CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold && !(fontDef.styleStrategy & QFont::NoAntialias)); + CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold + && !(fontDef.styleStrategy & QFont::NoAntialias)); + CGContextSetShouldSmoothFonts(ctx, false); CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx); CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0); diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index 1996d44..bf3a176 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -1406,8 +1406,8 @@ QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin #endif #endif - QNativeImage *ni = new QNativeImage(iw + 2 * margin, - ih + 2 * margin, + QNativeImage *ni = new QNativeImage(iw + 2 * margin + 2, + ih + 2 * margin + 2, QNativeImage::systemFormat(), true); ni->image.fill(0xffffffff); @@ -1449,7 +1449,7 @@ QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform) font = CreateFontIndirectW(&lf); } - QNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform); + QNativeImage *mask = drawGDIGlyph(font, glyph, 2, xform); if (mask == 0) return QImage(); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 80a5425..d41d414 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1099,6 +1099,16 @@ void QTextEngine::shapeTextWithCE(int item) const } #endif +static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLayout &source, int num) +{ + if (num > 0 && destination.glyphs != source.glyphs) { + memmove(destination.glyphs, source.glyphs, num * sizeof(HB_Glyph)); + memmove(destination.attributes, source.attributes, num * sizeof(HB_GlyphAttributes)); + memmove(destination.advances_x, source.advances_x, num * sizeof(HB_Fixed)); + memmove(destination.offsets, source.offsets, num * sizeof(HB_FixedPoint)); + } +} + /// take the item from layoutData->items and void QTextEngine::shapeTextWithHarfbuzz(int item) const { @@ -1189,7 +1199,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const - int initial_glyph_pos = 0; + int remaining_glyphs = entire_shaper_item.num_glyphs; int glyph_pos = 0; // for each item shape using harfbuzz and store the results in our layoutData's glyphs array. for (int k = 0; k < itemBoundaries.size(); k += 2) { // for the +2, see the comment at the definition of itemBoundaries @@ -1209,7 +1219,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const QFontEngine *actualFontEngine = font; uint engineIdx = 0; if (font->type() == QFontEngine::Multi) { - engineIdx = uint(initialGlyphs.glyphs[itemBoundaries[k + 1]] >> 24); + engineIdx = uint(availableGlyphs(&si).glyphs[glyph_pos] >> 24); actualFontEngine = static_cast<QFontEngineMulti *>(font)->engine(engineIdx); } @@ -1219,16 +1229,18 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const shaper_item.glyphIndicesPresent = true; + remaining_glyphs -= shaper_item.initialGlyphCount; + do { - ensureSpace(glyph_pos + shaper_item.num_glyphs); - initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs); - shaper_item.num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used - glyph_pos; + ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs); - const QGlyphLayout g = availableGlyphs(&si); - shaper_item.glyphs = g.glyphs + glyph_pos; - shaper_item.attributes = g.attributes + glyph_pos; - shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x + glyph_pos); - shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets + glyph_pos); + const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos); + moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); + + shaper_item.glyphs = g.glyphs; + shaper_item.attributes = g.attributes; + shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x); + shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets); if (shaper_item.glyphIndicesPresent) { for (hb_uint32 i = 0; i < shaper_item.initialGlyphCount; ++i) @@ -1241,18 +1253,18 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const } while (!qShapeItem(&shaper_item)); // this does the actual shaping via harfbuzz. QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos, shaper_item.num_glyphs); + moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); - for (hb_uint32 i = 0; i < shaper_item.item.length; ++i) { + for (hb_uint32 i = 0; i < shaper_item.num_glyphs; ++i) g.glyphs[i] = g.glyphs[i] | (engineIdx << 24); + + for (hb_uint32 i = 0; i < shaper_item.item.length; ++i) shaper_item.log_clusters[i] += glyph_pos; - } if (kerningEnabled && !shaper_item.kerning_applied) font->doKerning(&g, option.useDesignMetrics() ? QFlag(QTextEngine::DesignMetrics) : QFlag(0)); glyph_pos += shaper_item.num_glyphs; - - initial_glyph_pos += shaper_item.initialGlyphCount; } // qDebug(" -> item: script=%d num_glyphs=%d", shaper_item.script, shaper_item.num_glyphs); diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index 21bfc4d..38ac4ca 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -1449,7 +1449,7 @@ void QTextCharFormat::setUnderlineStyle(UnderlineStyle style) /*! \since 4.5 \fn bool QTextCharFormat::fontKerning() const - Returns true if the the font kerning is enabled. + Returns true if the font kerning is enabled. \sa setFontKerning() \sa font() diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index ba1c04f..48708c9 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -525,7 +525,12 @@ void QTextTablePrivate::update() const Rows and columns within a QTextTable can be merged and split using the mergeCells() and splitCell() functions. However, only cells that span multiple rows or columns can be split. (Merging or splitting does not increase or decrease - the number of rows and columns.) + the number of rows and columns.) + + Note that if you have merged multiple columns and rows into one cell, you will not + be able to split the merged cell into new cells spanning over more than one row + or column. To be able to split cells spanning over several rows and columns you + need to do this over several iterations. \table 80% \row diff --git a/src/gui/util/qundostack.cpp b/src/gui/util/qundostack.cpp index 11f65e3..a6b9c23 100644 --- a/src/gui/util/qundostack.cpp +++ b/src/gui/util/qundostack.cpp @@ -715,7 +715,7 @@ int QUndoStack::index() const } /*! - Repeatedly calls undo() or redo() until the the current command index reaches + Repeatedly calls undo() or redo() until the current command index reaches \a idx. This function can be used to roll the state of the document forwards of backwards. indexChanged() is emitted only once. diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp index 92c12a5..4436c04 100644 --- a/src/gui/widgets/qcalendarwidget.cpp +++ b/src/gui/widgets/qcalendarwidget.cpp @@ -2791,7 +2791,7 @@ QTextCharFormat QCalendarWidget::dateTextFormat(const QDate &date) const void QCalendarWidget::setDateTextFormat(const QDate &date, const QTextCharFormat &format) { Q_D(QCalendarWidget); - if ( date.isNull() && !format.isValid() ) + if (date.isNull()) d->m_model->m_dateFormats.clear(); else d->m_model->m_dateFormats[date] = format; diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index e9884bb..16e2f39 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -948,7 +948,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer() container = new QComboBoxPrivateContainer(new QComboBoxListView(q), q); container->itemView()->setModel(model); container->itemView()->setTextElideMode(Qt::ElideMiddle); - updateDelegate(); + updateDelegate(true); updateLayoutDirection(); QObject::connect(container, SIGNAL(itemSelected(QModelIndex)), q, SLOT(_q_itemSelected(QModelIndex))); @@ -1568,15 +1568,25 @@ bool QComboBox::isEditable() const return d->lineEdit != 0; } -void QComboBoxPrivate::updateDelegate() +/*! \internal + update the default delegate + depending on the style's SH_ComboBox_Popup hint, we use a different default delegate. + + but we do not change the delegate is the combobox use a custom delegate, + unless \a force is set to true. + */ +void QComboBoxPrivate::updateDelegate(bool force) { Q_Q(QComboBox); QStyleOptionComboBox opt; q->initStyleOption(&opt); - if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) - q->setItemDelegate(new QComboMenuDelegate(q->view(), q)); - else - q->setItemDelegate(new QComboBoxDelegate(q->view(), q)); + if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) { + if (force || qobject_cast<QComboBoxDelegate *>(q->itemDelegate())) + q->setItemDelegate(new QComboMenuDelegate(q->view(), q)); + } else { + if (force || qobject_cast<QComboMenuDelegate *>(q->itemDelegate())) + q->setItemDelegate(new QComboBoxDelegate(q->view(), q)); + } } QIcon QComboBoxPrivate::itemIcon(const QModelIndex &index) const diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index c39a231..a55b439 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -256,7 +256,7 @@ private: }; class QComboMenuDelegate : public QAbstractItemDelegate -{ +{ Q_OBJECT public: QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {} @@ -285,7 +285,7 @@ private: // Vista does not use the new theme for combo boxes and there might // be other side effects from using the new class class QComboBoxDelegate : public QItemDelegate -{ +{ Q_OBJECT public: QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {} @@ -367,7 +367,7 @@ public: int itemRole() const; void updateLayoutDirection(); void setCurrentIndex(const QModelIndex &index); - void updateDelegate(); + void updateDelegate(bool force = false); void keyboardSearchString(const QString &text); void modelChanged(); diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp index 0136f1a..af80963 100644 --- a/src/gui/widgets/qlcdnumber.cpp +++ b/src/gui/widgets/qlcdnumber.cpp @@ -1271,7 +1271,7 @@ bool QLCDNumber::event(QEvent *e) /*! \fn int QLCDNumber::margin() const - Returns the with of the the margin around the contents of the widget. + Returns the width of the margin around the contents of the widget. Use QWidget::getContentsMargins() instead. \sa setMargin(), QWidget::getContentsMargins() diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 116d000..0d8e16f 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -3690,7 +3690,7 @@ void QLineEditPrivate::redo() { /*! \fn int QLineEdit::margin() const - Returns the with of the the margin around the contents of the widget. + Returns the width of the margin around the contents of the widget. Use QWidget::getContentsMargins() instead. \sa setMargin(), QWidget::getContentsMargins() diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 502c1e9..558ba42 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -1408,10 +1408,10 @@ bool QMainWindow::event(QEvent *event) This property is false by default and only has any effect on Mac OS X 10.4 or higher. - If set to true, then the top toolbar area is replaced with a Carbon - HIToolbar and all toolbars in the top toolbar area are moved to that. Any - toolbars added afterwards will also be added to the Carbon HIToolbar. This - means a couple of things. + If set to true, then the top toolbar area is replaced with a Carbon HIToolbar + or a Cocoa NSToolbar (depending on whether Qt was built with Carbon or Cocoa). + All toolbars in the top toolbar area and any toolbars added afterwards are + moved to that. This means a couple of things. \list \i QToolBars in this toolbar area are not movable and you cannot drag other diff --git a/src/gui/widgets/qmdiarea.cpp b/src/gui/widgets/qmdiarea.cpp index 598d3b5..6acd977 100644 --- a/src/gui/widgets/qmdiarea.cpp +++ b/src/gui/widgets/qmdiarea.cpp @@ -81,7 +81,7 @@ subwindows. This information could be used in a popup menu containing a list of windows, for example. - The subwindows are sorted by the the current + The subwindows are sorted by the current \l{QMdiArea::}{WindowOrder}. This is used for the subWindowList() and for activateNextSubWindow() and acivatePreviousSubWindow(). Also, it is used when cascading or tiling the windows with diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index d47749f..a45f12f 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -227,7 +227,7 @@ public: QString searchBuffer; QBasicTimer searchBufferTimer; - //passing of mouse events up the parent heirarchy + //passing of mouse events up the parent hierarchy QPointer<QMenu> activeMenu; bool mouseEventTaken(QMouseEvent *); diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index 847a623..42a4e0b 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -214,10 +214,12 @@ static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, i mbi.nToolBarId = toolbarID; if (ptrCreateMenuBar(&mbi)) { +#ifdef Q_OS_WINCE_WM // Tell the menu bar that we want to override hot key behaviour. LPARAM lparam = MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, SHMBOF_NODEFAULT | SHMBOF_NOTIFY); SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, lparam); +#endif return mbi.hwndMB; } } diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index d05323d..fb8a69b 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -2417,7 +2417,7 @@ int QMenuBar::findIdForAction(QAction *act) const /*! \fn int QMenuBar::margin() const - Returns the with of the the margin around the contents of the widget. + Returns the width of the margin around the contents of the widget. Use QWidget::getContentsMargins() instead. \sa setMargin(), QWidget::getContentsMargins() diff --git a/src/gui/widgets/qscrollarea.cpp b/src/gui/widgets/qscrollarea.cpp index 6aca7d3..8b01453 100644 --- a/src/gui/widgets/qscrollarea.cpp +++ b/src/gui/widgets/qscrollarea.cpp @@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE setting the layout's \l{QLayout::sizeConstraint}{size constraint} property to one which provides constraints on the minimum and/or maximum size of the layout (e.g., QLayout::SetMinAndMaxSize) will - cause the size of the the scroll area to be updated whenever the + cause the size of the scroll area to be updated whenever the contents of the layout changes. For a complete example using the QScrollArea class, see the \l diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp index bf8af35..45e838f 100644 --- a/src/gui/widgets/qsplitter.cpp +++ b/src/gui/widgets/qsplitter.cpp @@ -1517,7 +1517,7 @@ void QSplitter::setOpaqueResize(bool on) /*! \fn int QSplitter::margin() const - Returns the with of the the margin around the contents of the widget. + Returns the width of the margin around the contents of the widget. Use QWidget::getContentsMargins() instead. \sa setMargin(), QWidget::getContentsMargins() diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index c16e000..43b2f54 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -504,7 +504,7 @@ QIcon QTabWidget::tabIcon(int index) const } /*! - Returns true if the the page at position \a index is enabled; otherwise returns false. + Returns true if the page at position \a index is enabled; otherwise returns false. \sa setTabEnabled(), QWidget::isEnabled() */ diff --git a/src/gui/widgets/qtoolbox.cpp b/src/gui/widgets/qtoolbox.cpp index 81935a5..271130a 100644 --- a/src/gui/widgets/qtoolbox.cpp +++ b/src/gui/widgets/qtoolbox.cpp @@ -802,7 +802,7 @@ void QToolBox::itemRemoved(int index) /*! \fn int QToolBox::margin() const - Returns the with of the the margin around the contents of the widget. + Returns the width of the margin around the contents of the widget. Use QWidget::getContentsMargins() instead. \sa setMargin(), QWidget::getContentsMargins() diff --git a/src/network/access/qhttp.cpp b/src/network/access/qhttp.cpp index 96ccc91..30befb3 100644 --- a/src/network/access/qhttp.cpp +++ b/src/network/access/qhttp.cpp @@ -64,10 +64,10 @@ # include "qtimer.h" #endif -QT_BEGIN_NAMESPACE - #ifndef QT_NO_HTTP +QT_BEGIN_NAMESPACE + class QHttpNormalRequest; class QHttpRequest { @@ -950,7 +950,7 @@ void QHttpHeader::setContentLength(int len) } /*! - Returns true if the header has an entry for the the special HTTP + Returns true if the header has an entry for the special HTTP header field \c content-type; otherwise returns false. \sa contentType() setContentType() diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 5940fba..ae518df 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -529,10 +529,20 @@ void QHttpNetworkConnectionPrivate::receiveReply(QAbstractSocket *socket, QHttpN QHttpNetworkReplyPrivate::ReplyState state = reply ? reply->d_func()->state : QHttpNetworkReplyPrivate::AllDoneState; switch (state) { case QHttpNetworkReplyPrivate::NothingDoneState: - case QHttpNetworkReplyPrivate::ReadingStatusState: - bytes += reply->d_func()->readStatus(socket); + case QHttpNetworkReplyPrivate::ReadingStatusState: { + qint64 statusBytes = reply->d_func()->readStatus(socket); + if (statusBytes == -1) { + // error reading the status, close the socket and emit error + socket->close(); + reply->d_func()->errorString = errorDetail(QNetworkReply::ProtocolFailure, socket); + emit reply->finishedWithError(QNetworkReply::ProtocolFailure, reply->d_func()->errorString); + QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); + break; + } + bytes += statusBytes; channels[i].lastStatus = reply->d_func()->statusCode; break; + } case QHttpNetworkReplyPrivate::ReadingHeaderState: bytes += reply->d_func()->readHeader(socket); if (reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState) { @@ -633,10 +643,21 @@ void QHttpNetworkConnectionPrivate::handleStatus(QAbstractSocket *socket, QHttpN switch (statusCode) { case 401: case 407: - handleAuthenticateChallenge(socket, reply, (statusCode == 407), resend); - if (resend) { - eraseData(reply); - sendRequest(socket); + if (handleAuthenticateChallenge(socket, reply, (statusCode == 407), resend)) { + if (resend) { + eraseData(reply); + sendRequest(socket); + } + } else { + int i = indexOf(socket); + emit channels[i].reply->headerChanged(); + emit channels[i].reply->readyRead(); + QNetworkReply::NetworkError errorCode = (statusCode == 407) + ? QNetworkReply::ProxyAuthenticationRequiredError + : QNetworkReply::AuthenticationRequiredError; + reply->d_func()->errorString = errorDetail(errorCode, socket); + emit q->error(errorCode, reply->d_func()->errorString); + emit channels[i].reply->finished(); } break; default: @@ -739,7 +760,6 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket // authentication is cancelled, send the current contents to the user. emit channels[i].reply->headerChanged(); emit channels[i].reply->readyRead(); - emit channels[i].reply->finished(); QNetworkReply::NetworkError errorCode = isProxy ? QNetworkReply::ProxyAuthenticationRequiredError diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index fe3f6af..69e0a4c 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -409,39 +409,62 @@ qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket) if (fragment.endsWith('\r')) { fragment.truncate(fragment.length()-1); } - parseStatus(fragment); + bool ok = parseStatus(fragment); state = ReadingHeaderState; fragment.clear(); // next fragment + + if (!ok) + return -1; break; } else { c = 0; bytes += socket->read(&c, 1); fragment.append(c); } + + // is this a valid reply? + if (fragment.length() >= 5 && !fragment.startsWith("HTTP/")) + return -1; + } + return bytes; } -void QHttpNetworkReplyPrivate::parseStatus(const QByteArray &status) +bool QHttpNetworkReplyPrivate::parseStatus(const QByteArray &status) { - const QByteArrayMatcher sp(" "); - int i = sp.indexIn(status); - const QByteArray version = status.mid(0, i); - int j = sp.indexIn(status, i + 1); + // from RFC 2616: + // Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF + // HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT + // that makes: 'HTTP/n.n xxx Message' + // byte count: 0123456789012 + + static const int minLength = 11; + static const int dotPos = 6; + static const int spacePos = 8; + static const char httpMagic[] = "HTTP/"; + + if (status.length() < minLength + || !status.startsWith(httpMagic) + || status.at(dotPos) != '.' + || status.at(spacePos) != ' ') { + // I don't know how to parse this status line + return false; + } + + // optimize for the valid case: defer checking until the end + majorVersion = status.at(dotPos - 1) - '0'; + minorVersion = status.at(dotPos + 1) - '0'; + + int i = spacePos; + int j = status.indexOf(' ', i + 1); // j == -1 || at(j) == ' ' so j+1 == 0 && j+1 <= length() const QByteArray code = status.mid(i + 1, j - i - 1); - const QByteArray reason = status.mid(j + 1, status.count() - j); - const QByteArrayMatcher slash("/"); - int k = slash.indexIn(version); - const QByteArrayMatcher dot("."); - int l = dot.indexIn(version, k); - const QByteArray major = version.mid(k + 1, l - k - 1); - const QByteArray minor = version.mid(l + 1, version.count() - l); + bool ok; + statusCode = code.toInt(&ok); + reasonPhrase = QString::fromLatin1(status.constData() + j + 1); - majorVersion = QString::fromAscii(major.constData()).toInt(); - minorVersion = QString::fromAscii(minor.constData()).toInt(); - statusCode = QString::fromAscii(code.constData()).toInt(); - reasonPhrase = QString::fromAscii(reason.constData()); + return ok && uint(majorVersion) <= 9 && uint(minorVersion) <= 9; } qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket) @@ -660,4 +683,4 @@ void QHttpNetworkReply::ignoreSslErrors() QT_END_NAMESPACE -#endif // QT_NO_HTTP
\ No newline at end of file +#endif // QT_NO_HTTP diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index c17c65c..cb4d34f 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -154,7 +154,7 @@ public: QHttpNetworkReplyPrivate(const QUrl &newUrl = QUrl()); ~QHttpNetworkReplyPrivate(); qint64 readStatus(QAbstractSocket *socket); - void parseStatus(const QByteArray &status); + bool parseStatus(const QByteArray &status); qint64 readHeader(QAbstractSocket *socket); void parseHeader(const QByteArray &header); qint64 readBody(QAbstractSocket *socket, QIODevice *out); diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index a52b5a0..f214699 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -1036,21 +1036,39 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo if (it != cacheHeaders.rawHeaders.constEnd()) metaData.setLastModified(QNetworkHeadersPrivate::fromHttpDate(it->second)); - bool canDiskCache = true; // Everything defaults to being cacheable on disk - - // 14.32 - // HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client - // had sent "Cache-Control: no-cache". - it = cacheHeaders.findRawHeader("pragma"); - if (it != cacheHeaders.rawHeaders.constEnd() - && it->second == "no-cache") - canDiskCache = false; + bool canDiskCache; + // only cache GET replies by default, all other replies (POST, PUT, DELETE) + // are not cacheable by default (according to RFC 2616 section 9) + if (httpReply->request().operation() == QHttpNetworkRequest::Get) { + + canDiskCache = true; + // 14.32 + // HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client + // had sent "Cache-Control: no-cache". + it = cacheHeaders.findRawHeader("pragma"); + if (it != cacheHeaders.rawHeaders.constEnd() + && it->second == "no-cache") + canDiskCache = false; + + // HTTP/1.1. Check the Cache-Control header + if (cacheControl.contains("no-cache")) + canDiskCache = false; + else if (cacheControl.contains("no-store")) + canDiskCache = false; + + // responses to POST might be cacheable + } else if (httpReply->request().operation() == QHttpNetworkRequest::Post) { - // HTTP/1.1. Check the Cache-Control header - if (cacheControl.contains("no-cache")) canDiskCache = false; - else if (cacheControl.contains("no-store")) + // some pages contain "expires:" and "cache-control: no-cache" field, + // so we only might cache POST requests if we get "cache-control: max-age ..." + if (cacheControl.contains("max-age")) + canDiskCache = true; + + // responses to PUT and DELETE are not cacheable + } else { canDiskCache = false; + } metaData.setSaveToDisk(canDiskCache); int statusCode = httpReply->statusCode(); diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index 892929e..44a8298 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -494,21 +494,21 @@ qint64 QNetworkDiskCache::expire() QDir::Filters filters = QDir::AllDirs | QDir:: Files | QDir::NoDotAndDotDot; QDirIterator it(cacheDirectory(), filters, QDirIterator::Subdirectories); - QMap<QDateTime, QString> cacheItems; + QMultiMap<QDateTime, QString> cacheItems; qint64 totalSize = 0; while (it.hasNext()) { QString path = it.next(); QFileInfo info = it.fileInfo(); QString fileName = info.fileName(); if (fileName.endsWith(CACHE_POSTFIX) && fileName.startsWith(CACHE_PREFIX)) { - cacheItems[info.created()] = path; + cacheItems.insert(info.created(), path); totalSize += info.size(); } } int removedFiles = 0; qint64 goal = (maximumCacheSize() * 9) / 10; - QMap<QDateTime, QString>::const_iterator i = cacheItems.constBegin(); + QMultiMap<QDateTime, QString>::const_iterator i = cacheItems.constBegin(); while (i != cacheItems.constEnd()) { if (totalSize < goal) break; diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index c9161f8..33795aa 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -73,6 +73,15 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas authentication information to the socket when accessing services that require authentication. + QAuthenticator supports the following authentication methods: + \list + \o Basic + \o NTLM version 1 + \o Digest-MD5 + \endlist + + Note that, in particular, NTLM version 2 is not supported. + \sa QSslSocket */ diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index 0a34e2b..472bc4b 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -72,21 +72,6 @@ struct qt_addrinfo qt_addrinfo *ai_next; }; -// sockaddr_in6 size changed between old and new SDK -// Only the new version is the correct one, so always -// use this structure. -struct qt_in6_addr { - uchar qt_s6_addr[16]; -}; - -struct qt_sockaddr_in6 { - short sin6_family; /* AF_INET6 */ - u_short sin6_port; /* Transport level port number */ - u_long sin6_flowinfo; /* IPv6 flow information */ - struct qt_in6_addr sin6_addr; /* IPv6 address */ - u_long sin6_scope_id; /* set of interfaces for a scope */ -}; - //### #define QT_SOCKLEN_T int #ifndef NI_MAXHOST // already defined to 1025 in ws2tcpip.h? diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index a339388..ff3624e 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -397,7 +397,7 @@ QNetworkInterface::~QNetworkInterface() } /*! - Creates a copy of the the QNetworkInterface object contained in \a + Creates a copy of the QNetworkInterface object contained in \a other. */ QNetworkInterface::QNetworkInterface(const QNetworkInterface &other) diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 62bdfc7..fd3a85a 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -1258,6 +1258,6 @@ QList<QNetworkProxy> QNetworkProxyFactory::proxyForQuery(const QNetworkProxyQuer return globalNetworkProxy()->proxyForQuery(query); } -#endif // QT_NO_NETWORKPROXY - QT_END_NAMESPACE + +#endif // QT_NO_NETWORKPROXY diff --git a/src/network/kernel/qurlinfo.cpp b/src/network/kernel/qurlinfo.cpp index 255c9ea..d90c480 100644 --- a/src/network/kernel/qurlinfo.cpp +++ b/src/network/kernel/qurlinfo.cpp @@ -726,6 +726,6 @@ bool QUrlInfo::isValid() const return d != 0; } -#endif // QT_NO_URLINFO - QT_END_NAMESPACE + +#endif // QT_NO_URLINFO diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 8ae247c..768cafb 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -991,7 +991,6 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() // Wait for a write notification that will eventually call // _q_testConnection(). socketEngine->setWriteNotificationEnabled(true); - socketEngine->setExceptionNotificationEnabled(true); break; } while (state != QAbstractSocket::ConnectedState); } @@ -1052,7 +1051,6 @@ void QAbstractSocketPrivate::_q_abortConnectionAttempt() #endif if (socketEngine) { socketEngine->setWriteNotificationEnabled(false); - socketEngine->setExceptionNotificationEnabled(false); } connectTimer->stop(); @@ -1130,7 +1128,7 @@ bool QAbstractSocketPrivate::readFromSocket() /*! \internal - Sets up the the internal state after the connection has succeeded. + Sets up the internal state after the connection has succeeded. */ void QAbstractSocketPrivate::fetchConnectionParameters() { diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 540c443..5a2a746 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -768,6 +768,6 @@ QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(int, QObject return 0; } -#endif - QT_END_NAMESPACE + +#endif diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index d6b1507..35701a7 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -276,6 +276,10 @@ QLocalSocket *QLocalServer::nextPendingConnection() if (d->pendingConnections.isEmpty()) return 0; QLocalSocket *nextSocket = d->pendingConnections.dequeue(); +#ifdef Q_OS_SYMBIAN + if(!d->socketNotifier) + return nextSocket; +#endif #ifndef Q_OS_WIN d->socketNotifier->setEnabled(d->pendingConnections.size() <= d->maxPendingConnections); diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 2471043..9e3cbde 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -237,7 +237,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) QLatin1String("QLocalSocket::connectToServer")); return; } - +#ifndef Q_OS_SYMBIAN // set non blocking so we can try to connect and it wont wait int flags = fcntl(d->connectingSocket, F_GETFL, 0); if (-1 == flags @@ -246,6 +246,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) QLatin1String("QLocalSocket::connectToServer")); return; } +#endif // _q_connectToSocket does the actual connecting d->connectingName = name; diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 515ad84..95ffba5 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -55,9 +55,9 @@ #include "QtNetwork/qhostaddress.h" #include "private/qabstractsocketengine_p.h" #ifndef Q_OS_WIN -#include "qplatformdefs.h" +# include "qplatformdefs.h" #else -#include <Winsock2.h> // sockaddr_storage, sockaddr_in +# include <winsock2.h> #endif #ifdef Q_OS_SYMBIAN @@ -227,6 +227,39 @@ static inline int qt_socket_socket(int domain, int type, int protocol) #endif +// Use our own defines and structs which we know are correct +# define QT_SS_MAXSIZE 128 +# define QT_SS_ALIGNSIZE (sizeof(qint64)) +# define QT_SS_PAD1SIZE (QT_SS_ALIGNSIZE - sizeof (short)) +# define QT_SS_PAD2SIZE (QT_SS_MAXSIZE - (sizeof (short) + QT_SS_PAD1SIZE + QT_SS_ALIGNSIZE)) +struct qt_sockaddr_storage { + short ss_family; + char __ss_pad1[QT_SS_PAD1SIZE]; + qint64 __ss_align; + char __ss_pad2[QT_SS_PAD2SIZE]; +}; + +// sockaddr_in6 size changed between old and new SDK +// Only the new version is the correct one, so always +// use this structure. +struct qt_in6_addr { + quint8 qt_s6_addr[16]; +}; +struct qt_sockaddr_in6 { + short sin6_family; /* AF_INET6 */ + quint16 sin6_port; /* Transport level port number */ + quint32 sin6_flowinfo; /* IPv6 flow information */ + struct qt_in6_addr sin6_addr; /* IPv6 address */ + quint32 sin6_scope_id; /* set of interfaces for a scope */ +}; + +union qt_sockaddr { + sockaddr a; + sockaddr_in a4; + qt_sockaddr_in6 a6; + qt_sockaddr_storage storage; +}; + class QNativeSocketEnginePrivate; class Q_AUTOTEST_EXPORT QNativeSocketEngine : public QAbstractSocketEngine diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index a3f62db..5136978 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -122,36 +122,34 @@ static void qt_ignore_sigpipe() Extracts the port and address from a sockaddr, and stores them in \a port and \a addr if they are non-null. */ -static inline void qt_socket_getPortAndAddress(struct sockaddr *sa, quint16 *port, QHostAddress *addr) +static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *port, QHostAddress *addr) { #if !defined(QT_NO_IPV6) - if (sa->sa_family == AF_INET6) { - struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa; + if (s->a.sa_family == AF_INET6) { Q_IPV6ADDR tmp; - memcpy(&tmp, &sa6->sin6_addr.s6_addr, sizeof(tmp)); + memcpy(&tmp, &s->a6.sin6_addr, sizeof(tmp)); if (addr) { QHostAddress tmpAddress; tmpAddress.setAddress(tmp); *addr = tmpAddress; #ifndef QT_NO_IPV6IFNAME char scopeid[IFNAMSIZ]; - if (::if_indextoname(sa6->sin6_scope_id, scopeid)) { + if (::if_indextoname(s->a6.sin6_scope_id, scopeid)) { addr->setScopeId(QLatin1String(scopeid)); } else #endif - addr->setScopeId(QString::number(sa6->sin6_scope_id)); + addr->setScopeId(QString::number(s->a6.sin6_scope_id)); } if (port) - *port = ntohs(sa6->sin6_port); + *port = ntohs(s->a6.sin6_port); return; } #endif - struct sockaddr_in *sa4 = (struct sockaddr_in *)sa; if (port) - *port = ntohs(sa4->sin_port); + *port = ntohs(s->a4.sin_port); if (addr) { QHostAddress tmpAddress; - tmpAddress.setAddress(ntohl(sa4->sin_addr.s_addr)); + tmpAddress.setAddress(ntohl(s->a4.sin_addr.s_addr)); *addr = tmpAddress; } } @@ -547,26 +545,16 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const { // Create a sockaddr struct and reset its port number. -#if !defined(QT_NO_IPV6) - struct sockaddr_storage storage; - sockaddr_in6 *storagePtrIPv6 = reinterpret_cast<sockaddr_in6 *>(&storage); - storagePtrIPv6->sin6_port = 0; -#else - struct sockaddr storage; -#endif - sockaddr *storagePtr = reinterpret_cast<sockaddr *>(&storage); - storagePtr->sa_family = 0; - - sockaddr_in *storagePtrIPv4 = reinterpret_cast<sockaddr_in *>(&storage); - storagePtrIPv4->sin_port = 0; + qt_sockaddr storage; QT_SOCKLEN_T storageSize = sizeof(storage); + memset(&storage, 0, storageSize); // Peek 0 bytes into the next message. The size of the message may // well be 0, so we can't check recvfrom's return value. ssize_t readBytes; do { char c; - readBytes = qt_socket_recvfrom(socketDescriptor, &c, 1, MSG_PEEK, storagePtr, &storageSize); + readBytes = qt_socket_recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize); } while (readBytes == -1 && errno == EINTR); // If there's no error, or if our buffer was too small, there must be a @@ -618,11 +606,7 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxSize, QHostAddress *address, quint16 *port) { -#if !defined(QT_NO_IPV6) - struct sockaddr_storage aa; -#else - struct sockaddr_in aa; -#endif + qt_sockaddr aa; memset(&aa, 0, sizeof(aa)); QT_SOCKLEN_T sz; sz = sizeof(aa); @@ -631,13 +615,13 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS do { char c; recvFromResult = qt_socket_recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1, - 0, (struct sockaddr *)&aa, &sz); + 0, &aa.a, &sz); } while (recvFromResult == -1 && errno == EINTR); if (recvFromResult == -1) { setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString); } else if (port || address) { - qt_socket_getPortAndAddress((struct sockaddr *) &aa, port, address); + qt_socket_getPortAndAddress(&aa, port, address); } #if defined (QNATIVESOCKETENGINE_DEBUG) @@ -716,21 +700,16 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() if (socketDescriptor == -1) return false; -#if !defined(QT_NO_IPV6) - struct sockaddr_storage sa; -#else - struct sockaddr_in sa; -#endif - struct sockaddr *sockAddrPtr = (struct sockaddr *) &sa; + qt_sockaddr sa; QT_SOCKLEN_T sockAddrSize = sizeof(sa); // Determine local address memset(&sa, 0, sizeof(sa)); - if (qt_socket_getsockname(socketDescriptor, sockAddrPtr, &sockAddrSize) == 0) { - qt_socket_getPortAndAddress(sockAddrPtr, &localPort, &localAddress); + if (qt_socket_getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0) { + qt_socket_getPortAndAddress(&sa, &localPort, &localAddress); // Determine protocol family - switch (sockAddrPtr->sa_family) { + switch (sa.a.sa_family) { case AF_INET: socketProtocol = QAbstractSocket::IPv4Protocol; break; @@ -750,8 +729,8 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() } // Determine the remote address - if (!qt_socket_getpeername(socketDescriptor, sockAddrPtr, &sockAddrSize)) - qt_socket_getPortAndAddress(sockAddrPtr, &peerPort, &peerAddress); + if (!qt_socket_getpeername(socketDescriptor, &sa.a, &sockAddrSize)) + qt_socket_getPortAndAddress(&sa, &peerPort, &peerAddress); // Determine the socket type (UDP/TCP) int value = 0; diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index d140be2..b08d7b0 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -149,41 +149,6 @@ static QByteArray qt_prettyDebug(const char *data, int len, int maxLength) #endif -#if !defined (QT_NO_IPV6) - -// Use our own defines and structs which we know are correct -# define QT_SS_MAXSIZE 128 -# define QT_SS_ALIGNSIZE (sizeof(__int64)) -# define QT_SS_PAD1SIZE (QT_SS_ALIGNSIZE - sizeof (short)) -# define QT_SS_PAD2SIZE (QT_SS_MAXSIZE - (sizeof (short) + QT_SS_PAD1SIZE + QT_SS_ALIGNSIZE)) -struct qt_sockaddr_storage { - short ss_family; - char __ss_pad1[QT_SS_PAD1SIZE]; - __int64 __ss_align; - char __ss_pad2[QT_SS_PAD2SIZE]; -}; - -// sockaddr_in6 size changed between old and new SDK -// Only the new version is the correct one, so always -// use this structure. -struct qt_in6_addr { - u_char qt_s6_addr[16]; -}; -typedef struct { - short sin6_family; /* AF_INET6 */ - u_short sin6_port; /* Transport level port number */ - u_long sin6_flowinfo; /* IPv6 flow information */ - struct qt_in6_addr sin6_addr; /* IPv6 address */ - u_long sin6_scope_id; /* set of interfaces for a scope */ -} qt_sockaddr_in6; - -#else - -typedef void * qt_sockaddr_in6 ; - - -#endif - #ifndef AF_INET6 #define AF_INET6 23 /* Internetwork Version 6 */ #endif diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 04bc611..ca5c732 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2504,6 +2504,42 @@ const QGLContext* QGLContext::currentContext() visual. On other platforms it may work differently. */ +/*! \fn int QGLContext::choosePixelFormat(void* dummyPfd, HDC pdc) + + \bold{Win32 only:} This virtual function chooses a pixel format + that matches the OpenGL \link setFormat() format\endlink. + Reimplement this function in a subclass if you need a custom + context. + + \warning The \a dummyPfd pointer and \a pdc are used as a \c + PIXELFORMATDESCRIPTOR*. We use \c void to avoid using + Windows-specific types in our header files. + + \sa chooseContext() +*/ + +/*! \fn void *QGLContext::chooseVisual() + + \bold{X11 only:} This virtual function tries to find a visual that + matches the format, reducing the demands if the original request + cannot be met. + + The algorithm for reducing the demands of the format is quite + simple-minded, so override this method in your subclass if your + application has spcific requirements on visual selection. + + \sa chooseContext() +*/ + +/*! \fn void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth) + \internal + + \bold{X11 only:} This virtual function chooses a visual that matches + the OpenGL \link format() format\endlink. Reimplement this function + in a subclass if you need a custom visual. + + \sa chooseContext() +*/ /*! \fn void QGLContext::reset() @@ -2588,7 +2624,7 @@ const QGLContext* QGLContext::currentContext() \i paintGL() - Renders the OpenGL scene. Gets called whenever the widget needs to be updated. \i resizeGL() - Sets up the OpenGL viewport, projection, etc. Gets - called whenever the the widget has been resized (and also when it + called whenever the widget has been resized (and also when it is shown for the first time because all newly created widgets get a resize event automatically). \i initializeGL() - Sets up the OpenGL rendering context, defines display @@ -3020,11 +3056,10 @@ void QGLWidget::setFormat(const QGLFormat &format) */ /* - \obsolete - \fn void QGLWidget::setContext(QGLContext *context, - const QGLContext* shareContext, - bool deleteOldContext) + const QGLContext* shareContext, + bool deleteOldContext) + \obsolete Sets a new context for this widget. The QGLContext \a context must be created using \e new. QGLWidget will delete \a context when @@ -3174,9 +3209,10 @@ void QGLWidget::resizeOverlayGL(int, int) { } - +/*! \fn bool QGLWidget::event(QEvent *e) + \reimp +*/ #if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) -/*! \reimp */ bool QGLWidget::event(QEvent *e) { Q_D(QGLWidget); diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp index bd8569a..217b0fc 100644 --- a/src/opengl/qgl_win.cpp +++ b/src/opengl/qgl_win.cpp @@ -884,19 +884,9 @@ static bool qLogEq(bool a, bool b) return (((!a) && (!b)) || (a && b)); } -/*! - \bold{Win32 only:} This virtual function chooses a pixel - format that matches the OpenGL \link setFormat() format\endlink. - Reimplement this function in a subclass if you need a custom - context. - - \warning The \a dummyPfd pointer and \a pdc are used as a \c - PIXELFORMATDESCRIPTOR*. We use \c void to avoid using - Windows-specific types in our header files. - - \sa chooseContext() -*/ - +/* + See qgl.cpp for qdoc comment. + */ int QGLContext::choosePixelFormat(void* dummyPfd, HDC pdc) { Q_D(QGLContext); diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp index cb51598..7429071 100644 --- a/src/opengl/qgl_wince.cpp +++ b/src/opengl/qgl_wince.cpp @@ -552,9 +552,6 @@ void QGLWidgetPrivate::updateColormap() ReleaseDC(q->winId(), hdc); } -/*! - \reimp -\*/ bool QGLWidget::event(QEvent *e) { Q_D(QGLWidget); diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 28c34de..7ed7a23 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -443,19 +443,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) return true; } - -/*! - \bold{X11 only:} This virtual function tries to find a - visual that matches the format, reducing the demands if the original - request cannot be met. - - The algorithm for reducing the demands of the format is quite - simple-minded, so override this method in your subclass if your - application has spcific requirements on visual selection. - - \sa chooseContext() -*/ - +/* + See qgl.cpp for qdoc comment. + */ void *QGLContext::chooseVisual() { Q_D(QGLContext); @@ -519,17 +509,9 @@ void *QGLContext::chooseVisual() return vis; } - -/*! - \internal - - \bold{X11 only:} This virtual function chooses a visual - that matches the OpenGL \link format() format\endlink. Reimplement this - function in a subclass if you need a custom visual. - - \sa chooseContext() -*/ - +/* + See qgl.cpp for qdoc comment. + */ void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth) { Q_D(QGLContext); diff --git a/src/plugins/accessible/widgets/rangecontrols.h b/src/plugins/accessible/widgets/rangecontrols.h index aea91e1..57073ee 100644 --- a/src/plugins/accessible/widgets/rangecontrols.h +++ b/src/plugins/accessible/widgets/rangecontrols.h @@ -60,6 +60,7 @@ class QDial; #ifndef QT_NO_SPINBOX class QAccessibleAbstractSpinBox: public QAccessibleWidgetEx, public QAccessibleValueInterface { + Q_ACCESSIBLE_OBJECT public: explicit QAccessibleAbstractSpinBox(QWidget *w); @@ -132,6 +133,7 @@ protected: class QAccessibleAbstractSlider: public QAccessibleWidgetEx, public QAccessibleValueInterface { + Q_ACCESSIBLE_OBJECT public: explicit QAccessibleAbstractSlider(QWidget *w, Role r = Slider); diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h index d4552e3..d1fd0da 100644 --- a/src/plugins/accessible/widgets/simplewidgets.h +++ b/src/plugins/accessible/widgets/simplewidgets.h @@ -115,6 +115,7 @@ public: class QAccessibleLineEdit : public QAccessibleWidgetEx, public QAccessibleTextInterface, public QAccessibleSimpleEditableTextInterface { + Q_ACCESSIBLE_OBJECT public: explicit QAccessibleLineEdit(QWidget *o, const QString &name = QString()); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 91a60e7..a68bc8f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -275,7 +275,6 @@ private: int lastLockedHeight; IDirectFB *fb; - DFBSurfaceDescription fbDescription; int fbWidth; int fbHeight; @@ -384,7 +383,7 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); d->dirtyClip = true; - const QPoint bottom = d->transform.map(QPoint(0, path.controlPointRect().y2)); + const QPoint bottom = d->transform.map(QPoint(0, int(path.controlPointRect().y2))); if (bottom.y() >= d->lastLockedHeight) d->lock(); QRasterPaintEngine::clip(path, op); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 7297a99..c9b676a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -271,7 +271,7 @@ void QDirectFBPixmapData::fill(const QColor &color) forceRaster = false; setSerialNumber(++global_ser_no); if (!dfbSurface) { - qWarning("QDirecttFBPixmapData::fill()"); + qWarning("QDirectFBPixmapData::fill()"); invalidate(); return; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index f571d1b..98e32ed 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -205,6 +205,7 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, SurfaceCreationOptions options) { DFBSurfaceDescription desc; + memset(&desc, 0, sizeof(DFBSurfaceDescription)); desc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH|DSDESC_HEIGHT); if (!QDirectFBScreen::initSurfaceDescriptionPixelFormat(&desc, format)) return 0; @@ -213,7 +214,6 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, return createDFBSurface(desc, options); } - IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options) { DFBResult result = DFB_OK; @@ -247,6 +247,7 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, } desc.caps = DFBSurfaceCapabilities(desc.caps & ~DSCAPS_VIDEOONLY); } + if (d_ptr->directFBFlags & SystemOnly) desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_SYSTEMONLY); @@ -293,14 +294,14 @@ IDirectFBSurface *QDirectFBScreen::copyToDFBSurface(const QImage &img, IDirectFBSurface *dfbSurface = createDFBSurface(image.size(), pixmapFormat, options); if (!dfbSurface) { - qWarning("QDirectFBPixmapData::fromImage() Couldn't create surface"); + qWarning("QDirectFBScreen::copyToDFBSurface() Couldn't create surface"); return 0; } #ifndef QT_NO_DIRECTFB_PREALLOCATED IDirectFBSurface *imgSurface = createDFBSurface(image, DontTrackSurface); if (!imgSurface) { - qWarning("QDirectFBPixmapData::fromImage()"); + qWarning("QDirectFBScreen::copyToDFBSurface()"); QDirectFBScreen::releaseDFBSurface(dfbSurface); return 0; } @@ -315,7 +316,7 @@ IDirectFBSurface *QDirectFBScreen::copyToDFBSurface(const QImage &img, dfbSurface->SetBlittingFlags(dfbSurface, flags); DFBResult result = dfbSurface->Blit(dfbSurface, imgSurface, 0, 0, 0); if (result != DFB_OK) - DirectFBError("QDirectFBPixmapData::fromImage()", result); + DirectFBError("QDirectFBScreen::copyToDFBSurface()", result); dfbSurface->ReleaseSource(dfbSurface); imgSurface->Release(imgSurface); #else // QT_NO_DIRECTFB_PREALLOCATED @@ -445,6 +446,7 @@ QImage::Format QDirectFBScreen::getImageFormat(IDirectFBSurface *surface) DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const QImage &image) { DFBSurfaceDescription description; + memset(&description, 0, sizeof(DFBSurfaceDescription)); const DFBSurfacePixelFormat format = getSurfacePixelFormat(image.format()); @@ -479,6 +481,7 @@ DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const uint *buffer, int length) { DFBSurfaceDescription description; + memset(&description, 0, sizeof(DFBSurfaceDescription)); description.flags = DFBSurfaceDescriptionFlags(DSDESC_CAPS | DSDESC_WIDTH @@ -917,6 +920,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec) d_ptr->dfb->SetCooperativeLevel(d_ptr->dfb, DFSCL_FULLSCREEN); DFBSurfaceDescription description; + memset(&description, 0, sizeof(DFBSurfaceDescription)); + description.flags = DFBSurfaceDescriptionFlags(DSDESC_CAPS); if (::setIntOption(displayArgs, QLatin1String("width"), &description.width)) description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_WIDTH); diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp index c7249d3..3273513 100644 --- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp @@ -122,16 +122,10 @@ QSize QSvgIconEngine::actualSize(const QSize &size, QIcon::Mode mode, return size; } - QSvgRenderer renderer; - d->loadDataForModeAndState(&renderer, mode, state); - if (renderer.isValid()) { - QSize defaultSize = renderer.defaultSize(); - if (!defaultSize.isNull()) - defaultSize.scale(size, Qt::KeepAspectRatio); - return defaultSize; - } else { + QPixmap pm = pixmap(size, mode, state); + if (pm.isNull()) return QSize(); - } + return pm.size(); } void QSvgIconEnginePrivate::loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state) diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro index bacf23b..0574341 100644 --- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro +++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro @@ -2,7 +2,5 @@ TEMPLATE = subdirs # We just want to extract the zip file containing sqlite binaries for Symbian -!exists($${EPOCROOT}epoc32/release/armv5/urel/sqlite3.dll): { - BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" -} +BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" diff --git a/src/qt3support/network/q3http.cpp b/src/qt3support/network/q3http.cpp index f1590a6..591b381 100644 --- a/src/qt3support/network/q3http.cpp +++ b/src/qt3support/network/q3http.cpp @@ -626,7 +626,7 @@ void Q3HttpHeader::setContentLength( int len ) } /*! - Returns true if the header has an entry for the the special HTTP + Returns true if the header has an entry for the special HTTP header field \c content-type; otherwise returns false. \sa contentType() setContentType() diff --git a/src/qt3support/network/q3urloperator.cpp b/src/qt3support/network/q3urloperator.cpp index 3f334a8..b415e12 100644 --- a/src/qt3support/network/q3urloperator.cpp +++ b/src/qt3support/network/q3urloperator.cpp @@ -543,7 +543,7 @@ const Q3NetworkOperation *Q3UrlOperator::rename( const QString &oldname, const Q in mind that the get() and put() operations emit this signal through the Q3UrlOperator. The number of transferred bytes and the total bytes that you receive as arguments in this signal do not - relate to the the whole copy operation; they relate first to the + relate to the whole copy operation; they relate first to the get() and then to the put() operation. Always check what type of operation the signal comes from; this is given in the signal's last argument. diff --git a/src/qt3support/widgets/q3action.cpp b/src/qt3support/widgets/q3action.cpp index 4e1a1bf..311212a 100644 --- a/src/qt3support/widgets/q3action.cpp +++ b/src/qt3support/widgets/q3action.cpp @@ -497,7 +497,7 @@ Q3Action::Q3Action(const QIcon& icon, const QString& menuText, QKeySequence acce } /*! - This constructor results in an icon-less action with the the menu + This constructor results in an icon-less action with the menu text \a menuText and keyboard accelerator \a accel. It is a child of \a parent and called \a name. diff --git a/src/qt3support/widgets/q3groupbox.cpp b/src/qt3support/widgets/q3groupbox.cpp index 1fa7e7c..e0b609a 100644 --- a/src/qt3support/widgets/q3groupbox.cpp +++ b/src/qt3support/widgets/q3groupbox.cpp @@ -382,7 +382,7 @@ int Q3GroupBox::insideSpacing() const } /*! - Sets the the width of the inside margin to \a m pixels. + Sets the width of the inside margin to \a m pixels. \sa insideMargin() */ @@ -954,7 +954,7 @@ int Q3GroupBox::frameWidth() const \fn int Q3GroupBox::margin() const \since 4.2 - Returns the width of the the margin around the contents of the widget. + Returns the width of the margin around the contents of the widget. This function uses QWidget::getContentsMargins() to get the margin. diff --git a/src/qt3support/widgets/q3popupmenu.cpp b/src/qt3support/widgets/q3popupmenu.cpp index 7f890b5..0b3a524 100644 --- a/src/qt3support/widgets/q3popupmenu.cpp +++ b/src/qt3support/widgets/q3popupmenu.cpp @@ -134,7 +134,7 @@ QT_BEGIN_NAMESPACE \fn int Q3PopupMenu::margin() const \since 4.2 - Returns the with of the the margin around the contents of the widget. + Returns the width of the margin around the contents of the widget. This function uses QWidget::getContentsMargins() to get the margin. \sa setMargin(), QWidget::getContentsMargins() diff --git a/src/qt3support/widgets/q3progressbar.cpp b/src/qt3support/widgets/q3progressbar.cpp index caae460..81f0dbf 100644 --- a/src/qt3support/widgets/q3progressbar.cpp +++ b/src/qt3support/widgets/q3progressbar.cpp @@ -455,7 +455,7 @@ void Q3ProgressBar::paintEvent(QPaintEvent *) \fn int Q3ProgressBar::margin() const \since 4.2 - Returns the with of the the margin around the contents of the widget. + Returns the width of the margin around the contents of the widget. This function uses QWidget::getContentsMargins() to get the margin. \sa setMargin(), QWidget::getContentsMargins() diff --git a/src/qt3support/widgets/q3scrollview.cpp b/src/qt3support/widgets/q3scrollview.cpp index 91a9203..5a91027 100644 --- a/src/qt3support/widgets/q3scrollview.cpp +++ b/src/qt3support/widgets/q3scrollview.cpp @@ -2038,7 +2038,7 @@ void Q3ScrollView::center(int x, int y) \list \i Margin 0.0 allows (x, y) to be on the edge of the visible area. \i Margin 0.5 ensures that (x, y) is in middle 50% of the visible area. - \i Margin 1.0 ensures that (x, y) is in the center of the the visible area. + \i Margin 1.0 ensures that (x, y) is in the center of the visible area. \endlist */ void Q3ScrollView::center(int x, int y, float xmargin, float ymargin) diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro index 99fde62..9aadfc0 100644 --- a/src/s60installs/qt_libs.pro +++ b/src/s60installs/qt_libs.pro @@ -66,7 +66,7 @@ symbian: { } contains(QT_CONFIG, phonon): { - qtlibraries.sources += QtPhonon.dll + qtlibraries.sources += Phonon.dll } BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" diff --git a/src/script/qscriptvalueiterator.cpp b/src/script/qscriptvalueiterator.cpp index fe5ef9f..1a60632 100644 --- a/src/script/qscriptvalueiterator.cpp +++ b/src/script/qscriptvalueiterator.cpp @@ -106,6 +106,7 @@ QScriptValueIteratorPrivate::QScriptValueIteratorPrivate() */ QScriptValueIteratorPrivate::~QScriptValueIteratorPrivate() { + delete it; } /*! @@ -130,7 +131,6 @@ QScriptValueIterator::QScriptValueIterator(const QScriptValue &object) QScriptValueIterator::~QScriptValueIterator() { if (d_ptr) { - delete d_ptr->it; delete d_ptr; d_ptr = 0; } @@ -312,7 +312,7 @@ void QScriptValueIterator::remove() QScriptValueIterator& QScriptValueIterator::operator=(QScriptValue &object) { if (d_ptr) { - delete d_ptr->it; + delete d_ptr; d_ptr = 0; } QScriptValueImpl val = QScriptValuePrivate::valueOf(object); diff --git a/src/scripttools/debugging/qscriptenginedebugger.cpp b/src/scripttools/debugging/qscriptenginedebugger.cpp index e35bd1d..0f8b600 100644 --- a/src/scripttools/debugging/qscriptenginedebugger.cpp +++ b/src/scripttools/debugging/qscriptenginedebugger.cpp @@ -63,16 +63,23 @@ #include <QtGui/qtoolbar.h> #include <QtGui/qboxlayout.h> +// this has to be outside the namespace +static void initScriptEngineDebuggerResources() +{ + Q_INIT_RESOURCE(scripttools_debugging); +} + +QT_BEGIN_NAMESPACE + class QtScriptDebuggerResourceInitializer { public: QtScriptDebuggerResourceInitializer() { - Q_INIT_RESOURCE(scripttools_debugging); + // call outside-the-namespace function + initScriptEngineDebuggerResources(); } }; -QT_BEGIN_NAMESPACE - /*! \since 4.5 \class QScriptEngineDebugger diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index 6834d9a..1645555 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -55,6 +55,7 @@ #include <limits.h> #include <math.h> #include <qdebug.h> +#include <QVarLengthArray> QT_BEGIN_NAMESPACE @@ -66,8 +67,11 @@ QT_BEGIN_NAMESPACE enum { QIBaseChunkSize = SHRT_MAX / 2 }; -static bool getIBaseError(QString& msg, ISC_STATUS* status, ISC_LONG &sqlcode, - QTextCodec *tc) +#if defined(FB_API_VER) && FB_API_VER >= 20 +static bool getIBaseError(QString& msg, const ISC_STATUS* status, ISC_LONG &sqlcode, QTextCodec *tc) +#else +static bool getIBaseError(QString& msg, ISC_STATUS* status, ISC_LONG &sqlcode, QTextCodec *tc) +#endif { if (status[0] != 1 || status[1] <= 0) return false; @@ -75,7 +79,11 @@ static bool getIBaseError(QString& msg, ISC_STATUS* status, ISC_LONG &sqlcode, msg.clear(); sqlcode = isc_sqlcode(status); char buf[512]; +#if defined(FB_API_VER) && FB_API_VER >= 20 + while(fb_interpret(buf, 512, &status)) { +#else while(isc_interprete(buf, &status)) { +#endif if(!msg.isEmpty()) msg += QLatin1String(" - "); if (tc) @@ -576,7 +584,7 @@ QVariant QIBaseResultPrivate::fetchArray(int pos, ISC_QUAD *arr) int arraySize = 1, subArraySize; short dimensions = desc.array_desc_dimensions; - short *numElements = new short[dimensions]; + QVarLengthArray<short> numElements(dimensions); for(int i = 0; i < dimensions; ++i) { subArraySize = (desc.array_desc_bounds[i].array_bound_upper - @@ -605,9 +613,7 @@ QVariant QIBaseResultPrivate::fetchArray(int pos, ISC_QUAD *arr) QSqlError::StatementError)) return list; - readArrayBuffer(list, ba.data(), 0, numElements, &desc, tc); - - delete[] numElements; + readArrayBuffer(list, ba.data(), 0, numElements.data(), &desc, tc); return QVariant(list); } diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 1f54db7..53645c9 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -163,18 +163,21 @@ static inline QVariant qDateTimeFromString(QString &val) #endif } -class QMYSQLResultPrivate +class QMYSQLResultPrivate : public QObject { + Q_OBJECT public: - QMYSQLResultPrivate(QMYSQLDriverPrivate* dp) : d(dp), result(0), + QMYSQLResultPrivate(const QMYSQLDriver* dp) : driver(dp), result(0), rowsAffected(0), hasBlobs(false) #if MYSQL_VERSION_ID >= 40108 , stmt(0), meta(0), inBinds(0), outBinds(0) #endif , precisionPolicy(QSql::HighPrecision) - {} + { + connect(dp, SIGNAL(destroyed()), this, SLOT(driverDestroyed())); + } - QMYSQLDriverPrivate* d; + const QMYSQLDriver* driver; MYSQL_RES *result; MYSQL_ROW row; @@ -207,6 +210,8 @@ public: MYSQL_BIND *outBinds; #endif QSql::NumericalPrecisionPolicy precisionPolicy; +private Q_SLOTS: + void driverDestroyed() { driver = NULL; } }; #ifndef QT_NO_TEXTCODEC @@ -379,7 +384,7 @@ bool QMYSQLResultPrivate::bindInValues() QMYSQLResult::QMYSQLResult(const QMYSQLDriver* db) : QSqlResult(db) { - d = new QMYSQLResultPrivate(db->d); + d = new QMYSQLResultPrivate(db); } QMYSQLResult::~QMYSQLResult() @@ -391,7 +396,7 @@ QMYSQLResult::~QMYSQLResult() QVariant QMYSQLResult::handle() const { #if MYSQL_VERSION_ID >= 40108 - if(d->d->preparedQuerys) + if(d->driver && d->driver->d->preparedQuerys) return d->meta ? qVariantFromValue(d->meta) : qVariantFromValue(d->stmt); else #endif @@ -406,8 +411,8 @@ void QMYSQLResult::cleanup() // must iterate trough leftover result sets from multi-selects or stored procedures // if this isn't done subsequent queries will fail with "Commands out of sync" #if MYSQL_VERSION_ID >= 40100 - while (d->d->mysql && mysql_next_result(d->d->mysql) == 0) { - MYSQL_RES *res = mysql_store_result(d->d->mysql); + while (d->driver && d->driver->d->mysql && mysql_next_result(d->driver->d->mysql) == 0) { + MYSQL_RES *res = mysql_store_result(d->driver->d->mysql); if (res) mysql_free_result(res); } @@ -447,11 +452,14 @@ void QMYSQLResult::cleanup() setAt(-1); setActive(false); - d->d->preparedQuerys = d->d->preparedQuerysEnabled; + if(d->driver) + d->driver->d->preparedQuerys = d->driver->d->preparedQuerysEnabled; } bool QMYSQLResult::fetch(int i) { + if(!d->driver) + return false; if (isForwardOnly()) { // fake a forward seek if (at() < i) { int x = i - at(); @@ -463,7 +471,7 @@ bool QMYSQLResult::fetch(int i) } if (at() == i) return true; - if (d->d->preparedQuerys) { + if (d->driver->d->preparedQuerys) { #if MYSQL_VERSION_ID >= 40108 mysql_stmt_data_seek(d->stmt, i); @@ -494,7 +502,9 @@ bool QMYSQLResult::fetch(int i) bool QMYSQLResult::fetchNext() { - if (d->d->preparedQuerys) { + if(!d->driver) + return false; + if (d->driver->d->preparedQuerys) { #if MYSQL_VERSION_ID >= 40108 if (mysql_stmt_fetch(d->stmt)) return false; @@ -512,6 +522,8 @@ bool QMYSQLResult::fetchNext() bool QMYSQLResult::fetchLast() { + if(!d->driver) + return false; if (isForwardOnly()) { // fake this since MySQL can't seek on forward only queries bool success = fetchNext(); // did we move at all? while (fetchNext()) {}; @@ -519,7 +531,7 @@ bool QMYSQLResult::fetchLast() } my_ulonglong numRows; - if (d->d->preparedQuerys) { + if (d->driver->d->preparedQuerys) { #if MYSQL_VERSION_ID >= 40108 numRows = mysql_stmt_num_rows(d->stmt); #else @@ -553,15 +565,18 @@ QVariant QMYSQLResult::data(int field) return QVariant(); } + if (!d->driver) + return QVariant(); + int fieldLength = 0; const QMYSQLResultPrivate::QMyField &f = d->fields.at(field); QString val; - if (d->d->preparedQuerys) { + if (d->driver->d->preparedQuerys) { if (f.nullIndicator) return QVariant(f.type); if (f.type != QVariant::ByteArray) - val = toUnicode(d->d->tc, f.outField, f.bufLength); + val = toUnicode(d->driver->d->tc, f.outField, f.bufLength); } else { if (d->row[field] == NULL) { // NULL value @@ -569,7 +584,7 @@ QVariant QMYSQLResult::data(int field) } fieldLength = mysql_fetch_lengths(d->result)[field]; if (f.type != QVariant::ByteArray) - val = toUnicode(d->d->tc, d->row[field], fieldLength); + val = toUnicode(d->driver->d->tc, d->row[field], fieldLength); } switch(f.type) { @@ -614,7 +629,7 @@ QVariant QMYSQLResult::data(int field) case QVariant::ByteArray: { QByteArray ba; - if (d->d->preparedQuerys) { + if (d->driver->d->preparedQuerys) { ba = QByteArray(f.outField, f.bufLength); } else { ba = QByteArray(d->row[field], fieldLength); @@ -631,7 +646,7 @@ QVariant QMYSQLResult::data(int field) bool QMYSQLResult::isNull(int field) { - if (d->d->preparedQuerys) + if (d->driver->d->preparedQuerys) return d->fields.at(field).nullIndicator; else return d->row[field] == NULL; @@ -639,31 +654,31 @@ bool QMYSQLResult::isNull(int field) bool QMYSQLResult::reset (const QString& query) { - if (!driver() || !driver()->isOpen() || driver()->isOpenError()) + if (!driver() || !driver()->isOpen() || driver()->isOpenError() || !d->driver) return false; - if(d->d->preparedQuerysEnabled && prepare(query)) { - d->d->preparedQuerys = true; + if(d->driver->d->preparedQuerysEnabled && prepare(query)) { + d->driver->d->preparedQuerys = true; return exec(); } - d->d->preparedQuerys = false; + d->driver->d->preparedQuerys = false; - const QByteArray encQuery(fromUnicode(d->d->tc, query)); - if (mysql_real_query(d->d->mysql, encQuery.data(), encQuery.length())) { + const QByteArray encQuery(fromUnicode(d->driver->d->tc, query)); + if (mysql_real_query(d->driver->d->mysql, encQuery.data(), encQuery.length())) { setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to execute query"), - QSqlError::StatementError, d->d)); + QSqlError::StatementError, d->driver->d)); return false; } - d->result = mysql_store_result(d->d->mysql); - if (!d->result && mysql_field_count(d->d->mysql) > 0) { + d->result = mysql_store_result(d->driver->d->mysql); + if (!d->result && mysql_field_count(d->driver->d->mysql) > 0) { setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to store result"), - QSqlError::StatementError, d->d)); + QSqlError::StatementError, d->driver->d)); return false; } - int numFields = mysql_field_count(d->d->mysql); + int numFields = mysql_field_count(d->driver->d->mysql); setSelect(numFields != 0); d->fields.resize(numFields); - d->rowsAffected = mysql_affected_rows(d->d->mysql); + d->rowsAffected = mysql_affected_rows(d->driver->d->mysql); if (isSelect()) { for(int i = 0; i < numFields; i++) { MYSQL_FIELD* field = mysql_fetch_field_direct(d->result, i); @@ -677,8 +692,8 @@ bool QMYSQLResult::reset (const QString& query) int QMYSQLResult::size() { - if (isSelect()) - if (d->d->preparedQuerys) + if (d->driver && isSelect()) + if (d->driver->d->preparedQuerys) #if MYSQL_VERSION_ID >= 40108 return mysql_stmt_num_rows(d->stmt); #else @@ -697,17 +712,17 @@ int QMYSQLResult::numRowsAffected() QVariant QMYSQLResult::lastInsertId() const { - if (!isActive()) + if (!isActive() || !d->driver) return QVariant(); - if (d->d->preparedQuerys) { + if (d->driver->d->preparedQuerys) { #if MYSQL_VERSION_ID >= 40108 quint64 id = mysql_stmt_insert_id(d->stmt); if (id) return QVariant(id); #endif } else { - quint64 id = mysql_insert_id(d->d->mysql); + quint64 id = mysql_insert_id(d->driver->d->mysql); if (id) return QVariant(id); } @@ -718,20 +733,20 @@ QSqlRecord QMYSQLResult::record() const { QSqlRecord info; MYSQL_RES *res; - if (!isActive() || !isSelect()) + if (!isActive() || !isSelect() || !d->driver) return info; #if MYSQL_VERSION_ID >= 40108 - res = d->d->preparedQuerys ? d->meta : d->result; + res = d->driver->d->preparedQuerys ? d->meta : d->result; #else res = d->result; #endif - if (!mysql_errno(d->d->mysql)) { + if (!mysql_errno(d->driver->d->mysql)) { mysql_field_seek(res, 0); MYSQL_FIELD* field = mysql_fetch_field(res); while(field) { - info.append(qToField(field, d->d->tc)); + info.append(qToField(field, d->driver->d->tc)); field = mysql_fetch_field(res); } } @@ -741,6 +756,8 @@ QSqlRecord QMYSQLResult::record() const bool QMYSQLResult::nextResult() { + if(!d->driver) + return false; #if MYSQL_VERSION_ID >= 40100 setAt(-1); setActive(false); @@ -754,26 +771,26 @@ bool QMYSQLResult::nextResult() delete[] d->fields[i].outField; d->fields.clear(); - int status = mysql_next_result(d->d->mysql); + int status = mysql_next_result(d->driver->d->mysql); if (status > 0) { setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to execute next query"), - QSqlError::StatementError, d->d)); + QSqlError::StatementError, d->driver->d)); return false; } else if (status == -1) { return false; // No more result sets } - d->result = mysql_store_result(d->d->mysql); - int numFields = mysql_field_count(d->d->mysql); + d->result = mysql_store_result(d->driver->d->mysql); + int numFields = mysql_field_count(d->driver->d->mysql); if (!d->result && numFields > 0) { setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to store next result"), - QSqlError::StatementError, d->d)); + QSqlError::StatementError, d->driver->d)); return false; } setSelect(numFields > 0); d->fields.resize(numFields); - d->rowsAffected = mysql_affected_rows(d->d->mysql); + d->rowsAffected = mysql_affected_rows(d->driver->d->mysql); if (isSelect()) { for (int i = 0; i < numFields; i++) { @@ -833,9 +850,11 @@ static MYSQL_TIME *toMySqlDate(QDate date, QTime time, QVariant::Type type) bool QMYSQLResult::prepare(const QString& query) { + if(!d->driver) + return false; #if MYSQL_VERSION_ID >= 40108 cleanup(); - if (!d->d->preparedQuerys) + if (!d->driver->d->preparedQuerys) return QSqlResult::prepare(query); int r; @@ -844,14 +863,14 @@ bool QMYSQLResult::prepare(const QString& query) return false; if (!d->stmt) - d->stmt = mysql_stmt_init(d->d->mysql); + d->stmt = mysql_stmt_init(d->driver->d->mysql); if (!d->stmt) { setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to prepare statement"), - QSqlError::StatementError, d->d)); + QSqlError::StatementError, d->driver->d)); return false; } - const QByteArray encQuery(fromUnicode(d->d->tc, query)); + const QByteArray encQuery(fromUnicode(d->driver->d->tc, query)); r = mysql_stmt_prepare(d->stmt, encQuery.constData(), encQuery.length()); if (r != 0) { setLastError(qMakeStmtError(QCoreApplication::translate("QMYSQLResult", @@ -873,7 +892,9 @@ bool QMYSQLResult::prepare(const QString& query) bool QMYSQLResult::exec() { - if (!d->d->preparedQuerys) + if (!d->driver) + return false; + if (!d->driver->d->preparedQuerys) return QSqlResult::exec(); if (!d->stmt) return false; @@ -906,6 +927,7 @@ bool QMYSQLResult::exec() nullVector[i] = static_cast<my_bool>(val.isNull()); currBind->is_null = &nullVector[i]; currBind->length = 0; + currBind->is_unsigned = 0; switch (val.type()) { case QVariant::ByteArray: @@ -952,7 +974,6 @@ bool QMYSQLResult::exec() currBind->buffer_type = MYSQL_TYPE_DOUBLE; currBind->buffer = data; currBind->buffer_length = sizeof(double); - currBind->is_unsigned = 0; break; case QVariant::LongLong: case QVariant::ULongLong: @@ -963,12 +984,11 @@ bool QMYSQLResult::exec() break; case QVariant::String: default: { - QByteArray ba = fromUnicode(d->d->tc, val.toString()); + QByteArray ba = fromUnicode(d->driver->d->tc, val.toString()); stringVector.append(ba); currBind->buffer_type = MYSQL_TYPE_STRING; currBind->buffer = const_cast<char *>(ba.constData()); currBind->buffer_length = ba.length(); - currBind->is_unsigned = 0; break; } } } @@ -1258,6 +1278,11 @@ bool QMYSQLDriver::open(const QString& db, d->preparedQuerysEnabled = false; #endif +#ifndef QT_NO_THREAD + mysql_thread_init(); +#endif + + setOpen(true); setOpenError(false); return true; @@ -1266,6 +1291,9 @@ bool QMYSQLDriver::open(const QString& db, void QMYSQLDriver::close() { if (isOpen()) { +#ifndef QT_NO_THREAD + mysql_thread_end(); +#endif mysql_close(d->mysql); d->mysql = NULL; setOpen(false); @@ -1459,3 +1487,5 @@ bool QMYSQLDriver::isIdentifierEscapedImplementation(const QString &identifier, } QT_END_NAMESPACE + +#include "qsql_mysql.moc"
\ No newline at end of file diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index d63c482..a7031b1 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -1789,7 +1789,7 @@ bool QOCIResult::prepare(const QString& query) bool QOCIResult::exec() { int r = 0; - ub2 stmtType; + ub2 stmtType=0; ub4 iters; ub4 mode; QList<QByteArray> tmpStorage; @@ -1803,6 +1803,16 @@ bool QOCIResult::exec() OCI_ATTR_STMT_TYPE, d->err); + if (r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO) { + qOraWarning("QOCIResult::exec: Unable to get statement type:", d->err); + setLastError(qMakeError(QCoreApplication::translate("QOCIResult", + "Unable to get statement type"), QSqlError::StatementError, d->err)); +#ifdef QOCI_DEBUG + qDebug() << "lastQuery()" << lastQuery(); +#endif + return false; + } + if (stmtType == OCI_STMT_SELECT) { iters = 0; mode = OCI_DEFAULT; diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index 6232452..a270c0e 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -378,7 +378,7 @@ void QSqlDatabasePrivate::disable() the connection name argument, if you don't pass the connection name argument, the default connection is assumed. The following snippet shows how to create and open a default connection to a - MySQL database: + PostgreSQL database: \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 0 diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index e6729a5..2a07e28 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -1195,7 +1195,7 @@ void QSqlQuery::finish() The query will be repositioned on an \e invalid record in the new result set and must be navigated to a valid record before data values can be retrieved. If a new result set isn't available the - function returns false and the the query is set to inactive. In any + function returns false and the query is set to inactive. In any case the old result set will be discarded. When one of the statements is a non-select statement a count of diff --git a/src/src.pro b/src/src.pro index 667df9c..f131e4f 100644 --- a/src/src.pro +++ b/src/src.pro @@ -23,6 +23,9 @@ win32:{ !wince*: SRC_SUBDIRS += src_tools_idc } +# TODO the following line should be between opengl and webkit when the 'symbian' block is removed +contains(QT_CONFIG, phonon): SRC_SUBDIRS += src_phonon + !symbian { contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): SRC_SUBDIRS += src_opengl contains(QT_CONFIG, xmlpatterns): SRC_SUBDIRS += src_xmlpatterns @@ -31,7 +34,6 @@ contains(QT_CONFIG, webkit) { #exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): SRC_SUBDIRS += src_javascriptcore SRC_SUBDIRS += src_webkit } -contains(QT_CONFIG, phonon): SRC_SUBDIRS += src_phonon contains(QT_CONFIG, scripttools): SRC_SUBDIRS += src_scripttools SRC_SUBDIRS += src_plugins } diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 433a3ad..6a897e8 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1673,10 +1673,19 @@ static void parseCSStoXMLAttrs(const QVector<QCss::Declaration> &declarations, const QCss::Declaration &decl = declarations.at(i); if (decl.d->property.isEmpty()) continue; - if (decl.d->values.count() != 1) - continue; QCss::Value val = decl.d->values.first(); - QString valueStr = val.toString(); + QString valueStr; + if (decl.d->values.count() != 1) { + for (int i=0; i<decl.d->values.count(); ++i) { + const QString &value = decl.d->values[i].toString(); + if (value.isEmpty()) + valueStr += QLatin1Char(','); + else + valueStr += value; + } + } else { + valueStr = val.toString(); + } if (val.type == QCss::Value::Uri) { valueStr.prepend(QLatin1String("url(")); valueStr.append(QLatin1Char(')')); diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h index ebfdae1..ba7da2a 100644 --- a/src/testlib/qtest_global.h +++ b/src/testlib/qtest_global.h @@ -52,7 +52,7 @@ QT_MODULE(Test) #ifdef QTEST_EMBED # define Q_TESTLIB_EXPORT -#elif !defined(QT_SHARED) +#elif !defined(QT_SHARED) && !(defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT)) # define Q_TESTLIB_EXPORT #else # ifdef QTESTLIB_MAKEDLL @@ -64,7 +64,7 @@ QT_MODULE(Test) #if (defined (Q_CC_MSVC) && _MSC_VER < 1310) || defined (Q_CC_SUN) || defined (Q_CC_XLC) || (defined (Q_CC_GNU) && (__GNUC__ - 0 < 3)) || defined (Q_CC_NOKIAX86) # define QTEST_NO_SPECIALIZATIONS -#endif +#endif #if (defined Q_CC_HPACC) && (defined __ia64) diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index b94d3fa..ba68636 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -2109,7 +2109,7 @@ events are reported. You can set the lexical handler with QXmlReader::setLexicalHandler(). - This interface's design is based on the the SAX2 extension + This interface's design is based on the SAX2 extension LexicalHandler. The interface provides the startDTD(), endDTD(), startEntity(), diff --git a/src/xmlpatterns/expr/qpath.cpp b/src/xmlpatterns/expr/qpath.cpp index 33bfa0f..a60f622 100644 --- a/src/xmlpatterns/expr/qpath.cpp +++ b/src/xmlpatterns/expr/qpath.cpp @@ -170,7 +170,7 @@ Expression::Ptr Path::compress(const StaticContext::Ptr &context) /* We do this as late as we can, such that we pick up the most recent type * from the operand. */ - if(m_isLast && !m_kind == XSLTForEach && m_operand2->staticType()->itemType() == BuiltinTypes::item) + if(m_isLast && m_kind != XSLTForEach && m_operand2->staticType()->itemType() == BuiltinTypes::item) m_checkXPTY0018 = true; return me; diff --git a/src/xmlpatterns/expr/qxsltsimplecontentconstructor.cpp b/src/xmlpatterns/expr/qxsltsimplecontentconstructor.cpp index ef77c76..104c5cc 100644 --- a/src/xmlpatterns/expr/qxsltsimplecontentconstructor.cpp +++ b/src/xmlpatterns/expr/qxsltsimplecontentconstructor.cpp @@ -105,7 +105,7 @@ Item XSLTSimpleContentConstructor::evaluateSingleton(const DynamicContext::Ptr & QString result; bool previousIsText = false; - bool discard; + bool discard = false; if(next) { |