summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2009-09-15 03:12:32 (GMT)
committerSarah Smith <sarah.j.smith@nokia.com>2009-09-15 03:12:32 (GMT)
commit227dd18f0e25ee522e5a4323e849590a314dd4cd (patch)
treec7712b9b55e4f05bccf77c92edc992c3068ddfb3 /src
parent02cc6a825227daf6f35f7bc17377a4a622f16391 (diff)
parentd94f6a35202d2d62671072b4ba78e75b07d630bd (diff)
downloadQt-227dd18f0e25ee522e5a4323e849590a314dd4cd.zip
Qt-227dd18f0e25ee522e5a4323e849590a314dd4cd.tar.gz
Qt-227dd18f0e25ee522e5a4323e849590a314dd4cd.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp2
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp2
-rw-r--r--src/corelib/tools/qlocale.cpp34
-rw-r--r--src/gui/effects/qgraphicseffect.cpp63
-rw-r--r--src/gui/effects/qgraphicseffect.h13
-rw-r--r--src/gui/effects/qgraphicseffect_p.h11
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.cpp185
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.h73
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp168
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h66
-rw-r--r--src/gui/image/qpixmapfilter.cpp51
-rw-r--r--src/gui/image/qpixmapfilter_p.h3
-rw-r--r--src/gui/itemviews/qlistview.cpp6
-rw-r--r--src/gui/kernel/qapplication.cpp18
-rw-r--r--src/gui/kernel/qapplication_p.h5
-rw-r--r--src/gui/kernel/qapplication_qws.cpp3
-rw-r--r--src/gui/kernel/qkeymapper_x11.cpp2
-rw-r--r--src/gui/kernel/qwidget.cpp12
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp21
-rw-r--r--src/gui/painting/qpaintengineex.cpp9
-rw-r--r--src/gui/painting/qpainter.cpp3
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp2
-rw-r--r--src/gui/text/qfontdatabase_win.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp3
-rw-r--r--src/gui/text/qtextengine_p.h1
-rw-r--r--src/gui/text/qtextlayout.cpp3
-rw-r--r--src/gui/widgets/qmenubar.cpp8
-rw-r--r--src/gui/widgets/qmenudata.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp67
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp36
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.cpp8
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp2
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.cpp8
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp2
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadersource_p.h12
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp45
-rw-r--r--src/opengl/qgl.cpp39
-rw-r--r--src/opengl/qgl_mac.mm10
-rw-r--r--src/opengl/qgl_p.h7
-rw-r--r--src/opengl/qgl_qws.cpp13
-rw-r--r--src/opengl/qgl_win.cpp10
-rw-r--r--src/opengl/qgl_wince.cpp13
-rw-r--r--src/opengl/qgl_x11.cpp13
-rw-r--r--src/opengl/qgl_x11egl.cpp13
-rw-r--r--src/opengl/qglpixelbuffer.cpp2
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.cpp3
-rw-r--r--src/sql/models/qsqltablemodel.cpp9
-rw-r--r--src/svg/qsvghandler.cpp94
-rw-r--r--src/svg/qsvghandler_p.h1
-rw-r--r--src/svg/qsvgnode.cpp110
-rw-r--r--src/svg/qsvgnode_p.h6
-rw-r--r--src/svg/qsvgstructure.cpp50
-rw-r--r--src/svg/qsvgstructure_p.h3
-rw-r--r--src/svg/qsvgstyle.cpp4
-rw-r--r--src/svg/qsvgtinydocument.cpp20
-rw-r--r--src/svg/qsvgtinydocument_p.h6
-rw-r--r--src/testlib/qtest_gui.h8
-rw-r--r--src/testlib/qtestevent.h2
-rw-r--r--src/testlib/qtestkeyboard.h2
-rw-r--r--src/testlib/qtestmouse.h2
61 files changed, 846 insertions, 549 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index 5cf86b1..43ef08e 100644
--- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -723,7 +723,7 @@ WebCore::ResourceError FrameLoaderClientQt::cannotShowURLError(const WebCore::Re
WebCore::ResourceError FrameLoaderClientQt::interruptForPolicyChangeError(const WebCore::ResourceRequest& request)
{
return ResourceError("Error", WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(),
- QCoreApplication::translate("QWebFrame", "Frame load interruped by policy change", 0, QCoreApplication::UnicodeUTF8));
+ QCoreApplication::translate("QWebFrame", "Frame load interrupted by policy change", 0, QCoreApplication::UnicodeUTF8));
}
WebCore::ResourceError FrameLoaderClientQt::cannotShowMIMETypeError(const WebCore::ResourceResponse& response)
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
index 389bb48..8c4cc82 100644
--- a/src/corelib/codecs/qiconvcodec.cpp
+++ b/src/corelib/codecs/qiconvcodec.cpp
@@ -62,7 +62,7 @@
#elif defined(Q_OS_AIX)
# define NO_BOM
# define UTF16 "UCS-2"
-#elif defined(Q_OS_MAC)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC)
# define NO_BOM
# if Q_BYTE_ORDER == Q_BIG_ENDIAN
# define UTF16 "UTF-16BE"
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 619c08c..a1f0712 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -125,7 +125,7 @@ static qulonglong qstrtoull(const char *nptr, const char **endptr, register int
#if defined(Q_CC_MWERKS) && defined(Q_OS_WIN32)
inline bool isascii(int c)
{
- return (c >= 0 && c <=127);
+ return (c >= 0 && c <=127);
}
#endif
@@ -1149,6 +1149,23 @@ static QLocale::MeasurementSystem macMeasurementSystem()
}
}
+static void getMacPreferredLanguageAndCountry(QString *language, QString *country)
+{
+ QCFType<CFArrayRef> languages = (CFArrayRef)CFPreferencesCopyValue(
+ CFSTR("AppleLanguages"),
+ kCFPreferencesAnyApplication,
+ kCFPreferencesCurrentUser,
+ kCFPreferencesAnyHost);
+ if (CFArrayGetCount(languages) > 0) {
+ QCFType<CFLocaleRef> locale = CFLocaleCreate(kCFAllocatorDefault,
+ CFStringRef(CFArrayGetValueAtIndex(languages, 0)));
+ if (language)
+ *language = QCFString::toQString(CFStringRef(CFLocaleGetValue(locale, kCFLocaleLanguageCode)));
+ if (country)
+ *country = QCFString::toQString(CFStringRef(CFLocaleGetValue(locale, kCFLocaleCountryCode)));
+ }
+}
+
QLocale QSystemLocale::fallbackLocale() const
{
return QLocale(QString::fromUtf8(getMacLocaleName().constData()));
@@ -1193,9 +1210,16 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
case NegativeSign:
case PositiveSign:
case ZeroDigit:
- case LanguageId:
- case CountryId:
break;
+ case LanguageId:
+ case CountryId: {
+ QString preferredLanguage;
+ QString preferredCountry;
+ getMacPreferredLanguageAndCountry(&preferredLanguage, &preferredCountry);
+ if (type == LanguageId)
+ return codeToLanguage(preferredLanguage.data());
+ return codeToCountry(preferredCountry.data());
+ }
case MeasurementSystem:
return QVariant(static_cast<int>(macMeasurementSystem()));
@@ -7181,8 +7205,8 @@ Q_CORE_EXPORT double qstrtod(const char *s00, const char **se, bool *ok)
double ret = strtod((char*)s00, (char**)se);
if (ok) {
if((ret == 0.0l && errno == ERANGE)
- || ret == HUGE_VAL || ret == -HUGE_VAL)
- *ok = false;
+ || ret == HUGE_VAL || ret == -HUGE_VAL)
+ *ok = false;
else
*ok = true; // the result will be that we don't report underflow in this case
}
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 683a984..26489c5 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -467,12 +467,44 @@ QGraphicsGrayscaleEffect::~QGraphicsGrayscaleEffect()
{
}
+
+/*!
+ \property QGraphicsGrayscaleEffect::strength
+ \brief the strength of the effect.
+
+ By default, the strength is 1.0.
+ A strength 0.0 equals to no effect, while 1.0 means full grayscale.
+*/
+qreal QGraphicsGrayscaleEffect::strength() const
+{
+ Q_D(const QGraphicsGrayscaleEffect);
+ return d->filter->strength();
+}
+
+void QGraphicsGrayscaleEffect::setStrength(qreal strength)
+{
+ Q_D(QGraphicsGrayscaleEffect);
+ if (qFuzzyCompare(d->filter->strength(), strength))
+ return;
+
+ d->filter->setStrength(strength);
+ d->opaque = !qFuzzyIsNull(strength);
+ update();
+ emit strengthChanged(strength);
+}
+
/*!
\reimp
*/
void QGraphicsGrayscaleEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
{
Q_D(QGraphicsGrayscaleEffect);
+
+ if (!d->opaque) {
+ source->draw(painter);
+ return;
+ }
+
QPoint offset;
if (source->isPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
@@ -546,6 +578,31 @@ void QGraphicsColorizeEffect::setColor(const QColor &color)
}
/*!
+ \property QGraphicsColorizeEffect::strength
+ \brief the strength of the effect.
+
+ By default, the strength is 1.0.
+ A strength 0.0 equals to no effect, while 1.0 means full colorization.
+*/
+qreal QGraphicsColorizeEffect::strength() const
+{
+ Q_D(const QGraphicsColorizeEffect);
+ return d->filter->strength();
+}
+
+void QGraphicsColorizeEffect::setStrength(qreal strength)
+{
+ Q_D(QGraphicsColorizeEffect);
+ if (qFuzzyCompare(d->filter->strength(), strength))
+ return;
+
+ d->filter->setStrength(strength);
+ d->opaque = !qFuzzyIsNull(strength);
+ update();
+ emit strengthChanged(strength);
+}
+
+/*!
\fn void QGraphicsColorizeEffect::colorChanged(const QColor &color)
This signal is emitted whenever the effect's color changes.
@@ -558,6 +615,12 @@ void QGraphicsColorizeEffect::setColor(const QColor &color)
void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
{
Q_D(QGraphicsColorizeEffect);
+
+ if (!d->opaque) {
+ source->draw(painter);
+ return;
+ }
+
QPoint offset;
if (source->isPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h
index 5822d8c..5062826 100644
--- a/src/gui/effects/qgraphicseffect.h
+++ b/src/gui/effects/qgraphicseffect.h
@@ -144,13 +144,22 @@ class QGraphicsGrayscaleEffectPrivate;
class Q_GUI_EXPORT QGraphicsGrayscaleEffect: public QGraphicsEffect
{
Q_OBJECT
+ Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
public:
QGraphicsGrayscaleEffect(QObject *parent = 0);
~QGraphicsGrayscaleEffect();
+ qreal strength() const;
+
protected:
void draw(QPainter *painter, QGraphicsEffectSource *source);
+public Q_SLOTS:
+ void setStrength(qreal strength);
+
+Q_SIGNALS:
+ void strengthChanged(qreal strength);
+
private:
Q_DECLARE_PRIVATE(QGraphicsGrayscaleEffect)
Q_DISABLE_COPY(QGraphicsGrayscaleEffect)
@@ -161,17 +170,21 @@ class Q_GUI_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect
{
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
public:
QGraphicsColorizeEffect(QObject *parent = 0);
~QGraphicsColorizeEffect();
QColor color() const;
+ qreal strength() const;
public Q_SLOTS:
void setColor(const QColor &c);
+ void setStrength(qreal strength);
Q_SIGNALS:
void colorChanged(const QColor &color);
+ void strengthChanged(qreal strength);
protected:
void draw(QPainter *painter, QGraphicsEffectSource *source);
diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h
index 4771384..e109790 100644
--- a/src/gui/effects/qgraphicseffect_p.h
+++ b/src/gui/effects/qgraphicseffect_p.h
@@ -113,6 +113,7 @@ class QGraphicsGrayscaleEffectPrivate : public QGraphicsEffectPrivate
Q_DECLARE_PUBLIC(QGraphicsGrayscaleEffect)
public:
QGraphicsGrayscaleEffectPrivate()
+ : opaque(true)
{
filter = new QPixmapColorizeFilter;
filter->setColor(Qt::black);
@@ -120,16 +121,24 @@ public:
~QGraphicsGrayscaleEffectPrivate() { delete filter; }
QPixmapColorizeFilter *filter;
+ quint32 opaque : 1;
+ quint32 padding : 31;
};
class QGraphicsColorizeEffectPrivate : public QGraphicsEffectPrivate
{
Q_DECLARE_PUBLIC(QGraphicsColorizeEffect)
public:
- QGraphicsColorizeEffectPrivate() { filter = new QPixmapColorizeFilter; }
+ QGraphicsColorizeEffectPrivate()
+ : opaque(true)
+ {
+ filter = new QPixmapColorizeFilter;
+ }
~QGraphicsColorizeEffectPrivate() { delete filter; }
QPixmapColorizeFilter *filter;
+ quint32 opaque : 1;
+ quint32 padding : 31;
};
class QGraphicsPixelizeEffectPrivate : public QGraphicsEffectPrivate
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
index c7033c6..f57f65f 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
@@ -84,6 +84,55 @@
QT_BEGIN_NAMESPACE
+QGraphicsAnchor::QGraphicsAnchor(QGraphicsAnchorLayout *parentLayout)
+ : QObject(*(new QGraphicsAnchorPrivate))
+{
+ Q_D(QGraphicsAnchor);
+ Q_ASSERT(parentLayout);
+ d->layoutPrivate = parentLayout->d_func();
+}
+
+/*!
+ Removes the QGraphicsAnchor object from the layout and destroys it.
+*/
+QGraphicsAnchor::~QGraphicsAnchor()
+{
+}
+
+/*!
+ Set the spacing for the anchor to \a spacing.
+
+ \sa spacing(), unsetSpacing()
+*/
+void QGraphicsAnchor::setSpacing(qreal spacing)
+{
+ Q_D(QGraphicsAnchor);
+ d->setSpacing(spacing);
+}
+
+/*!
+ Returns the spacing for the anchor
+
+ \sa setSpacing()
+*/
+qreal QGraphicsAnchor::spacing() const
+{
+ Q_D(const QGraphicsAnchor);
+ return d->spacing();
+}
+
+/*!
+ Resets the spacing of the anchor point to be the default spacing. Depending on the anchor type,
+ the default spacing is either 0 or a value returned from the style.
+
+ \sa setSpacing(), spacing(), QGraphicsAnchorLayout::anchor()
+*/
+void QGraphicsAnchor::unsetSpacing()
+{
+ Q_D(QGraphicsAnchor);
+ d->unsetSpacing();
+}
+
/*!
Constructs a QGraphicsAnchorLayout instance. \a parent is passed to
QGraphicsLayout's constructor.
@@ -136,17 +185,30 @@ QGraphicsAnchorLayout::~QGraphicsAnchorLayout()
* the default vertical spacing). For all other anchor combinations, the spacing will be 0.
* All anchoring functions will follow this rule.
*
- * The spacing can also be set manually by using setAnchorSpacing() method.
+ * The spacing can also be set manually by using QGraphicsAnchor::setSpacing() method.
*
- * \sa removeAnchor(), addCornerAnchors(), addLeftAndRightAnchors(), addTopAndBottomAnchors(),
- * addAllAnchors()
+ * \sa addCornerAnchors(), addAnchors()
*/
-void QGraphicsAnchorLayout::addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)
+QGraphicsAnchor *
+QGraphicsAnchorLayout::addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)
{
Q_D(QGraphicsAnchorLayout);
- d->anchor(firstItem, firstEdge, secondItem, secondEdge);
+ QGraphicsAnchor *a = d->anchor(firstItem, firstEdge, secondItem, secondEdge);
invalidate();
+ return a;
+}
+
+/*!
+ Returns the anchor between the anchor points defined by \a firstItem and \a firstEdge and
+ \a secondItem and \a secondEdge. If there is no such anchor, the function will return 0.
+*/
+QGraphicsAnchor *
+QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)
+{
+ Q_D(QGraphicsAnchorLayout);
+ return d->getAnchor(firstItem, firstEdge, secondItem, secondEdge);
}
/*!
@@ -195,6 +257,37 @@ void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem,
}
/*!
+ Anchors two or four edges of \a firstItem with the corresponding edges of \secondItem,
+ so that \a firstItem has the same size as \a secondItem in the dimensions specified by
+ \a orientation.
+
+ Calling this convenience function with the following arguments
+ \code
+ l->addAnchors(firstItem, secondItem, Qt::Horizontal)
+ \endcode
+
+ is the same as
+
+ \code
+ l->addAnchor(firstItem, Qt::AnchorLeft, secondItem, Qt::AnchorLeft);
+ l->addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
+ \endcode
+*/
+void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem,
+ Qt::Orientations orientations)
+{
+ if (orientations & Qt::Horizontal) {
+ addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft);
+ addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
+ }
+ if (orientations & Qt::Vertical) {
+ addAnchor(secondItem, Qt::AnchorTop, firstItem, Qt::AnchorTop);
+ addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom);
+ }
+}
+
+/*!
\fn QGraphicsAnchorLayout::addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem)
Anchors the left and right edges of \a firstItem to the same edges of
@@ -234,86 +327,6 @@ void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem,
*/
/*!
- Set the spacing between the anchor point defined by \a firstItem and \a firstEdge and
- \a secondItem and \a secondEdge to be \a spacing.
-*/
-void QGraphicsAnchorLayout::setAnchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge,
- qreal spacing)
-{
- Q_D(QGraphicsAnchorLayout);
-
- if (!d->setAnchorSize(firstItem, firstEdge, secondItem, secondEdge, &spacing)) {
- qWarning("setAnchorSpacing: The anchor does not exist.");
- return;
- }
- invalidate();
-}
-
-/*!
- Returns the spacing between the anchor point defined by \a firstItem and \a firstEdge and
- \a secondItem and \a secondEdge. The anchor must exist.
-*/
-qreal QGraphicsAnchorLayout::anchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge) const
-{
- Q_D(const QGraphicsAnchorLayout);
- qreal size = 0;
- if (!d->anchorSize(firstItem, firstEdge, secondItem, secondEdge, 0, &size)) {
- qWarning("anchorSpacing: The anchor does not exist.");
- }
- return size;
-}
-
-/*!
- Resets the spacing between the anchor point defined by \a firstItem and \a firstEdge and
- \a secondItem and \a secondEdge to be the default spacing. Depending on the anchor type, the
- default spacing is either 0 or a value returned from the style.
-
- \sa setAnchorSpacing(), anchorSpacing(), addAnchor()
-*/
-void QGraphicsAnchorLayout::unsetAnchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)
-{
- Q_D(QGraphicsAnchorLayout);
-
- if (!d->setAnchorSize(firstItem, firstEdge, secondItem, secondEdge, 0)) {
- qWarning("unsetAnchorSpacing: The anchor does not exist.");
- }
- invalidate();
-}
-
-/*!
- Removes the anchor between the edge \a firstEdge of item \a firstItem and the edge \a secondEdge
- of item \a secondItem. If such an anchor does not exist, the layout will be left unchanged.
-*/
-void QGraphicsAnchorLayout::removeAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)
-{
- Q_D(QGraphicsAnchorLayout);
- if ((firstItem == 0) || (secondItem == 0)) {
- qWarning("QGraphicsAnchorLayout::removeAnchor: "
- "Cannot remove anchor between NULL items");
- return;
- }
-
- if (firstItem == secondItem) {
- qWarning("QGraphicsAnchorLayout::removeAnchor: "
- "Cannot remove anchor from the item to itself");
- return;
- }
-
- if (d->edgeOrientation(secondEdge) != d->edgeOrientation(firstEdge)) {
- qWarning("QGraphicsAnchorLayout::removeAnchor: "
- "Cannot remove anchor from edges of different orientations");
- return;
- }
-
- d->removeAnchor(firstItem, firstEdge, secondItem, secondEdge);
- invalidate();
-}
-
-/*!
Sets the default horizontal spacing for the anchor layout to \a spacing.
\sa horizontalSpacing(), setVerticalSpacing(), setSpacing()
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h
index 70b73ef..d9a87ba 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.h
@@ -54,41 +54,44 @@ QT_MODULE(Gui)
#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+class QGraphicsAnchorPrivate;
+class QGraphicsAnchorLayout;
class QGraphicsAnchorLayoutPrivate;
+class Q_GUI_EXPORT QGraphicsAnchor : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing)
+public:
+ void setSpacing(qreal spacing);
+ void unsetSpacing();
+ qreal spacing() const;
+ ~QGraphicsAnchor();
+private:
+ QGraphicsAnchor(QGraphicsAnchorLayout *parent);
+
+ Q_DECLARE_PRIVATE(QGraphicsAnchor)
+
+ friend class QGraphicsAnchorLayoutPrivate;
+};
+
class Q_GUI_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout
{
public:
QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = 0);
virtual ~QGraphicsAnchorLayout();
- void addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
+ QGraphicsAnchor *addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
+ QGraphicsAnchor *anchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
void addCornerAnchors(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner,
QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner);
- inline void addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem,
- QGraphicsLayoutItem *secondItem);
-
- inline void addTopAndBottomAnchors(QGraphicsLayoutItem *firstItem,
- QGraphicsLayoutItem *secondItem);
-
- inline void addAllAnchors(QGraphicsLayoutItem *firstItem,
- QGraphicsLayoutItem *secondItem);
-
- void setAnchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge,
- qreal spacing);
-
- qreal anchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge) const;
-
- void unsetAnchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
-
- void removeAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
+ void addAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem,
+ Qt::Orientations orientations = Qt::Horizontal | Qt::Vertical);
void setHorizontalSpacing(qreal spacing);
void setVerticalSpacing(qreal spacing);
@@ -108,29 +111,9 @@ protected:
private:
Q_DISABLE_COPY(QGraphicsAnchorLayout)
Q_DECLARE_PRIVATE(QGraphicsAnchorLayout)
-};
-
-void QGraphicsAnchorLayout::addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem,
- QGraphicsLayoutItem *secondItem)
-{
- addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft);
- addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
-}
-
-void QGraphicsAnchorLayout::addTopAndBottomAnchors(QGraphicsLayoutItem *firstItem,
- QGraphicsLayoutItem *secondItem)
-{
- addAnchor(secondItem, Qt::AnchorTop, firstItem, Qt::AnchorTop);
- addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom);
-}
-
-void QGraphicsAnchorLayout::addAllAnchors(QGraphicsLayoutItem *firstItem,
- QGraphicsLayoutItem *secondItem)
-{
- addLeftAndRightAnchors(firstItem, secondItem);
- addTopAndBottomAnchors(firstItem, secondItem);
-}
+ friend class QGraphicsAnchor;
+};
#endif
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index f81ede0..a37ec96 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -51,6 +51,47 @@
QT_BEGIN_NAMESPACE
+
+QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version)
+ : QObjectPrivate(version), layoutPrivate(0), data(0)
+{
+}
+
+QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate()
+{
+ layoutPrivate->deleteAnchorData(data);
+}
+
+void QGraphicsAnchorPrivate::setSpacing(qreal value)
+{
+ if (data) {
+ layoutPrivate->setAnchorSize(data, &value);
+ } else {
+ qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
+ }
+}
+
+void QGraphicsAnchorPrivate::unsetSpacing()
+{
+ if (data) {
+ layoutPrivate->setAnchorSize(data, 0);
+ } else {
+ qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
+ }
+}
+
+qreal QGraphicsAnchorPrivate::spacing() const
+{
+ qreal size = 0;
+ if (data) {
+ layoutPrivate->anchorSize(data, 0, &size, 0);
+ } else {
+ qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
+ }
+ return size;
+}
+
+
void AnchorData::refreshSizeHints(qreal effectiveSpacing)
{
if (!isLayoutAnchor && from->m_item == to->m_item) {
@@ -998,29 +1039,29 @@ void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem *
* Helper function that is called from the anchor functions in the public API.
* If \a spacing is 0, it will pick up the spacing defined by the style.
*/
-void QGraphicsAnchorLayoutPrivate::anchor(QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
- qreal *spacing)
+QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::anchor(QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge,
+ qreal *spacing)
{
Q_Q(QGraphicsAnchorLayout);
if ((firstItem == 0) || (secondItem == 0)) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor NULL items");
- return;
+ return 0;
}
if (firstItem == secondItem) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor the item to itself");
- return;
+ return 0;
}
if (edgeOrientation(secondEdge) != edgeOrientation(firstEdge)) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor edges of different orientations");
- return;
+ return 0;
}
// Guarantee that the graph is no simplified when adding this anchor,
@@ -1079,6 +1120,7 @@ void QGraphicsAnchorLayoutPrivate::anchor(QGraphicsLayoutItem *firstItem,
data = new AnchorData(-*spacing);
addAnchor(secondItem, secondEdge, firstItem, firstEdge, data);
}
+ return acquireGraphicsAnchor(data);
}
void QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *firstItem,
@@ -1117,77 +1159,97 @@ void QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *firstItem,
graph[edgeOrientation(firstEdge)].createEdge(v1, v2, data);
}
+QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge)
+{
+ Orientation orient = edgeOrientation(firstEdge);
+ restoreSimplifiedGraph(orient);
+
+ AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
+ AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
+
+ QGraphicsAnchor *graphicsAnchor = 0;
+
+ AnchorData *data = graph[orient].edgeData(v1, v2);
+ if (data)
+ graphicsAnchor = acquireGraphicsAnchor(data);
+ return graphicsAnchor;
+}
+
void QGraphicsAnchorLayoutPrivate::removeAnchor(QGraphicsLayoutItem *firstItem,
Qt::AnchorPoint firstEdge,
QGraphicsLayoutItem *secondItem,
Qt::AnchorPoint secondEdge)
{
- // Guarantee that the graph is no simplified when adding this anchor,
- // anchor manipulation always happen in the full graph
- restoreSimplifiedGraph(edgeOrientation(firstEdge));
-
- // Look for both vertices
- AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
- AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
+ removeAnchor_helper(internalVertex(firstItem, firstEdge),
+ internalVertex(secondItem, secondEdge));
+}
+void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2)
+{
Q_ASSERT(v1 && v2);
+ // Guarantee that the graph is no simplified when removing this anchor,
+ // anchor manipulation always happen in the full graph
+ Orientation o = edgeOrientation(v1->m_edge);
+ restoreSimplifiedGraph(o);
// Remove edge from graph
- graph[edgeOrientation(firstEdge)].removeEdge(v1, v2);
+ graph[o].removeEdge(v1, v2);
// Decrease vertices reference count (may trigger a deletion)
- removeInternalVertex(firstItem, firstEdge);
- removeInternalVertex(secondItem, secondEdge);
+ removeInternalVertex(v1->m_item, v1->m_edge);
+ removeInternalVertex(v2->m_item, v2->m_edge);
}
-bool QGraphicsAnchorLayoutPrivate::setAnchorSize(const QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
- const qreal *anchorSize)
+/*!
+ \internal
+ Only called from outside. (calls invalidate())
+*/
+void QGraphicsAnchorLayoutPrivate::deleteAnchorData(AnchorData *data)
{
+ Q_Q(QGraphicsAnchorLayout);
+ removeAnchor_helper(data->from, data->to);
+ q->invalidate();
+}
+
+/*!
+ \internal
+ Only called from outside. (calls invalidate())
+*/
+void QGraphicsAnchorLayoutPrivate::setAnchorSize(AnchorData *data, const qreal *anchorSize)
+{
+ Q_Q(QGraphicsAnchorLayout);
// ### we can avoid restoration if we really want to, but we would have to
// search recursively through all composite anchors
- restoreSimplifiedGraph(edgeOrientation(firstEdge));
- AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
- AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
-
- AnchorData *data = graph[edgeOrientation(firstEdge)].edgeData(v1, v2);
- if (data) {
- if (anchorSize) {
- data->setFixedSize(*anchorSize);
- } else {
- data->unsetSize();
- }
+ Q_ASSERT(data);
+ restoreSimplifiedGraph(edgeOrientation(data->from->m_edge));
+ if (anchorSize) {
+ data->setFixedSize(*anchorSize);
+ } else {
+ data->unsetSize();
}
- return data;
+ q->invalidate();
}
-bool QGraphicsAnchorLayoutPrivate::anchorSize(const QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
+void QGraphicsAnchorLayoutPrivate::anchorSize(const AnchorData *data,
qreal *minSize,
qreal *prefSize,
qreal *maxSize) const
{
Q_ASSERT(minSize || prefSize || maxSize);
+ Q_ASSERT(data);
QGraphicsAnchorLayoutPrivate *that = const_cast<QGraphicsAnchorLayoutPrivate *>(this);
- that->restoreSimplifiedGraph(edgeOrientation(firstEdge));
- AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
- AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
-
- AnchorData *data = that->graph[edgeOrientation(firstEdge)].edgeData(v1, v2);
- if (data) {
- if (minSize)
- *minSize = data->minSize;
- if (prefSize)
- *prefSize = data->prefSize;
- if (maxSize)
- *maxSize = data->maxSize;
- }
- return data;
+ that->restoreSimplifiedGraph(edgeOrientation(data->from->m_edge));
+
+ if (minSize)
+ *minSize = data->minSize;
+ if (prefSize)
+ *prefSize = data->prefSize;
+ if (maxSize)
+ *maxSize = data->maxSize;
}
AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item,
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 31da1a1..f701c3f 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -54,6 +54,7 @@
//
#include <QGraphicsWidget>
+#include <private/qobject_p.h>
#include "qgraphicslayout_p.h"
#include "qgraphicsanchorlayout.h"
@@ -153,6 +154,7 @@ struct AnchorData : public QSimplexVariable {
minSize(minimumSize), prefSize(preferredSize),
maxSize(maximumSize), sizeAtMinimum(preferredSize),
sizeAtPreferred(preferredSize), sizeAtMaximum(preferredSize),
+ graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(true),
isLayoutAnchor(false) {}
@@ -160,6 +162,7 @@ struct AnchorData : public QSimplexVariable {
: QSimplexVariable(), from(0), to(0),
minSize(size), prefSize(size), maxSize(size),
sizeAtMinimum(size), sizeAtPreferred(size), sizeAtMaximum(size),
+ graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(true),
isLayoutAnchor(false) {}
@@ -167,6 +170,7 @@ struct AnchorData : public QSimplexVariable {
: QSimplexVariable(), from(0), to(0),
minSize(0), prefSize(0), maxSize(0),
sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMaximum(0),
+ graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(false),
isLayoutAnchor(false) {}
@@ -215,6 +219,7 @@ struct AnchorData : public QSimplexVariable {
qreal sizeAtMinimum;
qreal sizeAtPreferred;
qreal sizeAtMaximum;
+ QGraphicsAnchor *graphicsAnchor;
uint skipInPreferred : 1;
uint type : 2; // either Normal, Sequential or Parallel
@@ -226,6 +231,7 @@ protected:
minSize(size), prefSize(size),
maxSize(size), sizeAtMinimum(size),
sizeAtPreferred(size), sizeAtMaximum(size),
+ graphicsAnchor(0),
skipInPreferred(0), type(type), hasSize(true),
isLayoutAnchor(false) {}
};
@@ -309,6 +315,28 @@ public:
QSet<AnchorData *> negatives;
};
+class QGraphicsAnchorLayoutPrivate;
+/*!
+ \internal
+*/
+class QGraphicsAnchorPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsAnchor)
+
+public:
+ explicit QGraphicsAnchorPrivate(int version = QObjectPrivateVersion);
+ ~QGraphicsAnchorPrivate();
+
+ void setSpacing(qreal value);
+ void unsetSpacing();
+ qreal spacing() const;
+
+ QGraphicsAnchorLayoutPrivate *layoutPrivate;
+ AnchorData *data;
+};
+
+
+
/*!
\internal
@@ -365,12 +393,22 @@ public:
void removeCenterAnchors(QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge, bool substitute = true);
void removeCenterConstraints(QGraphicsLayoutItem *item, Orientation orientation);
+ QGraphicsAnchor *acquireGraphicsAnchor(AnchorData *data)
+ {
+ Q_Q(QGraphicsAnchorLayout);
+ if (!data->graphicsAnchor) {
+ data->graphicsAnchor = new QGraphicsAnchor(q);
+ data->graphicsAnchor->d_func()->data = data;
+ }
+ return data->graphicsAnchor;
+ }
+
// helper function used by the 4 API functions
- void anchor(QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
- qreal *spacing = 0);
+ QGraphicsAnchor *anchor(QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge,
+ qreal *spacing = 0);
// Anchor Manipulation methods
void addAnchor(QGraphicsLayoutItem *firstItem,
@@ -379,21 +417,17 @@ public:
Qt::AnchorPoint secondEdge,
AnchorData *data);
+ QGraphicsAnchor *getAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
+
void removeAnchor(QGraphicsLayoutItem *firstItem,
Qt::AnchorPoint firstEdge,
QGraphicsLayoutItem *secondItem,
Qt::AnchorPoint secondEdge);
-
- bool setAnchorSize(const QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
- const qreal *anchorSize);
-
- bool anchorSize(const QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
+ void removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2);
+ void deleteAnchorData(AnchorData *data);
+ void setAnchorSize(AnchorData *data, const qreal *anchorSize);
+ void anchorSize(const AnchorData *data,
qreal *minSize = 0,
qreal *prefSize = 0,
qreal *maxSize = 0) const;
diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
index 15704ba..4fa2e6c 100644
--- a/src/gui/image/qpixmapfilter.cpp
+++ b/src/gui/image/qpixmapfilter.cpp
@@ -759,6 +759,10 @@ class QPixmapColorizeFilterPrivate : public QPixmapFilterPrivate
Q_DECLARE_PUBLIC(QPixmapColorizeFilter)
public:
QColor color;
+ qreal strength;
+ quint32 opaque : 1;
+ quint32 alphaBlend : 1;
+ quint32 padding : 30;
};
/*!
@@ -771,7 +775,11 @@ public:
QPixmapColorizeFilter::QPixmapColorizeFilter(QObject *parent)
: QPixmapFilter(*new QPixmapColorizeFilterPrivate, ColorizeFilter, parent)
{
- d_func()->color = QColor(0, 0, 192);
+ Q_D(QPixmapColorizeFilter);
+ d->color = QColor(0, 0, 192);
+ d->strength = qreal(1);
+ d->opaque = true;
+ d->alphaBlend = false;
}
/*!
@@ -797,6 +805,31 @@ void QPixmapColorizeFilter::setColor(const QColor &color)
}
/*!
+ Gets the strength of the colorize filter, 1.0 means full colorized while
+ 0.0 equals to no filtering at all.
+
+ \internal
+*/
+qreal QPixmapColorizeFilter::strength() const
+{
+ Q_D(const QPixmapColorizeFilter);
+ return d->strength;
+}
+
+/*!
+ Sets the strength of the colorize filter to \a strength.
+
+ \internal
+*/
+void QPixmapColorizeFilter::setStrength(qreal strength)
+{
+ Q_D(QPixmapColorizeFilter);
+ d->strength = qBound(qreal(0), strength, qreal(1));
+ d->opaque = !qFuzzyIsNull(d->strength);
+ d->alphaBlend = !qFuzzyIsNull(d->strength - 1);
+}
+
+/*!
\internal
*/
void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
@@ -807,6 +840,7 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q
QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter);
if (colorizeFilter) {
colorizeFilter->setColor(d->color);
+ colorizeFilter->setStrength(d->strength);
colorizeFilter->draw(painter, dest, src, srcRect);
delete colorizeFilter;
return;
@@ -814,6 +848,11 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q
// falling back to raster implementation
+ if (!d->opaque) {
+ painter->drawPixmap(dest, src, srcRect);
+ return;
+ }
+
QImage srcImage;
QImage destImage;
@@ -836,6 +875,16 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q
destPainter.fillRect(srcImage.rect(), d->color);
destPainter.end();
+ if (d->alphaBlend) {
+ // alpha blending srcImage and destImage
+ QImage buffer = srcImage;
+ QPainter bufPainter(&buffer);
+ bufPainter.setOpacity(d->strength);
+ bufPainter.drawImage(0, 0, destImage);
+ bufPainter.end();
+ destImage = buffer;
+ }
+
if (srcImage.hasAlphaChannel())
destImage.setAlphaChannel(srcImage.alphaChannel());
diff --git a/src/gui/image/qpixmapfilter_p.h b/src/gui/image/qpixmapfilter_p.h
index 4cbf7a3..2565110 100644
--- a/src/gui/image/qpixmapfilter_p.h
+++ b/src/gui/image/qpixmapfilter_p.h
@@ -155,6 +155,9 @@ public:
void setColor(const QColor& color);
QColor color() const;
+ void setStrength(qreal strength);
+ qreal strength() const;
+
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
};
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index cbb54d8..a4cebe3 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -965,6 +965,12 @@ void QListView::paintEvent(QPaintEvent *e)
for (QVector<QModelIndex>::const_iterator it = toBeRendered.constBegin(); it != end; ++it) {
Q_ASSERT((*it).isValid());
option.rect = visualRect(*it);
+
+ if (flow() == TopToBottom)
+ option.rect.setWidth(qMin(viewport()->size().width(), option.rect.width()));
+ else
+ option.rect.setHeight(qMin(viewport()->size().height(), option.rect.height()));
+
option.state = state;
if (selections && selections->isSelected(*it))
option.state |= QStyle::State_Selected;
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 300e519..a19e022 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -469,12 +469,18 @@ QWidget *QApplicationPrivate::oldEditFocus = 0;
bool qt_tabletChokeMouse = false;
static bool force_reverse = false;
-static inline bool isAlien(QWidget *widget)
+inline bool QApplicationPrivate::isAlien(QWidget *widget)
{
if (!widget)
return false;
-#ifdef Q_WS_MAC // Fake alien behavior on the Mac :)
+#if defined(Q_WS_MAC) // Fake alien behavior on the Mac :)
return !widget->isWindow() && widget->window()->testAttribute(Qt::WA_DontShowOnScreen);
+#elif defined(Q_WS_QWS)
+ return !widget->isWindow()
+# ifdef Q_BACKINGSTORE_SUBSURFACES
+ && !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface)
+# endif
+ ;
#else
return !widget->internalWinId();
#endif
@@ -2974,7 +2980,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
return result;
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS)
/*
This function should only be called when the widget changes visibility, i.e.
when the \a widget is shown, hidden or deleted. This function does nothing
@@ -2986,9 +2992,13 @@ extern QWidget *qt_button_down;
void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
{
#ifndef QT_NO_CURSOR
+#ifdef Q_WS_QWS
+ if (!widget || widget->isWindow())
+ return;
+#else
if (!widget || widget->internalWinId() || widget->isWindow())
return;
-
+#endif
const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor;
if (!widgetInShow && widget != qt_last_mouse_receiver)
return; // Widget was not under the cursor when it was hidden/deleted.
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index c027763..c33eb1a 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -513,7 +513,7 @@ public:
#ifdef Q_OS_SYMBIAN
static TUint resolveS60ScanCode(TInt scanCode, TUint keysym);
#endif
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
void sendSyntheticEnterLeave(QWidget *widget);
#endif
@@ -586,6 +586,9 @@ private:
Qt::FocusPolicy focusPolicy,
Qt::FocusReason focusReason);
static bool shouldSetFocus(QWidget *w, Qt::FocusPolicy policy);
+
+
+ static bool isAlien(QWidget *);
};
Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index e6bfd28..e9284f7 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -430,6 +430,7 @@ static QWidget *popupOfPopupButtonFocus = 0;
static bool popupCloseDownMode = false;
static bool popupGrabOk;
static QPointer<QWidget> *mouseInWidget = 0;
+QPointer<QWidget> qt_last_mouse_receiver = 0;
static bool sm_blockUserInput = false; // session management
@@ -3523,10 +3524,12 @@ bool QETWidget::translateMouseEvent(const QWSMouseEvent *event, int prevstate)
if (widget != (*mouseInWidget)) {
QApplicationPrivate::dispatchEnterLeave(widget, *mouseInWidget);
(*mouseInWidget) = widget;
+ qt_last_mouse_receiver = widget;
}
QApplication::sendSpontaneousEvent(widget, &e);
if (leaveAfterRelease && !QWidget::mouseGrabber()) {
*mouseInWidget = QApplication::widgetAt(globalPos);
+ qt_last_mouse_receiver = *mouseInWidget;
QApplicationPrivate::dispatchEnterLeave(*mouseInWidget, leaveAfterRelease);
leaveAfterRelease = 0;
}
diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp
index 488cc6a..0ce77fe 100644
--- a/src/gui/kernel/qkeymapper_x11.cpp
+++ b/src/gui/kernel/qkeymapper_x11.cpp
@@ -536,7 +536,7 @@ void QKeyMapperPrivate::clearMappings()
coreDesc.keysyms_per_keycode = 0;
coreDesc.keysyms = XGetKeyboardMapping(X11->display,
coreDesc.min_keycode,
- coreDesc.max_keycode - coreDesc.min_keycode,
+ coreDesc.max_keycode - coreDesc.min_keycode + 1,
&coreDesc.keysyms_per_keycode);
#if 0
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index fd44d78..fd89cb9 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1442,9 +1442,13 @@ QWidget::~QWidget()
}
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
else if (!internalWinId() && isVisible()) {
qApp->d_func()->sendSyntheticEnterLeave(this);
+#ifdef Q_WS_QWS
+ } else if (isVisible()) {
+ qApp->d_func()->sendSyntheticEnterLeave(this);
+#endif
}
#endif
@@ -7181,7 +7185,7 @@ void QWidgetPrivate::hide_helper()
// next bit tries to move the focus if the focus widget is now
// hidden.
if (wasVisible) {
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
qApp->d_func()->sendSyntheticEnterLeave(q);
#endif
@@ -7313,7 +7317,7 @@ void QWidget::setVisible(bool visible)
d->show_helper();
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
qApp->d_func()->sendSyntheticEnterLeave(this);
#endif
}
@@ -7428,7 +7432,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
widget->d_func()->hide_sys();
}
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
qApp->d_func()->sendSyntheticEnterLeave(widget);
#endif
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 46a3362..bac0a76 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -114,7 +114,7 @@ extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); //
// #define QT_DEBUG_DRAW
#ifdef QT_DEBUG_DRAW
-void dumpClip(int width, int height, QClipData *clip);
+void dumpClip(int width, int height, const QClipData *clip);
#endif
#define QT_FAST_SPANS
@@ -495,7 +495,7 @@ bool QRasterPaintEngine::begin(QPaintDevice *device)
<< ") devType:" << device->devType()
<< "devRect:" << d->deviceRect;
if (d->baseClip) {
- dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), d->baseClip);
+ dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->baseClip);
}
#endif
@@ -534,7 +534,7 @@ bool QRasterPaintEngine::end()
Q_D(QRasterPaintEngine);
qDebug() << "QRasterPaintEngine::end devRect:" << d->deviceRect;
if (d->baseClip) {
- dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), d->baseClip);
+ dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->baseClip);
}
#endif
@@ -1181,6 +1181,11 @@ static void qrasterpaintengine_dirty_clip(QRasterPaintEnginePrivate *d, QRasterP
d->solid_color_filler.clip = d->clip();
d->solid_color_filler.adjustSpanMethods();
+
+#ifdef QT_DEBUG_DRAW
+ dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->clip());
+#endif
+
}
@@ -1780,9 +1785,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
if (path.isEmpty())
return;
#ifdef QT_DEBUG_DRAW
- QRealRect vectorPathBounds = path.controlPointRect();
- QRectF rf(vectorPathBounds.x1, vectorPathBounds.y1,
- vectorPathBounds.x2 - vectorPathBounds.x1, vectorPathBounds.y2 - vectorPathBounds.y1);
+ QRectF rf = path.controlPointRect();
qDebug() << "QRasterPaintEngine::fill(): "
<< "size=" << path.elementCount()
<< ", hints=" << hex << path.hints()
@@ -6068,7 +6071,7 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
*/
#ifdef QT_DEBUG_DRAW
-void dumpClip(int width, int height, QClipData *clip)
+void dumpClip(int width, int height, const QClipData *clip)
{
QImage clipImg(width, height, QImage::Format_ARGB32_Premultiplied);
clipImg.fill(0xffff0000);
@@ -6078,8 +6081,10 @@ void dumpClip(int width, int height, QClipData *clip)
int y0 = height;
int y1 = 0;
+ ((QClipData *) clip)->spans(); // Force allocation of the spans structure...
+
for (int i = 0; i < clip->count; ++i) {
- QSpan *span = clip->spans() + i;
+ const QSpan *span = ((QClipData *) clip)->spans() + i;
for (int j = 0; j < span->len; ++j)
clipImg.setPixel(span->x + j, span->y, 0xffffff00);
x0 = qMin(x0, int(span->x));
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index e75240c..656f383 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -535,8 +535,13 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
void QPaintEngineEx::draw(const QVectorPath &path)
{
- fill(path, state()->brush);
- stroke(path, state()->pen);
+ const QBrush &brush = state()->brush;
+ if (qbrush_style(brush) != Qt::NoBrush)
+ fill(path, brush);
+
+ const QPen &pen = state()->pen;
+ if (qpen_style(pen) != Qt::NoPen && qbrush_style(qpen_brush(pen)) != Qt::NoBrush)
+ stroke(path, pen);
}
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index a9257c7..beda9d6 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -475,7 +475,8 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
p.end();
q->save();
- q->resetMatrix();
+ state->matrix = QTransform();
+ state->dirtyFlags |= QPaintEngine::DirtyTransform;
updateState(state);
engine->drawImage(absPathRect,
image,
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 5645950..0dc1832 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -586,7 +586,7 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels)
}
register unsigned int alphaValue = (*buffer) & 0xFF000000;
if (alphaValue == 0xFF000000) {
- *buffer &= 0x00FFFFFF;
+ *buffer = 0;
valueChange = true;
} else if (alphaValue == 0) {
*buffer |= 0xFF000000;
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index 6b874af..ae26dab 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -471,7 +471,7 @@ static void initializeDb()
// print the database
for (int f = 0; f < db->count; f++) {
QtFontFamily *family = db->families[f];
- qDebug(" %s: %p", family->name.latin1(), family);
+ qDebug(" %s: %p", qPrintable(family->name), family);
populate_database(family->name);
#if 0
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 88837ca..b43bd06 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1645,7 +1645,8 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const
glyph_t glyph = glyphs.glyphs[logClusters[pos + ilen - 1]];
glyph_metrics_t gi = fe->boundingBox(glyph);
- gm.width -= qRound(gi.xoff - gi.x - gi.width);
+ if (gi.isValid())
+ gm.width -= qRound(gi.xoff - gi.x - gi.width);
}
}
return gm;
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 28ac7d9..85c6928 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -110,6 +110,7 @@ struct glyph_metrics_t
QFixed yoff;
glyph_metrics_t transformed(const QTransform &xform) const;
+ inline bool isValid() const {return x != 100000 && y != 100000;}
};
Q_DECLARE_TYPEINFO(glyph_metrics_t, Q_PRIMITIVE_TYPE);
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 62795f8..f8b0cbc 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1807,7 +1807,8 @@ void QTextLine::layout_helper(int maxGlyphs)
QFontEngine *fontEngine = eng->fontEngine(current);
glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]];
glyph_metrics_t gi = fontEngine->boundingBox(glyph);
- lbh.rightBearing = -qRound(gi.xoff - gi.x - gi.width);
+ if (gi.isValid())
+ lbh.rightBearing = -qRound(gi.xoff - gi.x - gi.width);
}
if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) {
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index d5a7982..7b0f37e 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -1252,11 +1252,11 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
void QMenuBar::mouseMoveEvent(QMouseEvent *e)
{
Q_D(QMenuBar);
- bool popupState = d->popupState || e->buttons() & Qt::LeftButton;
- if (!d->mouseDown || !popupState)
- return;
+ if (!(e->buttons() & Qt::LeftButton))
+ d->mouseDown = false;
+ bool popupState = d->popupState || d->mouseDown;
QAction *action = d->actionAt(e->pos());
- if (action && d->isVisible(action))
+ if ((action && d->isVisible(action)) || !popupState)
d->setCurrentAction(action, popupState);
}
diff --git a/src/gui/widgets/qmenudata.h b/src/gui/widgets/qmenudata.h
index 69f0cbc..c9d8b47 100644
--- a/src/gui/widgets/qmenudata.h
+++ b/src/gui/widgets/qmenudata.h
@@ -68,7 +68,7 @@ private:
void setId(int);
void setSignalValue(int);
- Q_DISABLE_COPY(QMenuItem);
+ Q_DISABLE_COPY(QMenuItem)
};
QT_END_NAMESPACE
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
index 4ed1b41..c944cf0 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
@@ -81,13 +81,18 @@ QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const
nearest.setByteOrder(QAudioFormat::LittleEndian);
nearest.setSampleType(QAudioFormat::SignedInt);
nearest.setSampleSize(16);
- nearest.setCodec(tr("audio/pcm"));
+ nearest.setCodec(QLatin1String("audio/pcm"));
} else {
nearest.setFrequency(8000);
nearest.setChannels(1);
- nearest.setSampleType(QAudioFormat::SignedInt);
+ nearest.setSampleType(QAudioFormat::UnSignedInt);
nearest.setSampleSize(8);
- nearest.setCodec(tr("audio/pcm"));
+ nearest.setCodec(QLatin1String("audio/pcm"));
+ if(!testSettings(nearest)) {
+ nearest.setChannels(2);
+ nearest.setSampleSize(16);
+ nearest.setSampleType(QAudioFormat::SignedInt);
+ }
}
return nearest;
}
@@ -145,9 +150,9 @@ bool QAudioDeviceInfoPrivate::open()
{
int err = 0;
QString dev = device;
- if(!dev.contains(tr("default"))) {
+ if(!dev.contains(QLatin1String("default"))) {
int idx = snd_card_get_index(dev.toLocal8Bit().constData());
- dev = QString(tr("hw:%1,0")).arg(idx);
+ dev = QString(QLatin1String("hw:%1,0")).arg(idx);
}
if(mode == QAudio::AudioOutput) {
err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0);
@@ -172,16 +177,15 @@ bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const
{
// Set nearest to closest settings that do work.
// See if what is in settings will work (return value).
-
int err = 0;
snd_pcm_t* handle;
snd_pcm_hw_params_t *params;
QString dev = device;
// open()
- if(!dev.contains(tr("default"))) {
+ if(!dev.contains(QLatin1String("default"))) {
int idx = snd_card_get_index(dev.toLocal8Bit().constData());
- dev = QString(tr("hw:%1,0")).arg(idx);
+ dev = QString(QLatin1String("hw:%1,0")).arg(idx);
}
if(mode == QAudio::AudioOutput) {
err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0);
@@ -205,8 +209,45 @@ bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const
snd_pcm_hw_params_alloca( &params );
snd_pcm_hw_params_any( handle, params );
+ // set the values!
+ snd_pcm_hw_params_set_channels(handle,params,format.channels());
+ snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir);
+ switch(format.sampleSize()) {
+ case 8:
+ if(format.sampleType() == QAudioFormat::SignedInt)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8);
+ else if(format.sampleType() == QAudioFormat::UnSignedInt)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8);
+ break;
+ case 16:
+ if(format.sampleType() == QAudioFormat::SignedInt) {
+ if(format.byteOrder() == QAudioFormat::LittleEndian)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE);
+ else if(format.byteOrder() == QAudioFormat::BigEndian)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE);
+ } else if(format.sampleType() == QAudioFormat::UnSignedInt) {
+ if(format.byteOrder() == QAudioFormat::LittleEndian)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE);
+ else if(format.byteOrder() == QAudioFormat::BigEndian)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE);
+ }
+ break;
+ case 32:
+ if(format.sampleType() == QAudioFormat::SignedInt) {
+ if(format.byteOrder() == QAudioFormat::LittleEndian)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE);
+ else if(format.byteOrder() == QAudioFormat::BigEndian)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE);
+ } else if(format.sampleType() == QAudioFormat::UnSignedInt) {
+ if(format.byteOrder() == QAudioFormat::LittleEndian)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE);
+ else if(format.byteOrder() == QAudioFormat::BigEndian)
+ snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE);
+ }
+ }
+
// For now, just accept only audio/pcm codec
- if(!format.codec().startsWith(tr("audio/pcm"))) {
+ if(!format.codec().startsWith(QLatin1String("audio/pcm"))) {
err=-1;
} else
testCodec = true;
@@ -313,7 +354,7 @@ void QAudioDeviceInfoPrivate::updateLists()
typez.append(QAudioFormat::SignedInt);
typez.append(QAudioFormat::UnSignedInt);
typez.append(QAudioFormat::Float);
- codecz.append(tr("audio/pcm"));
+ codecz.append(QLatin1String("audio/pcm"));
close();
}
@@ -346,10 +387,10 @@ QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode)
if(io == NULL)
_m = mode;
- QString str = tr(name);
+ QString str = QLatin1String(name);
- if(str.contains(tr("default"))) {
- int pos = str.indexOf(tr("="),0);
+ if(str.contains(QLatin1String("default"))) {
+ int pos = str.indexOf(QLatin1String("="),0);
devices.append(str.mid(pos+1).toLocal8Bit().constData());
}
}
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
index 371f442..ba9f5e2 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
@@ -99,13 +99,13 @@ QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const
nearest.setByteOrder(QAudioFormat::LittleEndian);
nearest.setSampleType(QAudioFormat::SignedInt);
nearest.setSampleSize(16);
- nearest.setCodec(tr("audio/pcm"));
+ nearest.setCodec(QLatin1String("audio/pcm"));
} else {
nearest.setFrequency(11025);
nearest.setChannels(1);
nearest.setSampleType(QAudioFormat::SignedInt);
nearest.setSampleSize(8);
- nearest.setCodec(tr("audio/pcm"));
+ nearest.setCodec(QLatin1String("audio/pcm"));
}
return nearest;
}
@@ -174,27 +174,25 @@ bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const
// Set nearest to closest settings that do work.
// See if what is in settings will work (return value).
- bool testChannel = false;
- bool testCodec = false;
- bool testFreq = false;
-
- int err = 0;
+ bool failed = false;
// For now, just accept only audio/pcm codec
- if(!format.codec().startsWith(tr("audio/pcm"))) {
- err=-1;
- } else
- testCodec = true;
+ if(!format.codec().startsWith(QLatin1String("audio/pcm")))
+ failed = true;
- if(err>=0 && format.channels() != -1) {
- testChannel = true;
- }
+ if(!failed && !(format.channels() == 1 || format.channels() == 2))
+ failed = true;
- if(err>=0 && format.frequency() != -1) {
- testFreq = true;
+ if(!failed) {
+ if(!(format.frequency() == 8000 || format.frequency() == 11025 || format.frequency() == 22050 ||
+ format.frequency() == 44100 || format.frequency() == 48000 || format.frequency() == 96000))
+ failed = true;
}
- if(err == 0) {
+ if(!failed && !(format.sampleSize() == 8 || format.sampleSize() == 16))
+ failed = true;
+
+ if(!failed) {
// settings work
return true;
}
@@ -209,7 +207,7 @@ void QAudioDeviceInfoPrivate::updateLists()
DWORD fmt = NULL;
QString tmp;
- if(device.compare(tr("default")) == 0)
+ if(device.compare(QLatin1String("default")) == 0)
base = true;
if(mode == QAudio::AudioOutput) {
@@ -331,7 +329,7 @@ void QAudioDeviceInfoPrivate::updateLists()
typez.append(QAudioFormat::SignedInt);
typez.append(QAudioFormat::UnSignedInt);
- codecz.append(tr("audio/pcm"));
+ codecz.append(QLatin1String("audio/pcm"));
}
}
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp
index c98102c..f36ffc8 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp
@@ -78,7 +78,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor
pullMode = true;
resuming = false;
- QStringList list1 = QString(tr(device)).split(tr(":"));
+ QStringList list1 = QString(QLatin1String(device)).split(QLatin1String(":"));
m_device = QByteArray(list1.at(0).toLocal8Bit().constData());
timer = new QTimer(this);
@@ -254,9 +254,9 @@ bool QAudioInputPrivate::open()
int count=0;
unsigned int freakuency=settings.frequency();
- QString dev = QString(tr(m_device.constData()));
- if(!dev.contains(tr("default"))) {
- dev = QString(tr("default:CARD=%1")).arg(tr(m_device.constData()));
+ QString dev = QString(QLatin1String(m_device.constData()));
+ if(!dev.contains(QLatin1String("default"))) {
+ dev = QString(QLatin1String("default:CARD=%1")).arg(QLatin1String(m_device.constData()));
}
// Step 1: try and open the device
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index 315a59b..31441ae 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -245,7 +245,7 @@ bool QAudioInputPrivate::open()
== MMSYSERR_NOERROR) {
QString tmp;
tmp = QString::fromUtf16((const unsigned short*)wic.szPname);
- if(tmp.compare(tr(m_device)) == 0) {
+ if(tmp.compare(QLatin1String(m_device)) == 0) {
devId = ii;
break;
}
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
index 45ff115..e8a3f5c 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
@@ -81,7 +81,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF
resuming = false;
opened = false;
- QStringList list1 = QString(tr(device)).split(tr(":"));
+ QStringList list1 = QString(QLatin1String(device)).split(QLatin1String(":"));
m_device = QByteArray(list1.at(0).toLocal8Bit().constData());
timer = new QTimer(this);
@@ -277,9 +277,9 @@ bool QAudioOutputPrivate::open()
int count=0;
unsigned int freakuency=settings.frequency();
- QString dev = tr(m_device.constData());
- if(!dev.contains(tr("default"))) {
- dev = QString(tr("default:CARD=%1")).arg(tr(m_device.constData()));
+ QString dev = QLatin1String(m_device.constData());
+ if(!dev.contains(QLatin1String("default"))) {
+ dev = QString(QLatin1String("default:CARD=%1")).arg(QLatin1String(m_device.constData()));
}
// Step 1: try and open the device
while((count < 5) && (err < 0)) {
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index fae680c..aea3a3f 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -241,7 +241,7 @@ bool QAudioOutputPrivate::open()
== MMSYSERR_NOERROR) {
QString tmp;
tmp = QString::fromUtf16((const unsigned short*)woc.szPname);
- if(tmp.compare(tr(m_device)) == 0) {
+ if(tmp.compare(QLatin1String(m_device)) == 0) {
devId = ii;
break;
}
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
index 2d1885c..2502069 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
@@ -216,6 +216,8 @@ void QGLEngineSharedShaders::shaderDestroyed(QObject *shader)
QGLShader *QGLEngineSharedShaders::compileNamedShader(ShaderName name, QGLShader::ShaderType type)
{
Q_ASSERT(name != CustomImageSrcFragmentShader);
+ Q_ASSERT(name < InvalidShaderName);
+
if (compiledShaders[name])
return compiledShaders[name];
@@ -514,7 +516,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg()
else switch (srcPixelType) {
default:
case Qt::NoBrush:
- qCritical("QGLEngineShaderManager::useCorrectShaderProg() - I'm scared, Qt::NoBrush style is set");
+ qFatal("QGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set");
break;
case QGLEngineShaderManager::ImageSrc:
srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcFragmentShader;
diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
index acd4461..6bcf010 100644
--- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
@@ -260,12 +260,24 @@ static const char* const qglslPositionWithTextureBrushVertexShader = "\
static const char* const qglslAffinePositionWithTextureBrushVertexShader
= qglslPositionWithTextureBrushVertexShader;
+#if defined(QT_OPENGL_ES_2)
+// OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead,
+// we emulate GL_REPEAT by only taking the fractional part of the texture coords.
+// TODO: Special case POT textures which don't need this emulation
+static const char* const qglslTextureBrushSrcFragmentShader = "\
+ varying highp vec2 brushTextureCoords; \
+ uniform lowp sampler2D brushTexture; \
+ lowp vec4 srcPixel() { \
+ return texture2D(brushTexture, fract(brushTextureCoords)); \
+ }";
+#else
static const char* const qglslTextureBrushSrcFragmentShader = "\
varying highp vec2 brushTextureCoords; \
uniform lowp sampler2D brushTexture; \
lowp vec4 srcPixel() { \
return texture2D(brushTexture, brushTextureCoords); \
}";
+#endif
static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\
varying highp vec2 brushTextureCoords; \
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index e32bbbd..5e790cf 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1039,60 +1039,45 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush)
{
Q_D(QGL2PaintEngineEx);
- if (brush.style() == Qt::NoBrush)
+ if (qbrush_style(brush) == Qt::NoBrush)
return;
if (!d->inRenderText)
ensureActive();
d->setBrush(&brush);
d->fill(path);
- d->setBrush(&(state()->brush)); // reset back to the state's brush
}
void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
{
Q_D(QGL2PaintEngineEx);
- if (pen.style() == Qt::NoPen)
+ Qt::PenStyle penStyle = qpen_style(pen);
+ const QBrush &penBrush = qpen_brush(pen);
+ if (penStyle == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush)
return;
ensureActive();
- if ( (pen.isCosmetic() && (pen.style() == Qt::SolidLine)) && (pen.widthF() < 2.5f) )
+ qreal penWidth = qpen_widthf(pen);
+ if ( (pen.isCosmetic() && (penStyle == Qt::SolidLine)) && (penWidth < 2.5f) )
{
// We only handle solid, cosmetic pens with a width of 1 pixel
const QBrush& brush = pen.brush();
d->setBrush(&brush);
- if (pen.widthF() < 0.01f)
+ if (penWidth < 0.01f)
glLineWidth(1.0);
else
- glLineWidth(pen.widthF());
+ glLineWidth(penWidth);
d->drawOutline(path);
- d->setBrush(&(state()->brush));
} else
return QPaintEngineEx::stroke(path, pen);
}
-void QGL2PaintEngineEx::penChanged()
-{
-// qDebug("QGL2PaintEngineEx::penChanged() not implemented!");
-}
-
-
-void QGL2PaintEngineEx::brushChanged()
-{
-// qDebug("QGL2PaintEngineEx::brushChanged()");
- Q_D(QGL2PaintEngineEx);
- d->setBrush(&(state()->brush));
-}
-
-void QGL2PaintEngineEx::brushOriginChanged()
-{
-// qDebug("QGL2PaintEngineEx::brushOriginChanged()");
- Q_D(QGL2PaintEngineEx);
- d->brushUniformsDirty = true;
-}
+void QGL2PaintEngineEx::penChanged() { }
+void QGL2PaintEngineEx::brushChanged() { }
+void QGL2PaintEngineEx::brushOriginChanged() { }
void QGL2PaintEngineEx::opacityChanged()
{
@@ -1300,8 +1285,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte
glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data());
glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size());
-
- setBrush(&(q->state()->brush)); //###
}
bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
@@ -1555,6 +1538,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op)
if (state()->rectangleClip.isValid() && op != Qt::NoClip && op != Qt::ReplaceClip) {
QPainterPath path;
path.addRect(state()->rectangleClip);
+ path = state()->matrix.inverted().map(path);
state()->rectangleClip = QRect();
d->updateDepthScissorTest();
@@ -1715,8 +1699,6 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state)
d->matrixDirty = true;
d->compositionModeDirty = true;
- d->brushTextureDirty = true;
- d->brushUniformsDirty = true;
d->simpleShaderDepthUniformDirty = true;
d->depthUniformDirty = true;
d->simpleShaderMatrixUniformDirty = true;
@@ -1739,6 +1721,9 @@ QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const
{
Q_D(const QGL2PaintEngineEx);
+ if (orig)
+ const_cast<QGL2PaintEngineEx *>(this)->ensureActive();
+
QOpenGL2PaintEngineState *s;
if (!orig)
s = new QOpenGL2PaintEngineState();
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 1bcfab8..1a0957c 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -103,7 +103,11 @@ QT_BEGIN_NAMESPACE
QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs;
#endif
-QThreadStorage<QGLThreadContext *> qgl_context_storage;
+struct QGLThreadContext {
+ QGLContext *context;
+};
+
+static QThreadStorage<QGLThreadContext *> qgl_context_storage;
Q_GLOBAL_STATIC(QGLFormat, qgl_default_format)
@@ -2939,11 +2943,28 @@ void QGLContext::setInitialized(bool on)
const QGLContext* QGLContext::currentContext()
{
- if (qgl_context_storage.hasLocalData())
- return qgl_context_storage.localData()->context;
+ QGLThreadContext *threadContext = qgl_context_storage.localData();
+ if (threadContext)
+ return threadContext->context;
return 0;
}
+void QGLContextPrivate::setCurrentContext(QGLContext *context)
+{
+ QGLThreadContext *threadContext = qgl_context_storage.localData();
+ if (!threadContext) {
+ if (!QThread::currentThread()) {
+ // We don't have a current QThread, so just set the static.
+ QGLContext::currentCtx = context;
+ return;
+ }
+ threadContext = new QGLThreadContext;
+ qgl_context_storage.setLocalData(threadContext);
+ }
+ threadContext->context = context;
+ QGLContext::currentCtx = context; // XXX: backwards-compat, not thread-safe
+}
+
/*!
\fn bool QGLContext::chooseContext(const QGLContext* shareContext = 0)
@@ -3983,7 +4004,7 @@ void QGLWidget::qglColor(const QColor& c) const
{
#if !defined(QT_OPENGL_ES_2)
#ifdef QT_OPENGL_ES
- glColor4f(c.red()/255.0, c.green()/255.0, c.blue()/255.0, c.alpha()/255.0);
+ glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());
#else
Q_D(const QGLWidget);
const QGLContext *ctx = QGLContext::currentContext();
@@ -4015,15 +4036,13 @@ void QGLWidget::qglColor(const QColor& c) const
void QGLWidget::qglClearColor(const QColor& c) const
{
#ifdef QT_OPENGL_ES
- glClearColor((GLfloat)c.red() / 255.0, (GLfloat)c.green() / 255.0,
- (GLfloat)c.blue() / 255.0, (GLfloat) c.alpha() / 255.0);
+ glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
#else
Q_D(const QGLWidget);
const QGLContext *ctx = QGLContext::currentContext();
if (ctx) {
if (ctx->format().rgba())
- glClearColor((GLfloat)c.red() / 255.0, (GLfloat)c.green() / 255.0,
- (GLfloat)c.blue() / 255.0, (GLfloat) c.alpha() / 255.0);
+ glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
else if (!d->cmap.isEmpty()) { // QGLColormap in use?
int i = d->cmap.find(c.rgb());
if (i < 0)
@@ -4094,10 +4113,10 @@ QImage QGLWidget::convertToGLFormat(const QImage& img)
colormaps installed. Asking for the colormap of a child widget
will return the colormap for the child's top-level widget.
- If no colormap has been set for this widget, the QColormap
+ If no colormap has been set for this widget, the QGLColormap
returned will be empty.
- \sa setColormap()
+ \sa setColormap(), QGLColormap::isEmpty()
*/
/*!
diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm
index dd9d9ff..063082b 100644
--- a/src/opengl/qgl_mac.mm
+++ b/src/opengl/qgl_mac.mm
@@ -493,11 +493,7 @@ void QGLContext::makeCurrent()
#else
[static_cast<NSOpenGLContext *>(d->cx) makeCurrentContext];
#endif
- currentCtx = this;
- if (!qgl_context_storage.hasLocalData() && QThread::currentThread())
- qgl_context_storage.setLocalData(new QGLThreadContext);
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = this;
+ QGLContextPrivate::setCurrentContext(this);
}
#ifndef QT_MAC_USE_COCOA
@@ -656,9 +652,7 @@ void QGLContext::doneCurrent()
)
return;
- currentCtx = 0;
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = 0;
+ QGLContextPrivate::setCurrentContext(0);
#ifndef QT_MAC_USE_COCOA
aglSetCurrentContext(0);
#else
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 57b40fb..2b74e69 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -351,6 +351,8 @@ public:
static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *) { return qt_extensionFuncs; }
#endif
+ static void setCurrentContext(QGLContext *context);
+
QPixmapFilter *createPixmapFilter(int type) const;
};
@@ -398,11 +400,6 @@ public:
Q_DECLARE_OPERATORS_FOR_FLAGS(QGLExtensions::Extensions)
-struct QGLThreadContext {
- QGLContext *context;
-};
-extern QThreadStorage<QGLThreadContext *> qgl_context_storage;
-
class QGLShareRegister
{
public:
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
index 759f9de..7197776 100644
--- a/src/opengl/qgl_qws.cpp
+++ b/src/opengl/qgl_qws.cpp
@@ -260,13 +260,8 @@ void QGLContext::makeCurrent()
return;
}
- if (d->eglContext->makeCurrent()) {
- if (!qgl_context_storage.hasLocalData() && QThread::currentThread())
- qgl_context_storage.setLocalData(new QGLThreadContext);
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = this;
- currentCtx = this;
- }
+ if (d->eglContext->makeCurrent())
+ QGLContextPrivate::setCurrentContext(this);
}
void QGLContext::doneCurrent()
@@ -275,9 +270,7 @@ void QGLContext::doneCurrent()
if (d->eglContext)
d->eglContext->doneCurrent();
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = 0;
- currentCtx = 0;
+ QGLContextPrivate::setCurrentContext(0);
}
diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp
index 78dad80..2f9e225 100644
--- a/src/opengl/qgl_win.cpp
+++ b/src/opengl/qgl_win.cpp
@@ -1173,11 +1173,7 @@ void QGLContext::makeCurrent()
}
if (wglMakeCurrent(d->dc, d->rc)) {
- if (!qgl_context_storage.hasLocalData() && QThread::currentThread())
- qgl_context_storage.setLocalData(new QGLThreadContext);
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = this;
- currentCtx = this;
+ QGLContextPrivate::setCurrentContext(this);
} else {
qwglError("QGLContext::makeCurrent()", "wglMakeCurrent");
}
@@ -1187,10 +1183,8 @@ void QGLContext::makeCurrent()
void QGLContext::doneCurrent()
{
Q_D(QGLContext);
- currentCtx = 0;
wglMakeCurrent(0, 0);
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = 0;
+ QGLContextPrivate::setCurrentContext(0);
if (deviceIsPixmap() && d->hbitmap) {
QPixmap *pm = static_cast<QPixmap *>(d->paintDevice);
*pm = QPixmap::fromWinHBITMAP(d->hbitmap);
diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp
index 83efca8..4e655f1 100644
--- a/src/opengl/qgl_wince.cpp
+++ b/src/opengl/qgl_wince.cpp
@@ -450,13 +450,8 @@ void QGLContext::makeCurrent()
return;
}
- if (d->eglContext->makeCurrent()) {
- if (!qgl_context_storage.hasLocalData() && QThread::currentThread())
- qgl_context_storage.setLocalData(new QGLThreadContext);
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = this;
- currentCtx = this;
- }
+ if (d->eglContext->makeCurrent())
+ QGLContextPrivate::setCurrentContext(this);
}
@@ -467,9 +462,7 @@ void QGLContext::doneCurrent()
if (d->eglContext)
d->eglContext->doneCurrent();
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = 0;
- currentCtx = 0;
+ QGLContextPrivate::setCurrentContext(0);
}
void QGLContext::swapBuffers() const
diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp
index cb1da18..da7972d 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -791,22 +791,15 @@ void QGLContext::makeCurrent()
if (!ok)
qWarning("QGLContext::makeCurrent(): Failed.");
- if (ok) {
- if (!qgl_context_storage.hasLocalData() && QThread::currentThread())
- qgl_context_storage.setLocalData(new QGLThreadContext);
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = this;
- currentCtx = this;
- }
+ if (ok)
+ QGLContextPrivate::setCurrentContext(this);
}
void QGLContext::doneCurrent()
{
Q_D(QGLContext);
glXMakeCurrent(qt_x11Info(d->paintDevice)->display(), 0, 0);
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = 0;
- currentCtx = 0;
+ QGLContextPrivate::setCurrentContext(0);
}
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index c54315f..7dfd642 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -146,13 +146,8 @@ void QGLContext::makeCurrent()
return;
}
- if (d->eglContext->makeCurrent()) {
- if (!qgl_context_storage.hasLocalData() && QThread::currentThread())
- qgl_context_storage.setLocalData(new QGLThreadContext);
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = this;
- currentCtx = this;
- }
+ if (d->eglContext->makeCurrent())
+ QGLContextPrivate::setCurrentContext(this);
}
void QGLContext::doneCurrent()
@@ -161,9 +156,7 @@ void QGLContext::doneCurrent()
if (d->eglContext)
d->eglContext->doneCurrent();
- if (qgl_context_storage.hasLocalData())
- qgl_context_storage.localData()->context = 0;
- currentCtx = 0;
+ QGLContextPrivate::setCurrentContext(0);
}
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index 6cd8968..07bc711 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -402,7 +402,7 @@ QPaintEngine *QGLPixelBuffer::paintEngine() const
#elif defined(QT_OPENGL_ES_2)
return qt_buffer_2_engine();
#else
- if (d_ptr->qctx->d_func()->internal_context || qt_gl_preferGL2Engine())
+ if (qt_gl_preferGL2Engine())
return qt_buffer_2_engine();
else
return qt_buffer_engine();
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp
index b0ba8cd..bc425fc 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/sql/drivers/ibase/qsql_ibase.cpp
@@ -1296,6 +1296,9 @@ int QIBaseResult::numRowsAffected()
case isc_info_sql_stmt_insert:
cCountType = isc_info_req_insert_count;
break;
+ default:
+ qWarning() << "numRowsAffected: Unknown statement type (" << d->queryType << ")";
+ return -1;
}
char acBuffer[33];
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index eeb250d..df94080 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -559,7 +559,7 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
if (row.op == QSqlTableModelPrivate::None) {
row.op = QSqlTableModelPrivate::Update;
row.rec = d->rec;
- row.primaryValues = d->primaryValues(indexInQuery(index).row());
+ row.primaryValues = d->primaryValues(indexInQuery(index).row());
}
row.rec.setValue(index.column(), value);
emit dataChanged(index, index);
@@ -669,7 +669,7 @@ bool QSqlTableModel::deleteRowFromTable(int row)
Q_D(QSqlTableModel);
emit beforeDelete(row);
- QSqlRecord rec = d->primaryValues(row);
+ const QSqlRecord whereValues = d->strategy == OnManualSubmit ? d->cache[row].primaryValues : d->primaryValues(row);
bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries);
QString stmt = d->db.driver()->sqlStatement(QSqlDriver::DeleteStatement,
d->tableName,
@@ -677,7 +677,7 @@ bool QSqlTableModel::deleteRowFromTable(int row)
prepStatement);
QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement,
d->tableName,
- rec,
+ whereValues,
prepStatement);
if (stmt.isEmpty() || where.isEmpty()) {
@@ -687,7 +687,7 @@ bool QSqlTableModel::deleteRowFromTable(int row)
}
stmt.append(QLatin1Char(' ')).append(where);
- return d->exec(stmt, prepStatement, rec);
+ return d->exec(stmt, prepStatement, whereValues);
}
/*!
@@ -1099,6 +1099,7 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent)
revertRow(idx);
else {
d->cache[idx].op = QSqlTableModelPrivate::Delete;
+ d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row());
emit headerDataChanged(Qt::Vertical, idx, idx);
}
}
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index f287d5e..a6e4855 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -975,15 +975,7 @@ static void parseColor(QSvgNode *,
static QSvgStyleProperty *styleFromUrl(QSvgNode *node, const QString &url)
{
- while (node && (node->type() != QSvgNode::DOC &&
- node->type() != QSvgNode::G &&
- node->type() != QSvgNode::DEFS &&
- node->type() != QSvgNode::SWITCH)) {
- node = node->parent();
- }
- if (!node)
- return 0;
- return static_cast<QSvgStructureNode*>(node)->scopeStyle(idFromUrl(url));
+ return node ? node->styleProperty(idFromUrl(url)) : 0;
}
static void parseBrush(QSvgNode *node,
@@ -3559,10 +3551,9 @@ void QSvgHandler::parse()
case QXmlStreamReader::ProcessingInstruction:
processingInstruction(xml->processingInstructionTarget().toString(), xml->processingInstructionData().toString());
break;
- default:
- ;
}
}
+ resolveGradients(m_doc);
}
bool QSvgHandler::startElement(const QString &localName,
@@ -3672,7 +3663,7 @@ bool QSvgHandler::startElement(const QString &localName,
QSvgStyleProperty *prop = method(m_nodes.top(), attributes, this);
if (prop) {
m_style = prop;
- m_nodes.top()->appendStyleProperty(prop, someId(attributes), true);
+ m_nodes.top()->appendStyleProperty(prop, someId(attributes));
} else {
qWarning("Could not parse node: %s", qPrintable(localName));
}
@@ -3713,53 +3704,52 @@ bool QSvgHandler::endElement(const QStringRef &localName)
if (m_inStyle && localName == QLatin1String("style"))
m_inStyle = false;
- if (node == Graphics) {
- // Iterate through the m_renderers to resolve any unresolved gradients.
- QSvgNode* curNode = static_cast<QSvgNode*>(m_nodes.top());
- if (curNode->type() == QSvgNode::DOC ||
- curNode->type() == QSvgNode::G ||
- curNode->type() == QSvgNode::DEFS ||
- curNode->type() == QSvgNode::SWITCH) {
- QSvgStructureNode* structureNode = static_cast<QSvgStructureNode*>(curNode);
- QList<QSvgNode*> ren = structureNode->renderers();
- QList<QSvgNode*>::iterator itr = ren.begin();
- while (itr != ren.end()) {
- QSvgNode *eleNode = *itr++;
- QSvgFillStyle *fill = static_cast<QSvgFillStyle*>(eleNode->styleProperty(QSvgStyleProperty::FILL));
- if (fill && !(fill->isGradientResolved())) {
- QString id = fill->gradientId();
- QSvgStyleProperty *style = structureNode->scopeStyle(id);
- if (style) {
- if (style->type() == QSvgStyleProperty::SOLID_COLOR || style->type() == QSvgStyleProperty::GRADIENT)
- fill->setFillStyle(reinterpret_cast<QSvgFillStyleProperty *>(style));
- } else {
- qWarning("Could not resolve property : %s",qPrintable(id));
- fill->setBrush(QBrush(Qt::NoBrush));
- }
- }
- QSvgStrokeStyle *stroke = static_cast<QSvgStrokeStyle*>(eleNode->styleProperty(QSvgStyleProperty::STROKE));
- if (stroke && !(stroke->isGradientResolved())) {
- QString id = stroke->gradientId();
- QSvgStyleProperty *style = structureNode->scopeStyle(id);
- if (style) {
- if (style->type() == QSvgStyleProperty::SOLID_COLOR || style->type() == QSvgStyleProperty::GRADIENT)
- stroke->setStyle(reinterpret_cast<QSvgFillStyleProperty *>(style));
- } else {
- qWarning("Could not resolve property : %s",qPrintable(id));
- stroke->setStroke(QBrush(Qt::NoBrush));
- }
- }
- }
- }
+ if (node == Graphics)
m_nodes.pop();
- }
-
else if (m_style && !m_skipNodes.isEmpty() && m_skipNodes.top() != Style)
m_style = 0;
return true;
}
+void QSvgHandler::resolveGradients(QSvgNode *node)
+{
+ if (!node || (node->type() != QSvgNode::DOC && node->type() != QSvgNode::G
+ && node->type() != QSvgNode::DEFS && node->type() != QSvgNode::SWITCH)) {
+ return;
+ }
+ QSvgStructureNode *structureNode = static_cast<QSvgStructureNode *>(node);
+
+ QList<QSvgNode *> ren = structureNode->renderers();
+ for (QList<QSvgNode *>::iterator it = ren.begin(); it != ren.end(); ++it) {
+ QSvgFillStyle *fill = static_cast<QSvgFillStyle *>((*it)->styleProperty(QSvgStyleProperty::FILL));
+ if (fill && !fill->isGradientResolved()) {
+ QString id = fill->gradientId();
+ QSvgFillStyleProperty *style = structureNode->styleProperty(id);
+ if (style) {
+ fill->setFillStyle(style);
+ } else {
+ qWarning("Could not resolve property : %s", qPrintable(id));
+ fill->setBrush(Qt::NoBrush);
+ }
+ }
+
+ QSvgStrokeStyle *stroke = static_cast<QSvgStrokeStyle *>((*it)->styleProperty(QSvgStyleProperty::STROKE));
+ if (stroke && !stroke->isGradientResolved()) {
+ QString id = stroke->gradientId();
+ QSvgFillStyleProperty *style = structureNode->styleProperty(id);
+ if (style) {
+ stroke->setStyle(style);
+ } else {
+ qWarning("Could not resolve property : %s", qPrintable(id));
+ stroke->setStroke(Qt::NoBrush);
+ }
+ }
+
+ resolveGradients(*it);
+ }
+}
+
bool QSvgHandler::characters(const QStringRef &str)
{
if (m_inStyle) {
diff --git a/src/svg/qsvghandler_p.h b/src/svg/qsvghandler_p.h
index aff6f1d..daf1b1c 100644
--- a/src/svg/qsvghandler_p.h
+++ b/src/svg/qsvghandler_p.h
@@ -172,6 +172,7 @@ private:
QXmlStreamReader *const xml;
QCss::Parser m_cssParser;
void parse();
+ void resolveGradients(QSvgNode *node);
QPen m_defaultPen;
/**
diff --git a/src/svg/qsvgnode.cpp b/src/svg/qsvgnode.cpp
index 6b8254e..2e27cd5 100644
--- a/src/svg/qsvgnode.cpp
+++ b/src/svg/qsvgnode.cpp
@@ -60,56 +60,57 @@ QSvgNode::~QSvgNode()
}
-void QSvgNode::appendStyleProperty(QSvgStyleProperty *prop, const QString &id,
- bool justLink)
+void QSvgNode::appendStyleProperty(QSvgStyleProperty *prop, const QString &id)
{
//qDebug()<<"appending "<<prop->type()<< " ("<< id <<") "<<"to "<<this<<this->type();
- if (!justLink) {
- switch (prop->type()) {
- case QSvgStyleProperty::QUALITY:
- m_style.quality = static_cast<QSvgQualityStyle*>(prop);
- break;
- case QSvgStyleProperty::FILL:
- m_style.fill = static_cast<QSvgFillStyle*>(prop);
- break;
- case QSvgStyleProperty::VIEWPORT_FILL:
- m_style.viewportFill = static_cast<QSvgViewportFillStyle*>(prop);
- break;
- case QSvgStyleProperty::FONT:
- m_style.font = static_cast<QSvgFontStyle*>(prop);
- break;
- case QSvgStyleProperty::STROKE:
- m_style.stroke = static_cast<QSvgStrokeStyle*>(prop);
- break;
- case QSvgStyleProperty::SOLID_COLOR:
- m_style.solidColor = static_cast<QSvgSolidColorStyle*>(prop);
- break;
- case QSvgStyleProperty::GRADIENT:
- m_style.gradient = static_cast<QSvgGradientStyle*>(prop);
- break;
- case QSvgStyleProperty::TRANSFORM:
- m_style.transform = static_cast<QSvgTransformStyle*>(prop);
- break;
- case QSvgStyleProperty::ANIMATE_COLOR:
- m_style.animateColor = static_cast<QSvgAnimateColor*>(prop);
- break;
- case QSvgStyleProperty::ANIMATE_TRANSFORM:
- m_style.animateTransforms.append(
- static_cast<QSvgAnimateTransform*>(prop));
- break;
- case QSvgStyleProperty::OPACITY:
- m_style.opacity = static_cast<QSvgOpacityStyle*>(prop);
- break;
- case QSvgStyleProperty::COMP_OP:
- m_style.compop = static_cast<QSvgCompOpStyle*>(prop);
- break;
- default:
- qDebug("QSvgNode: Trying to append unknown property!");
- break;
- }
- }
- if (!id.isEmpty()) {
- m_styles.insert(id, prop);
+ QSvgTinyDocument *doc;
+ switch (prop->type()) {
+ case QSvgStyleProperty::QUALITY:
+ m_style.quality = static_cast<QSvgQualityStyle*>(prop);
+ break;
+ case QSvgStyleProperty::FILL:
+ m_style.fill = static_cast<QSvgFillStyle*>(prop);
+ break;
+ case QSvgStyleProperty::VIEWPORT_FILL:
+ m_style.viewportFill = static_cast<QSvgViewportFillStyle*>(prop);
+ break;
+ case QSvgStyleProperty::FONT:
+ m_style.font = static_cast<QSvgFontStyle*>(prop);
+ break;
+ case QSvgStyleProperty::STROKE:
+ m_style.stroke = static_cast<QSvgStrokeStyle*>(prop);
+ break;
+ case QSvgStyleProperty::SOLID_COLOR:
+ m_style.solidColor = static_cast<QSvgSolidColorStyle*>(prop);
+ doc = document();
+ if (doc && !id.isEmpty())
+ doc->addNamedStyle(id, m_style.solidColor);
+ break;
+ case QSvgStyleProperty::GRADIENT:
+ m_style.gradient = static_cast<QSvgGradientStyle*>(prop);
+ doc = document();
+ if (doc && !id.isEmpty())
+ doc->addNamedStyle(id, m_style.gradient);
+ break;
+ case QSvgStyleProperty::TRANSFORM:
+ m_style.transform = static_cast<QSvgTransformStyle*>(prop);
+ break;
+ case QSvgStyleProperty::ANIMATE_COLOR:
+ m_style.animateColor = static_cast<QSvgAnimateColor*>(prop);
+ break;
+ case QSvgStyleProperty::ANIMATE_TRANSFORM:
+ m_style.animateTransforms.append(
+ static_cast<QSvgAnimateTransform*>(prop));
+ break;
+ case QSvgStyleProperty::OPACITY:
+ m_style.opacity = static_cast<QSvgOpacityStyle*>(prop);
+ break;
+ case QSvgStyleProperty::COMP_OP:
+ m_style.compop = static_cast<QSvgCompOpStyle*>(prop);
+ break;
+ default:
+ qDebug("QSvgNode: Trying to append unknown property!");
+ break;
}
}
@@ -185,20 +186,13 @@ QSvgStyleProperty * QSvgNode::styleProperty(QSvgStyleProperty::Type type) const
return 0;
}
-QSvgStyleProperty * QSvgNode::styleProperty(const QString &id) const
+QSvgFillStyleProperty * QSvgNode::styleProperty(const QString &id) const
{
QString rid = id;
if (rid.startsWith(QLatin1Char('#')))
rid.remove(0, 1);
- const QSvgNode *node = this;
- while (node) {
- QSvgStyleProperty *style = node->m_styles[rid];
- if (style)
- return style;
- node = node->parent();
- }
-
- return 0;
+ QSvgTinyDocument *doc = document();
+ return doc ? doc->namedStyle(rid) : 0;
}
QRectF QSvgNode::bounds() const
diff --git a/src/svg/qsvgnode_p.h b/src/svg/qsvgnode_p.h
index 2831e65..1f5606a 100644
--- a/src/svg/qsvgnode_p.h
+++ b/src/svg/qsvgnode_p.h
@@ -117,12 +117,11 @@ public:
QSvgNode *parent() const;
- void appendStyleProperty(QSvgStyleProperty *prop, const QString &id,
- bool justLink=false);
+ void appendStyleProperty(QSvgStyleProperty *prop, const QString &id);
void applyStyle(QPainter *p, QSvgExtraStates &states);
void revertStyle(QPainter *p, QSvgExtraStates &states);
QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const;
- QSvgStyleProperty *styleProperty(const QString &id) const;
+ QSvgFillStyleProperty *styleProperty(const QString &id) const;
QSvgTinyDocument *document() const;
@@ -162,7 +161,6 @@ protected:
qreal strokeWidth() const;
private:
QSvgNode *m_parent;
- QHash<QString, QSvgRefCounter<QSvgStyleProperty> > m_styles;
QStringList m_requiredFeatures;
QStringList m_requiredExtensions;
diff --git a/src/svg/qsvgstructure.cpp b/src/svg/qsvgstructure.cpp
index 47a544f..82c800d 100644
--- a/src/svg/qsvgstructure.cpp
+++ b/src/svg/qsvgstructure.cpp
@@ -45,6 +45,7 @@
#include "qsvgnode_p.h"
#include "qsvgstyle_p.h"
+#include "qsvgtinydocument_p.h"
#include "qpainter.h"
#include "qlocale.h"
@@ -90,35 +91,20 @@ QSvgStructureNode::QSvgStructureNode(QSvgNode *parent)
QSvgNode * QSvgStructureNode::scopeNode(const QString &id) const
{
- const QSvgStructureNode *group = this;
- while (group && group->type() != QSvgNode::DOC) {
- group = static_cast<QSvgStructureNode*>(group->parent());
- }
- if (group)
- return group->m_scope[id];
- return 0;
+ QSvgTinyDocument *doc = document();
+ return doc ? doc->namedNode(id) : 0;
}
-void QSvgStructureNode::addChild(QSvgNode *child, const QString &id, bool def)
+void QSvgStructureNode::addChild(QSvgNode *child, const QString &id)
{
- if (!def)
- m_renderers.append(child);
-
- if (child->type() == QSvgNode::DEFS) {
- QSvgDefs *defs =
- static_cast<QSvgDefs*>(child);
- m_linkedScopes.append(defs);
- }
+ m_renderers.append(child);
if (id.isEmpty())
return; //we can't add it to scope without id
- QSvgStructureNode *group = this;
- while (group && group->type() != QSvgNode::DOC) {
- group = static_cast<QSvgStructureNode*>(group->parent());
- }
- if (group)
- group->m_scope.insert(id, child);
+ QSvgTinyDocument *doc = document();
+ if (doc)
+ doc->addNamedNode(id, child);
}
QSvgDefs::QSvgDefs(QSvgNode *parent)
@@ -136,26 +122,6 @@ QSvgNode::Type QSvgDefs::type() const
return DEFS;
}
-QSvgStyleProperty * QSvgStructureNode::scopeStyle(const QString &id) const
-{
- const QSvgStructureNode *group = this;
- while (group) {
- QSvgStyleProperty *prop = group->styleProperty(id);
- if (prop)
- return prop;
- QList<QSvgStructureNode*>::const_iterator itr = group->m_linkedScopes.constBegin();
- while (itr != group->m_linkedScopes.constEnd()) {
- prop = (*itr)->styleProperty(id);
- if (prop)
- return prop;
- ++itr;
- }
- group = static_cast<QSvgStructureNode*>(group->parent());
- }
- return 0;
-}
-
-
/*
Below is a lookup function based on the gperf output using the following set:
diff --git a/src/svg/qsvgstructure_p.h b/src/svg/qsvgstructure_p.h
index d873f54..444f885 100644
--- a/src/svg/qsvgstructure_p.h
+++ b/src/svg/qsvgstructure_p.h
@@ -73,8 +73,7 @@ public:
QSvgStructureNode(QSvgNode *parent);
~QSvgStructureNode();
QSvgNode *scopeNode(const QString &id) const;
- QSvgStyleProperty *scopeStyle(const QString &id) const;
- void addChild(QSvgNode *child, const QString &id, bool def = false);
+ void addChild(QSvgNode *child, const QString &id);
virtual QRectF bounds() const;
QSvgNode *previousSiblingNode(QSvgNode *n) const;
QList<QSvgNode*> renderers() const { return m_renderers; }
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index 564bf24..f834016 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -934,7 +934,7 @@ void QSvgGradientStyle::setStopLink(const QString &link, QSvgTinyDocument *doc)
void QSvgGradientStyle::resolveStops()
{
if (!m_link.isEmpty() && m_doc) {
- QSvgStyleProperty *prop = m_doc->scopeStyle(m_link);
+ QSvgStyleProperty *prop = m_doc->styleProperty(m_link);
if (prop) {
if (prop->type() == QSvgStyleProperty::GRADIENT) {
QSvgGradientStyle *st =
@@ -943,6 +943,8 @@ void QSvgGradientStyle::resolveStops()
m_gradient->setStops(st->qgradient()->stops());
m_gradientStopsSet = st->gradientStopsSet();
}
+ } else {
+ qWarning("Could not resolve property : %s", qPrintable(m_link));
}
m_link = QString();
}
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
index 5d58f79..e2cefeb 100644
--- a/src/svg/qsvgtinydocument.cpp
+++ b/src/svg/qsvgtinydocument.cpp
@@ -350,6 +350,26 @@ QSvgFont * QSvgTinyDocument::svgFont(const QString &family) const
return m_fonts[family];
}
+void QSvgTinyDocument::addNamedNode(const QString &id, QSvgNode *node)
+{
+ m_namedNodes.insert(id, node);
+}
+
+QSvgNode *QSvgTinyDocument::namedNode(const QString &id) const
+{
+ return m_namedNodes.value(id);
+}
+
+void QSvgTinyDocument::addNamedStyle(const QString &id, QSvgFillStyleProperty *style)
+{
+ m_namedStyles.insert(id, style);
+}
+
+QSvgFillStyleProperty *QSvgTinyDocument::namedStyle(const QString &id) const
+{
+ return m_namedStyles.value(id);
+}
+
void QSvgTinyDocument::restartAnimation()
{
m_time.restart();
diff --git a/src/svg/qsvgtinydocument_p.h b/src/svg/qsvgtinydocument_p.h
index bde28c7..38a1f92 100644
--- a/src/svg/qsvgtinydocument_p.h
+++ b/src/svg/qsvgtinydocument_p.h
@@ -108,6 +108,10 @@ public:
void addSvgFont(QSvgFont *);
QSvgFont *svgFont(const QString &family) const;
+ void addNamedNode(const QString &id, QSvgNode *node);
+ QSvgNode *namedNode(const QString &id) const;
+ void addNamedStyle(const QString &id, QSvgFillStyleProperty *style);
+ QSvgFillStyleProperty *namedStyle(const QString &id) const;
void restartAnimation();
int currentElapsed() const;
@@ -127,6 +131,8 @@ private:
mutable QRectF m_viewBox;
QHash<QString, QSvgRefCounter<QSvgFont> > m_fonts;
+ QHash<QString, QSvgNode *> m_namedNodes;
+ QHash<QString, QSvgRefCounter<QSvgFillStyleProperty> > m_namedStyles;
QTime m_time;
bool m_animated;
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h
index 92ca055..13063a8 100644
--- a/src/testlib/qtest_gui.h
+++ b/src/testlib/qtest_gui.h
@@ -42,6 +42,14 @@
#ifndef QTEST_GUI_H
#define QTEST_GUI_H
+// enable GUI features
+#ifndef QT_GUI_LIB
+#define QT_GUI_LIB
+#endif
+#if 0
+#pragma qt_class(QtTestGui)
+#endif
+
#include <QtTest/qtestassert.h>
#include <QtTest/qtest.h>
#include <QtTest/qtestevent.h>
diff --git a/src/testlib/qtestevent.h b/src/testlib/qtestevent.h
index 95f2028..55df572 100644
--- a/src/testlib/qtestevent.h
+++ b/src/testlib/qtestevent.h
@@ -48,8 +48,10 @@
#endif
#include <QtTest/qtest_global.h>
+#ifdef QT_GUI_LIB
#include <QtTest/qtestkeyboard.h>
#include <QtTest/qtestmouse.h>
+#endif
#include <QtTest/qtestsystem.h>
#include <QtCore/qlist.h>
diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h
index 42012e9..11c3b70 100644
--- a/src/testlib/qtestkeyboard.h
+++ b/src/testlib/qtestkeyboard.h
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#if !defined(QTESTKEYBOARD_H) && defined(QT_GUI_LIB)
+#if !defined(QTESTKEYBOARD_H)
#define QTESTKEYBOARD_H
#if 0
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index feb64cf..f339a5a 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#if !defined(QTESTMOUSE_H) && defined(QT_GUI_LIB)
+#if !defined(QTESTMOUSE_H)
#define QTESTMOUSE_H
#if 0