diff options
author | Joerg Bornemann <joerg.bornemann@nokia.com> | 2009-11-11 11:25:03 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@nokia.com> | 2009-11-11 11:25:03 (GMT) |
commit | b111d0bb1f0483d507c758810a0f247cb8dd82c0 (patch) | |
tree | 9db9a693360c607a53d1ec8c3c421b338fb53fef /src/gui | |
parent | 3e2c214dc217ac677733e2a56ac9f17ff0c3196f (diff) | |
parent | 95db13345cd7b6b7cac8725fe2879aaf80233818 (diff) | |
download | Qt-b111d0bb1f0483d507c758810a0f247cb8dd82c0.zip Qt-b111d0bb1f0483d507c758810a0f247cb8dd82c0.tar.gz Qt-b111d0bb1f0483d507c758810a0f247cb8dd82c0.tar.bz2 |
Merge commit 'origin/4.6' into 4.6-ce
Diffstat (limited to 'src/gui')
73 files changed, 713 insertions, 428 deletions
diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp index 4cb0c93..1f0b51d 100644 --- a/src/gui/dialogs/qprintpreviewdialog.cpp +++ b/src/gui/dialogs/qprintpreviewdialog.cpp @@ -446,7 +446,7 @@ void QPrintPreviewDialogPrivate::setFitting(bool on) void QPrintPreviewDialogPrivate::updateNavActions() { int curPage = preview->currentPage(); - int numPages = preview->numPages(); + int numPages = preview->pageCount(); nextPageAction->setEnabled(curPage < numPages); prevPageAction->setEnabled(curPage > 1); firstPageAction->setEnabled(curPage > 1); @@ -458,7 +458,7 @@ void QPrintPreviewDialogPrivate::updatePageNumLabel() { Q_Q(QPrintPreviewDialog); - int numPages = preview->numPages(); + int numPages = preview->pageCount(); int maxChars = QString::number(numPages).length(); pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages)); int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars)); @@ -515,7 +515,7 @@ void QPrintPreviewDialogPrivate::_q_navigate(QAction* action) else if (action == firstPageAction) preview->setCurrentPage(1); else if (action == lastPageAction) - preview->setCurrentPage(preview->numPages()); + preview->setCurrentPage(preview->pageCount()); updateNavActions(); } diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 568ff73..3fca319 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -67,7 +67,17 @@ \o QGraphicsOpacityEffect - renders the item with an opacity \endlist - \img graphicseffect-effects.png + \table + \row + \o{2,1} \img graphicseffect-plain.png + \row + \o \img graphicseffect-blur.png + \o \img graphicseffect-colorize.png + \row + \o \img graphicseffect-opacity.png + \o \img graphicseffect-drop-shadow.png + \endtable + \img graphicseffect-widget.png For more information on how to use each effect, refer to the specific @@ -76,24 +86,21 @@ To create your own custom effect, create a subclass of QGraphicsEffect (or any other existing effects) and reimplement the virtual function draw(). This function is called whenever the effect needs to redraw. The draw() - function accepts two arguments: the painter and a pointer to the source - (QGraphicsEffectSource). The source provides extra context information, - such as a pointer to the item that is rendering the effect, any cached - pixmap data, or the device rectangle bounds. For more information, refer to - the documenation for draw(). To obtain a pointer to the current source, - simply call source(). + function takes the painter with which to draw as an argument. For more + information, refer to the documenation for draw(). In the draw() function + you can call sourcePixmap() to get a pixmap of the graphics effect source + which you can then process. If your effect changes, use update() to request for a redraw. If your custom effect changes the bounding rectangle of the source, e.g., a radial glow effect may need to apply an extra margin, you can reimplement the - virtual boundingRectFor() function, and call updateBoundingRect() to notify - the framework whenever this rectangle changes. The virtual - sourceBoundingRectChanged() function is called to notify the effects that - the source's bounding rectangle has changed - e.g., if the source is a + virtual boundingRectFor() function, and call updateBoundingRect() + to notify the framework whenever this rectangle changes. The virtual + sourceChanged() function is called to notify the effects that + the source has changed in some way - e.g., if the source is a QGraphicsRectItem and its rectangle parameters have changed. - \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect(), - QGraphicsEffectSource + \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect() */ #include "qgraphicseffect_p.h" @@ -112,10 +119,10 @@ QT_BEGIN_NAMESPACE /*! + \internal \class QGraphicsEffectSource \brief The QGraphicsEffectSource class represents the source on which a QGraphicsEffect is installed on. - \since 4.6 When a QGraphicsEffect is installed on a QGraphicsItem, for example, this class will act as a wrapper around QGraphicsItem. Then, calling update() is @@ -154,20 +161,13 @@ QGraphicsEffectSource::~QGraphicsEffectSource() {} /*! - Returns the bounds of the current painter's device. - - This function is useful when you want to draw something in device - coordinates and ensure the size of the pixmap is not bigger than the size - of the device. - - Calling QGraphicsEffectSource::pixmap(Qt::DeviceCoordinates) always returns - a pixmap which is bound to the device's size. + Returns the bounding rectangle of the source mapped to the given \a system. - \sa pixmap() + \sa draw() */ -QRect QGraphicsEffectSource::deviceRect() const +QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const { - return d_func()->deviceRect(); + return d_func()->boundingRect(system); } /*! @@ -175,9 +175,12 @@ QRect QGraphicsEffectSource::deviceRect() const \sa draw() */ -QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const +QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const { - return d_func()->boundingRect(system); + Q_D(const QGraphicsEffect); + if (d->source) + return d->source->boundingRect(system); + return QRectF(); } /*! @@ -218,10 +221,6 @@ const QStyleOption *QGraphicsEffectSource::styleOption() const This function should only be called from QGraphicsEffect::draw(). - For example: - - \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0 - \sa QGraphicsEffect::draw() */ void QGraphicsEffectSource::draw(QPainter *painter) @@ -246,6 +245,24 @@ void QGraphicsEffectSource::draw(QPainter *painter) } /*! + Draws the source directly using the given \a painter. + + This function should only be called from QGraphicsEffect::draw(). + + For example: + + \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0 + + \sa QGraphicsEffect::draw() +*/ +void QGraphicsEffect::drawSource(QPainter *painter) +{ + Q_D(const QGraphicsEffect); + if (d->source) + d->source->draw(painter); +} + +/*! Schedules a redraw of the source. Call this function whenever the source needs to be redrawn. @@ -271,6 +288,19 @@ bool QGraphicsEffectSource::isPixmap() const } /*! + Returns true if the source effectively is a pixmap, e.g., a + QGraphicsPixmapItem. + + This function is useful for optimization purposes. For instance, there's no + point in drawing the source in device coordinates to avoid pixmap scaling + if this function returns true - the source pixmap will be scaled anyways. +*/ +bool QGraphicsEffect::sourceIsPixmap() const +{ + return source() ? source()->isPixmap() : false; +} + +/*! Returns a pixmap with the source painted into it. The \a system specifies which coordinate system to be used for the source. @@ -283,15 +313,15 @@ bool QGraphicsEffectSource::isPixmap() const The returned pixmap is bound to the current painter's device rectangle when \a system is Qt::DeviceCoordinates. - \sa QGraphicsEffect::draw(), boundingRect(), deviceRect() + \sa QGraphicsEffect::draw(), boundingRect() */ -QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, PixmapPadMode mode) const +QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const { Q_D(const QGraphicsEffectSource); // Shortcut, no cache for childless pixmap items... const QGraphicsItem *item = graphicsItem(); - if (system == Qt::LogicalCoordinates && mode == NoExpandPadMode && item && isPixmap()) { + if (system == Qt::LogicalCoordinates && mode == QGraphicsEffect::NoPad && item && isPixmap()) { return ((QGraphicsPixmapItem *) item)->pixmap(); } @@ -320,6 +350,27 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse return pm; } +/*! + Returns a pixmap with the source painted into it. + + The \a system specifies which coordinate system to be used for the source. + The optional \a offset parameter returns the offset where the pixmap should + be painted at using the current painter. For control on how the pixmap is + padded use the \a mode parameter. + + The returned pixmap is clipped to the current painter's device rectangle when + \a system is Qt::DeviceCoordinates. + + \sa draw(), boundingRect() +*/ +QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const +{ + Q_D(const QGraphicsEffect); + if (d->source) + return d->source->pixmap(system, offset, mode); + return QPixmap(); +} + QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate() { invalidateCache(); @@ -327,7 +378,7 @@ QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate() void QGraphicsEffectSourcePrivate::invalidateCache(bool effectRectChanged) const { - if (effectRectChanged && m_cachedMode != QGraphicsEffectSource::ExpandToEffectRectPadMode) + if (effectRectChanged && m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect) return; QPixmapCache::remove(m_cacheKey); } @@ -359,9 +410,9 @@ QGraphicsEffect::~QGraphicsEffect() } /*! - Returns the bounding rectangle for this effect, i.e., the bounding - rectangle of the source, adjusted by any margins applied by the effect - itself. + Returns the effective bounding rectangle for this effect, i.e., the + bounding rectangle of the source, adjusted by any margins applied by + the effect itself. \sa boundingRectFor(), updateBoundingRect() */ @@ -374,12 +425,13 @@ QRectF QGraphicsEffect::boundingRect() const } /*! - Returns the bounding rectangle for this effect, given the provided source - \a rect. When writing you own custom effect, you must call - updateBoundingRect() whenever any parameters are changed that may cause - this this function to return a different value. + Returns the effective bounding rectangle for this effect, given the + provided \a rect in the source's coordinate space. When writing + you own custom effect, you must call updateBoundingRect() whenever any + parameters are changed that may cause this this function to return a + different value. - \sa boundingRect() + \sa sourceBoundingRect() */ QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const { @@ -445,6 +497,8 @@ void QGraphicsEffect::update() } /*! + \internal + Returns a pointer to the source, which provides extra context information that can be useful for the effect. @@ -464,7 +518,7 @@ QGraphicsEffectSource *QGraphicsEffect::source() const This function will call update() if this is necessary. - \sa boundingRectFor(), boundingRect() + \sa boundingRectFor(), boundingRect(), sourceBoundingRect() */ void QGraphicsEffect::updateBoundingRect() { @@ -476,15 +530,13 @@ void QGraphicsEffect::updateBoundingRect() } /*! - \fn virtual void QGraphicsEffect::draw(QPainter *painter, - QGraphicsEffectSource *source) = 0 + \fn virtual void QGraphicsEffect::draw(QPainter *painter) = 0 This pure virtual function draws the effect and is called whenever the - source() needs to be drawn. + source needs to be drawn. Reimplement this function in a QGraphicsEffect subclass to provide the - effect's drawing implementation, using \a painter. The \a source parameter - is provided for convenience; its value is the same as source(). + effect's drawing implementation, using \a painter. For example: @@ -492,8 +544,6 @@ void QGraphicsEffect::updateBoundingRect() This function should not be called explicitly by the user, since it is meant for reimplementation purposes only. - - \sa QGraphicsEffectSource */ /*! @@ -509,6 +559,20 @@ void QGraphicsEffect::updateBoundingRect() */ /*! + \enum QGraphicsEffect::PixmapPadMode + + This enum describes how the pixmap returned from sourcePixmap should be + padded. + + \value NoPad The pixmap should not receive any additional + padding. + \value PadToTransparentBorder The pixmap should be padded + to ensure it has a completely transparent border. + \value PadToEffectiveBoundingRect The pixmap should be padded to + match the effective bounding rectangle of the effect. +*/ + +/*! This virtual function is called by QGraphicsEffect to notify the effect that the source has changed. If the effect applies any cache, then this cache must be purged in order to reflect the new appearance of the source. @@ -615,26 +679,25 @@ void QGraphicsColorizeEffect::setStrength(qreal strength) /*! \reimp */ -void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsColorizeEffect::draw(QPainter *painter) { Q_D(QGraphicsColorizeEffect); if (!d->opaque) { - source->draw(painter); + drawSource(painter); return; } QPoint offset; - if (source->isPixmap()) { + if (sourceIsPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset, - QGraphicsEffectSource::NoExpandPadMode); + const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad); d->filter->draw(painter, offset, pixmap); return; } // Draw pixmap in deviceCoordinates to avoid pixmap scaling. - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -649,7 +712,7 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou A blur effect blurs the source. This effect is useful for reducing details, such as when the source loses focus and you want to draw attention to other elements. The level of detail can be modified using the setBlurRadius() - function. Use setBlurHint() to choose the quality or performance blur hints. + function. Use setBlurHints() to choose the blur hints. By default, the blur radius is 5 pixels. @@ -666,15 +729,17 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou blur effects are applied. The hints might not have an effect in all the paint engines. - \value QualityHint Indicates that rendering quality is the most important factor, - at the potential cost of lower performance. - \value PerformanceHint Indicates that rendering performance is the most important factor, at the potential cost of lower quality. + \value QualityHint Indicates that rendering quality is the most important factor, + at the potential cost of lower performance. + \value AnimationHint Indicates that the blur radius is going to be animated, hinting - that the implementation can keep a cache of blurred verisons of the source pixmap. - Do not use this hint if the source item is going to be dynamically changing. + that the implementation can keep a cache of blurred verisons of the source. + Do not use this hint if the source is going to be dynamically changing. + + \sa blurHints(), setBlurHints() */ @@ -686,7 +751,7 @@ QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent) { Q_D(QGraphicsBlurEffect); - d->filter->setBlurHint(QGraphicsBlurEffect::PerformanceHint); + d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint); } /*! @@ -730,7 +795,7 @@ void QGraphicsBlurEffect::setBlurRadius(qreal radius) */ /*! - \property QGraphicsBlurEffect::blurHint + \property QGraphicsBlurEffect::blurHints \brief the blur hint of the effect. Use the PerformanceHint hint to say that you want a faster blur, @@ -739,27 +804,27 @@ void QGraphicsBlurEffect::setBlurRadius(qreal radius) By default, the blur hint is PerformanceHint. */ -QGraphicsBlurEffect::BlurHint QGraphicsBlurEffect::blurHint() const +QGraphicsBlurEffect::BlurHints QGraphicsBlurEffect::blurHints() const { Q_D(const QGraphicsBlurEffect); - return d->filter->blurHint(); + return d->filter->blurHints(); } -void QGraphicsBlurEffect::setBlurHint(QGraphicsBlurEffect::BlurHint hint) +void QGraphicsBlurEffect::setBlurHints(QGraphicsBlurEffect::BlurHints hints) { Q_D(QGraphicsBlurEffect); - if (d->filter->blurHint() == hint) + if (d->filter->blurHints() == hints) return; - d->filter->setBlurHint(hint); - emit blurHintChanged(hint); + d->filter->setBlurHints(hints); + emit blurHintsChanged(hints); } /*! - \fn void QGraphicsBlurEffect::blurHintChanged(QGraphicsBlurEffect::BlurHint hint) + \fn void QGraphicsBlurEffect::blurHintsChanged(QGraphicsBlurEffect::BlurHints hints) - This signal is emitted whenever the effect's blur hint changes. - The \a hint parameter holds the effect's new blur hint. + This signal is emitted whenever the effect's blur hints changes. + The \a hints parameter holds the effect's new blur hints. */ /*! @@ -774,21 +839,21 @@ QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const /*! \reimp */ -void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsBlurEffect::draw(QPainter *painter) { Q_D(QGraphicsBlurEffect); if (d->filter->radius() <= 0) { - source->draw(painter); + drawSource(painter); return; } - QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToEffectRectPadMode; + PixmapPadMode mode = PadToEffectiveBoundingRect; if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) - mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode; + mode = PadToTransparentBorder; // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, mode); + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -963,21 +1028,21 @@ QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const /*! \reimp */ -void QGraphicsDropShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsDropShadowEffect::draw(QPainter *painter) { Q_D(QGraphicsDropShadowEffect); if (d->filter->blurRadius() <= 0 && d->filter->offset().isNull()) { - source->draw(painter); + drawSource(painter); return; } - QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToEffectRectPadMode; + PixmapPadMode mode = PadToEffectiveBoundingRect; if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) - mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode; + mode = PadToTransparentBorder; // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, mode); + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -1100,7 +1165,7 @@ void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) /*! \reimp */ -void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsOpacityEffect::draw(QPainter *painter) { Q_D(QGraphicsOpacityEffect); @@ -1110,18 +1175,16 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour // Opaque; draw directly without going through a pixmap. if (d->isFullyOpaque && !d->hasOpacityMask) { - source->draw(painter); + drawSource(painter); return; } - QPoint offset; - Qt::CoordinateSystem system = source->isPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates; - QPixmap pixmap = source->pixmap(system, &offset, QGraphicsEffectSource::NoExpandPadMode); + Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates; + QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad); if (pixmap.isNull()) return; - painter->save(); painter->setOpacity(d->opacity); @@ -1133,7 +1196,7 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour QTransform worldTransform = painter->worldTransform(); worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y()); pixmapPainter.setWorldTransform(worldTransform); - pixmapPainter.fillRect(source->boundingRect(), d->opacityMask); + pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask); } else { pixmapPainter.translate(-offset); pixmapPainter.fillRect(pixmap.rect(), d->opacityMask); diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 5c73f4b..2257f01 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -60,46 +60,7 @@ class QStyleOption; class QPainter; class QPixmap; -class QGraphicsEffectSourcePrivate; -class Q_GUI_EXPORT QGraphicsEffectSource : public QObject -{ - Q_OBJECT -public: - enum PixmapPadMode { - NoExpandPadMode, - ExpandToTransparentBorderPadMode, - ExpandToEffectRectPadMode - }; - - ~QGraphicsEffectSource(); - const QGraphicsItem *graphicsItem() const; - const QWidget *widget() const; - const QStyleOption *styleOption() const; - - bool isPixmap() const; - void draw(QPainter *painter); - void update(); - - QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; - QRect deviceRect() const; - QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, - QPoint *offset = 0, - PixmapPadMode mode = ExpandToEffectRectPadMode) const; - -protected: - QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); - -private: - Q_DECLARE_PRIVATE(QGraphicsEffectSource) - Q_DISABLE_COPY(QGraphicsEffectSource) - friend class QGraphicsEffect; - friend class QGraphicsEffectPrivate; - friend class QGraphicsScenePrivate; - friend class QGraphicsItem; - friend class QGraphicsItemPrivate; - friend class QWidget; - friend class QWidgetPrivate; -}; +class QGraphicsEffectSource; class QGraphicsEffectPrivate; class Q_GUI_EXPORT QGraphicsEffect : public QObject @@ -116,14 +77,18 @@ public: }; Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) + enum PixmapPadMode { + NoPad, + PadToTransparentBorder, + PadToEffectiveBoundingRect + }; + QGraphicsEffect(QObject *parent = 0); virtual ~QGraphicsEffect(); - virtual QRectF boundingRectFor(const QRectF &rect) const; + virtual QRectF boundingRectFor(const QRectF &sourceRect) const; QRectF boundingRect() const; - QGraphicsEffectSource *source() const; - bool isEnabled() const; public Q_SLOTS: @@ -135,10 +100,17 @@ Q_SIGNALS: protected: QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0); - virtual void draw(QPainter *painter, QGraphicsEffectSource *source) = 0; + virtual void draw(QPainter *painter) = 0; virtual void sourceChanged(ChangeFlags flags); void updateBoundingRect(); + bool sourceIsPixmap() const; + QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const; + void drawSource(QPainter *painter); + QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, + QPoint *offset = 0, + PixmapPadMode mode = PadToEffectiveBoundingRect) const; + private: Q_DECLARE_PRIVATE(QGraphicsEffect) Q_DISABLE_COPY(QGraphicsEffect) @@ -147,6 +119,10 @@ private: friend class QGraphicsScenePrivate; friend class QWidget; friend class QWidgetPrivate; + +public: + QGraphicsEffectSource *source() const; // internal + }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags) @@ -172,7 +148,7 @@ Q_SIGNALS: void strengthChanged(qreal strength); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: Q_DECLARE_PRIVATE(QGraphicsColorizeEffect) @@ -183,38 +159,42 @@ class QGraphicsBlurEffectPrivate; class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect { Q_OBJECT + Q_FLAGS(BlurHint BlurHints) Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) - Q_PROPERTY(BlurHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) + Q_PROPERTY(BlurHints blurHints READ blurHints WRITE setBlurHints NOTIFY blurHintsChanged) public: enum BlurHint { - QualityHint, - PerformanceHint, - AnimationHint + PerformanceHint = 0x00, + QualityHint = 0x01, + AnimationHint = 0x02 }; + Q_DECLARE_FLAGS(BlurHints, BlurHint) QGraphicsBlurEffect(QObject *parent = 0); ~QGraphicsBlurEffect(); QRectF boundingRectFor(const QRectF &rect) const; qreal blurRadius() const; - BlurHint blurHint() const; + BlurHints blurHints() const; public Q_SLOTS: void setBlurRadius(qreal blurRadius); - void setBlurHint(BlurHint hint); + void setBlurHints(BlurHints hints); Q_SIGNALS: void blurRadiusChanged(qreal blurRadius); - void blurHintChanged(BlurHint hint); + void blurHintsChanged(BlurHints hints); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: Q_DECLARE_PRIVATE(QGraphicsBlurEffect) Q_DISABLE_COPY(QGraphicsBlurEffect) }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsBlurEffect::BlurHints) + class QGraphicsDropShadowEffectPrivate; class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect { @@ -264,7 +244,7 @@ Q_SIGNALS: void colorChanged(const QColor &color); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect) @@ -293,7 +273,7 @@ Q_SIGNALS: void opacityMaskChanged(const QBrush &mask); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: Q_DECLARE_PRIVATE(QGraphicsOpacityEffect) diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index d94d08d..0011eef 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -63,6 +63,41 @@ #ifndef QT_NO_GRAPHICSEFFECT QT_BEGIN_NAMESPACE +class QGraphicsEffectSourcePrivate; +class Q_GUI_EXPORT QGraphicsEffectSource : public QObject +{ + Q_OBJECT +public: + ~QGraphicsEffectSource(); + const QGraphicsItem *graphicsItem() const; + const QWidget *widget() const; + const QStyleOption *styleOption() const; + + bool isPixmap() const; + void draw(QPainter *painter); + void update(); + + QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; + QRect deviceRect() const; + QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, + QPoint *offset = 0, + QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect) const; + +protected: + QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); + +private: + Q_DECLARE_PRIVATE(QGraphicsEffectSource) + Q_DISABLE_COPY(QGraphicsEffectSource) + friend class QGraphicsEffect; + friend class QGraphicsEffectPrivate; + friend class QGraphicsScenePrivate; + friend class QGraphicsItem; + friend class QGraphicsItemPrivate; + friend class QWidget; + friend class QWidgetPrivate; +}; + class QGraphicsEffectSourcePrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QGraphicsEffectSource) @@ -70,7 +105,7 @@ public: QGraphicsEffectSourcePrivate() : QObjectPrivate() , m_cachedSystem(Qt::DeviceCoordinates) - , m_cachedMode(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + , m_cachedMode(QGraphicsEffect::PadToTransparentBorder) {} virtual ~QGraphicsEffectSourcePrivate(); @@ -84,7 +119,7 @@ public: virtual void update() = 0; virtual bool isPixmap() const = 0; virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0, - QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode) const = 0; + QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToTransparentBorder) const = 0; virtual void effectBoundingRectChanged() = 0; void invalidateCache(bool effectRectChanged = false) const; @@ -94,7 +129,7 @@ public: private: mutable Qt::CoordinateSystem m_cachedSystem; - mutable QGraphicsEffectSource::PixmapPadMode m_cachedMode; + mutable QGraphicsEffect::PixmapPadMode m_cachedMode; mutable QPoint m_cachedOffset; mutable QPixmapCache::Key m_cacheKey; }; diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index 911a77e..ae5570f 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -600,7 +600,7 @@ static void blit_template(QScreen *screen, const QImage &image, const int screenStride = screen->linestep(); const int imageStride = image.bytesPerLine(); - if (region.numRects() == 1) { + if (region.rectCount() == 1) { const QRect r = region.boundingRect(); const SRC *src = reinterpret_cast<const SRC*>(image.scanLine(r.y())) + r.x(); @@ -1385,7 +1385,7 @@ QImage::Format QScreenPrivate::preferredImageFormat() const QScreen provides several functions to retrieve information about the color palette: The clut() function returns a pointer to the - color lookup table (i.e. its color palette). Use the numCols() + color lookup table (i.e. its color palette). Use the colorCount() function to determine the number of entries in this table, and the alloc() function to retrieve the palette index of the color that is the closest match to a given RGB value. @@ -1998,12 +1998,20 @@ QImage::Format QScreenPrivate::preferredImageFormat() const i.e. in modes where only the palette indexes (and not the actual color values) are stored in memory. - \sa alloc(), depth(), numCols() + \sa alloc(), depth(), colorCount() */ /*! + \obsolete \fn int QScreen::numCols() + \sa colorCount() +*/ + +/*! + \since 4.6 + \fn int QScreen::colorCount() + Returns the number of entries in the screen's color lookup table (i.e. its color palette). A pointer to the color table can be retrieved using the clut() function. @@ -2103,7 +2111,7 @@ void QScreen::setPixelFormat(QImage::Format format) i.e. in modes where only the palette indexes (and not the actual color values) are stored in memory. - \sa clut(), numCols() + \sa clut(), colorCount() */ int QScreen::alloc(unsigned int r,unsigned int g,unsigned int b) @@ -2455,7 +2463,7 @@ void QScreen::exposeRegion(QRegion r, int windowIndex) delete blendBuffer; } - if (r.numRects() == 1) { + if (r.rectCount() == 1) { setDirty(r.boundingRect()); } else { const QVector<QRect> rects = r.rects(); diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h index d20d709..b3246f9 100644 --- a/src/gui/embedded/qscreen_qws.h +++ b/src/gui/embedded/qscreen_qws.h @@ -243,7 +243,8 @@ public: int totalSize() const { return mapsize; } QRgb * clut() { return screenclut; } - int numCols() { return screencols; } + QT_DEPRECATED int numCols() { return screencols; } + int colorCount() { return screencols; } virtual QSize mapToDevice(const QSize &) const; virtual QSize mapFromDevice(const QSize &) const; diff --git a/src/gui/embedded/qwscursor_qws.cpp b/src/gui/embedded/qwscursor_qws.cpp index 07271e1..7d5a3d1 100644 --- a/src/gui/embedded/qwscursor_qws.cpp +++ b/src/gui/embedded/qwscursor_qws.cpp @@ -534,7 +534,7 @@ void QWSCursor::set(const uchar *data, const uchar *mask, if (!width || !height || !data || !mask || cursor.isNull()) return; - cursor.setNumColors(3); + cursor.setColorCount(3); cursor.setColor(0, 0xff000000); cursor.setColor(1, 0xffffffff); cursor.setColor(2, 0x00000000); diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 3ef37f9..5f50c85 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -267,7 +267,7 @@ inline QString AnchorVertex::toString() const const AnchorVertexPair *vp = static_cast<const AnchorVertexPair *>(this); return QString::fromAscii("(%1, %2)").arg(vp->m_first->toString()).arg(vp->m_second->toString()); } else if (!m_item) { - return QString::fromAscii("NULL_%1").arg(int(this)); + return QString::fromAscii("NULL_%1").arg(quintptr(this)); } QString edge; switch (m_edge) { diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index a236b14..9d495e9 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3349,6 +3349,9 @@ QPointF QGraphicsItem::pos() const */ void QGraphicsItem::setX(qreal x) { + if (d_ptr->inDestructor) + return; + d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y())); } @@ -3370,6 +3373,9 @@ void QGraphicsItem::setX(qreal x) */ void QGraphicsItem::setY(qreal y) { + if (d_ptr->inDestructor) + return; + d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y)); } @@ -3435,6 +3441,9 @@ void QGraphicsItem::setPos(const QPointF &pos) if (d_ptr->pos == pos) return; + if (d_ptr->inDestructor) + return; + // Update and repositition. if (!(d_ptr->flags & ItemSendsGeometryChanges)) { d_ptr->setPosHelper(pos); @@ -10803,7 +10812,7 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) } QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, - QGraphicsEffectSource::PixmapPadMode mode) const + QGraphicsEffect::PixmapPadMode mode) const { const bool deviceCoordinates = (system == Qt::DeviceCoordinates); if (!info && deviceCoordinates) { @@ -10819,9 +10828,9 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP const QRectF sourceRect = boundingRect(system); QRect effectRect; - if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) { + if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); - } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) { + } else if (mode == QGraphicsEffect::PadToTransparentBorder) { // adjust by 1.5 to account for cosmetic pens effectRect = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5).toAlignedRect(); } else { diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index afc2198..75c8246 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -633,7 +633,7 @@ public: void draw(QPainter *); QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset, - QGraphicsEffectSource::PixmapPadMode mode) const; + QGraphicsEffect::PixmapPadMode mode) const; QGraphicsItem *item; QGraphicsItemPaintInfo *info; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index d1845c2..13f31b8 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4208,7 +4208,7 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion & QRect br = pixmapExposed.boundingRect(); // Don't use subpixmap if we get a full update. - if (pixmapExposed.isEmpty() || (pixmapExposed.numRects() == 1 && br.contains(pix->rect()))) { + if (pixmapExposed.isEmpty() || (pixmapExposed.rectCount() == 1 && br.contains(pix->rect()))) { pix->fill(Qt::transparent); pixmapPainter.begin(pix); } else { @@ -4656,7 +4656,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * sourced->lastEffectTransform = painter->worldTransform(); sourced->invalidateCache(); } - item->d_ptr->graphicsEffect->draw(painter, source); + item->d_ptr->graphicsEffect->draw(painter); painter->setWorldTransform(restoreTransform); sourced->info = 0; } else diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 87585a2..27fd09e 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -978,7 +978,7 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg // Step 2) If the expose region is a simple rect and the view is only // translated or scaled, search for items using // QGraphicsScene::items(QRectF). - bool simpleRectLookup = exposedRegion.numRects() == 1 && matrix.type() <= QTransform::TxScale; + bool simpleRectLookup = exposedRegion.rectCount() == 1 && matrix.type() <= QTransform::TxScale; if (simpleRectLookup) { return scene->items(exposedRegionSceneBounds, Qt::IntersectsItemBoundingRect, diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 4b6fcba..f3eb7c3 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -52,9 +52,9 @@ QT_BEGIN_NAMESPACE static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels { int i; - if (image->depth() == 1 && image->numColors() == 2) { + if (image->depth() == 1 && image->colorCount() == 2) { register uint *p = (uint *)image->bits(); - int nbytes = image->numBytes(); + int nbytes = image->byteCount(); for (i=0; i<nbytes/4; i++) { *p = ~*p; p++; @@ -246,7 +246,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int if (depth != 32) { ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; - image.setNumColors(ncols); + image.setColorCount(ncols); } image.setDotsPerMeterX(bi.biXPelsPerMeter); @@ -526,7 +526,7 @@ bool qt_write_dib(QDataStream &s, QImage image) if (!d->isWritable()) return false; - if (image.depth() == 8 && image.numColors() <= 16) { + if (image.depth() == 8 && image.colorCount() <= 16) { bpl_bmp = (((bpl+1)/2+3)/4)*4; nbits = 4; } else if (image.depth() == 32) { @@ -554,23 +554,23 @@ bool qt_write_dib(QDataStream &s, QImage image) bi.biXPelsPerMeter = image.dotsPerMeterX() ? image.dotsPerMeterX() : 2834; // 72 dpi default bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834; - bi.biClrUsed = image.numColors(); - bi.biClrImportant = image.numColors(); + bi.biClrUsed = image.colorCount(); + bi.biClrImportant = image.colorCount(); s << bi; // write info header if (s.status() != QDataStream::Ok) return false; if (image.depth() != 32) { // write color table - uchar *color_table = new uchar[4*image.numColors()]; + uchar *color_table = new uchar[4*image.colorCount()]; uchar *rgb = color_table; QVector<QRgb> c = image.colorTable(); - for (int i=0; i<image.numColors(); i++) { + for (int i=0; i<image.colorCount(); i++) { *rgb++ = qBlue (c[i]); *rgb++ = qGreen(c[i]); *rgb++ = qRed (c[i]); *rgb++ = 0; } - if (d->write((char *)color_table, 4*image.numColors()) == -1) { + if (d->write((char *)color_table, 4*image.colorCount()) == -1) { delete [] color_table; return false; } @@ -754,7 +754,7 @@ bool QBmpHandler::write(const QImage &img) int bpl = image.bytesPerLine(); // Code partially repeated in qt_write_dib - if (image.depth() == 8 && image.numColors() <= 16) { + if (image.depth() == 8 && image.colorCount() <= 16) { bpl_bmp = (((bpl+1)/2+3)/4)*4; } else if (image.depth() == 32) { bpl_bmp = ((image.width()*24+31)/32)*4; @@ -771,7 +771,7 @@ bool QBmpHandler::write(const QImage &img) // write file header bf.bfReserved1 = 0; bf.bfReserved2 = 0; - bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.numColors() * 4; + bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.colorCount() * 4; bf.bfSize = bf.bfOffBits + bpl_bmp*image.height(); s << bf; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 21ca1e3..6d96d7a 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -449,7 +449,7 @@ bool QImageData::checkForAlphaPixels() const to the pixel() function. The pixel() function returns the color as a QRgb value indepedent of the image's format. - In case of monochrome and 8-bit images, the numColors() and + In case of monochrome and 8-bit images, the colorCount() and colorTable() functions provide information about the color components used to store the image data: The colorTable() function returns the image's entire color table. To obtain a single entry, @@ -484,7 +484,7 @@ bool QImageData::checkForAlphaPixels() const depths are 1 (monochrome), 8 and 32 (for more information see the \l {QImage#Image Formats}{Image Formats} section). - The format(), bytesPerLine(), and numBytes() functions provide + The format(), bytesPerLine(), and byteCount() functions provide low-level information about the data stored in the image. The cacheKey() function returns a number that uniquely @@ -623,7 +623,7 @@ bool QImageData::checkForAlphaPixels() const \o Sets the color table used to translate color indexes. Only monochrome and 8-bit formats. \row - \o setNumColors() + \o setColorCount() \o Resizes the color table. Only monochrome and 8-bit formats. \endtable @@ -906,7 +906,7 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm If \a format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with - setNumColors() or setColorTable() before the image is used. + setColorCount() or setColorTable() before the image is used. */ QImage::QImage(uchar* data, int width, int height, Format format) : QPaintDevice() @@ -928,7 +928,7 @@ QImage::QImage(uchar* data, int width, int height, Format format) If \a format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with - setNumColors() or setColorTable() before the image is used. + setColorCount() or setColorTable() before the image is used. Unlike the similar QImage constructor that takes a non-const data buffer, this version will never alter the contents of the buffer. For example, @@ -954,7 +954,7 @@ QImage::QImage(const uchar* data, int width, int height, Format format) If \a format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with - setNumColors() or setColorTable() before the image is used. + setColorCount() or setColorTable() before the image is used. */ QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format) :QPaintDevice() @@ -974,7 +974,7 @@ QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format form If \a format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with - setNumColors() or setColorTable() before the image is used. + setColorCount() or setColorTable() before the image is used. Unlike the similar QImage constructor that takes a non-const data buffer, this version will never alter the contents of the buffer. For example, @@ -1126,7 +1126,7 @@ QImage::QImage(const QImage &image) Use the constructor that accepts a width, a height and a format (i.e. specifying the depth and bit order), in combination with the - setNumColors() function, instead. + setColorCount() function, instead. \oldcode QImage image(width, height, depth, numColors); @@ -1135,15 +1135,15 @@ QImage::QImage(const QImage &image) // For 8 bit images the default number of colors is 256. If // another number of colors is required it can be specified - // using the setNumColors() function. - image.setNumColors(numColors); + // using the setColorCount() function. + image.setColorCount(numColors); \endcode */ -QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder) +QImage::QImage(int w, int h, int depth, int colorCount, Endian bitOrder) : QPaintDevice() { - d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), numColors); + d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), colorCount); } /*! @@ -1152,7 +1152,7 @@ QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder) Use the constructor that accepts a size and a format (i.e. specifying the depth and bit order), in combination with the - setNumColors() function, instead. + setColorCount() function, instead. \oldcode QSize mySize(width, height); @@ -1163,8 +1163,8 @@ QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder) // For 8 bit images the default number of colors is 256. If // another number of colors is required it can be specified - // using the setNumColors() function. - image.setNumColors(numColors); + // using the setColorCount() function. + image.setColorCount(numColors); \endcode */ QImage::QImage(const QSize& size, int depth, int numColors, Endian bitOrder) @@ -1232,7 +1232,7 @@ QImage::QImage(uchar* data, int w, int h, int depth, const QRgb* colortable, int for (int i = 0; i < numColors; ++i) d->colortable[i] = colortable[i]; } else if (numColors) { - setNumColors(numColors); + setColorCount(numColors); } } @@ -1283,7 +1283,7 @@ QImage::QImage(uchar* data, int w, int h, int depth, int bpl, const QRgb* colort for (int i = 0; i < numColors; ++i) d->colortable[i] = colortable[i]; } else if (numColors) { - setNumColors(numColors); + setColorCount(numColors); } } #endif // Q_WS_QWS @@ -1592,17 +1592,31 @@ int QImage::depth() const } /*! + \obsolete \fn int QImage::numColors() const Returns the size of the color table for the image. - Notice that numColors() returns 0 for 32-bpp images because these + \sa setColorCount() +*/ +int QImage::numColors() const +{ + return d ? d->colortable.size() : 0; +} + +/*! + \since 4.6 + \fn int QImage::colorCount() const + + Returns the size of the color table for the image. + + Notice that colorCount() returns 0 for 32-bpp images because these images do not use color tables, but instead encode pixel values as ARGB quadruplets. - \sa setNumColors(), {QImage#Image Information}{Image Information} + \sa setColorCount(), {QImage#Image Information}{Image Information} */ -int QImage::numColors() const +int QImage::colorCount() const { return d ? d->colortable.size() : 0; } @@ -1711,7 +1725,7 @@ void QImage::setColorTable(const QVector<QRgb> colors) Returns a list of the colors contained in the image's color table, or an empty list if the image does not have a color table - \sa setColorTable(), numColors(), color() + \sa setColorTable(), colorCount(), color() */ QVector<QRgb> QImage::colorTable() const { @@ -1720,12 +1734,24 @@ QVector<QRgb> QImage::colorTable() const /*! + \obsolete + Returns the number of bytes occupied by the image data. + + \sa byteCount() +*/ +int QImage::numBytes() const +{ + return d ? d->nbytes : 0; +} + +/*! + \since 4.6 Returns the number of bytes occupied by the image data. \sa bytesPerLine(), bits(), {QImage#Image Information}{Image Information} */ -int QImage::numBytes() const +int QImage::byteCount() const { return d ? d->nbytes : 0; } @@ -1733,7 +1759,7 @@ int QImage::numBytes() const /*! Returns the number of bytes per image scanline. - This is equivalent to numBytes()/ height(). + This is equivalent to byteCount() / height(). \sa scanLine() */ @@ -1756,7 +1782,7 @@ int QImage::bytesPerLine() const */ QRgb QImage::color(int i) const { - Q_ASSERT(i < numColors()); + Q_ASSERT(i < colorCount()); return d ? d->colortable.at(i) : QRgb(uint(-1)); } @@ -1767,9 +1793,9 @@ QRgb QImage::color(int i) const given to \a colorValue. The color value is an ARGB quadruplet. If \a index is outside the current size of the color table, it is - expanded with setNumColors(). + expanded with setColorCount(). - \sa color(), numColors(), setColorTable(), {QImage#Pixel Manipulation}{Pixel + \sa color(), colorCount(), setColorTable(), {QImage#Pixel Manipulation}{Pixel Manipulation} */ void QImage::setColor(int i, QRgb c) @@ -1787,7 +1813,7 @@ void QImage::setColor(int i, QRgb c) return; if (i >= d->colortable.size()) - setNumColors(i+1); + setColorCount(i+1); d->colortable[i] = c; d->has_alpha_clut |= (qAlpha(c) != 255); } @@ -1844,7 +1870,7 @@ const uchar *QImage::scanLine(int i) const data, thus ensuring that this QImage is the only one using the current return value. - \sa scanLine(), numBytes() + \sa scanLine(), byteCount() */ uchar *QImage::bits() { @@ -2025,8 +2051,21 @@ void QImage::invertPixels(InvertMode mode) #endif /*! + \obsolete Resizes the color table to contain \a numColors entries. + \sa setColorCount() +*/ + +void QImage::setNumColors(int numColors) +{ + setColorCount(numColors); +} + +/*! + \since 4.6 + Resizes the color table to contain \a colorCount entries. + If the color table is expanded, all the extra colors will be set to transparent (i.e qRgba(0, 0, 0, 0)). @@ -2034,14 +2073,14 @@ void QImage::invertPixels(InvertMode mode) have entries for all the pixel/index values present in the image, otherwise the results are undefined. - \sa numColors(), colorTable(), setColor(), {QImage#Image + \sa colorsCount(), colorTable(), setColor(), {QImage#Image Transformations}{Image Transformations} */ -void QImage::setNumColors(int numColors) +void QImage::setColorCount(int colorCount) { if (!d) { - qWarning("QImage::setNumColors: null image"); + qWarning("QImage::setColorCount: null image"); return; } @@ -2051,17 +2090,16 @@ void QImage::setNumColors(int numColors) if (!d) return; - if (numColors == d->colortable.size()) + if (colorCount == d->colortable.size()) return; - if (numColors <= 0) { // use no color table + if (colorCount <= 0) { // use no color table d->colortable = QVector<QRgb>(); return; } int nc = d->colortable.size(); - d->colortable.resize(numColors); - for (int i = nc; i < numColors; ++i) + d->colortable.resize(colorCount); + for (int i = nc; i < colorCount; ++i) d->colortable[i] = 0; - } /*! @@ -3674,7 +3712,7 @@ QRgb QImage::pixel(int x, int y) const otherwise the parameter must be a QRgb value. If \a position is not a valid coordinate pair in the image, or if - \a index_or_rgb >= numColors() in the case of monochrome and + \a index_or_rgb >= colorCount() in the case of monochrome and 8-bit images, the result is undefined. \warning This function is expensive due to the call of the internal @@ -3835,7 +3873,7 @@ bool QImage::allGray() const } else { if (d->colortable.isEmpty()) return true; - for (int i = 0; i < numColors(); i++) + for (int i = 0; i < colorCount(); i++) if (!qIsGray(d->colortable.at(i))) return false; } @@ -3862,7 +3900,7 @@ bool QImage::isGrayscale() const case 16: return allGray(); case 8: { - for (int i = 0; i < numColors(); i++) + for (int i = 0; i < colorCount(); i++) if (d->colortable.at(i) != qRgb(i,i,i)) return false; return true; @@ -4128,7 +4166,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const int w = width(); int h = height(); QImage m(w, h, Format_MonoLSB); - m.setNumColors(2); + m.setColorCount(2); m.setColor(0, QColor(Qt::color0).rgba()); m.setColor(1, QColor(Qt::color1).rgba()); m.fill(0xff); @@ -5703,7 +5741,7 @@ QImage QImage::alphaChannel() const int h = d->height; QImage image(w, h, Format_Indexed8); - image.setNumColors(256); + image.setColorCount(256); // set up gray scale table. for (int i=0; i<256; ++i) @@ -5833,7 +5871,7 @@ static QImage smoothScaled(const QImage &source, int w, int h) { static QImage rotated90(const QImage &image) { QImage out(image.height(), image.width(), image.format()); - if (image.numColors() > 0) + if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); int h = image.height(); @@ -5872,7 +5910,7 @@ static QImage rotated90(const QImage &image) { break; default: for (int y=0; y<h; ++y) { - if (image.numColors()) + if (image.colorCount()) for (int x=0; x<w; ++x) out.setPixel(h-y-1, x, image.pixelIndex(x, y)); else @@ -5892,7 +5930,7 @@ static QImage rotated180(const QImage &image) { static QImage rotated270(const QImage &image) { QImage out(image.height(), image.width(), image.format()); - if (image.numColors() > 0) + if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); int h = image.height(); @@ -5931,7 +5969,7 @@ static QImage rotated270(const QImage &image) { break; default: for (int y=0; y<h; ++y) { - if (image.numColors()) + if (image.colorCount()) for (int x=0; x<w; ++x) out.setPixel(y, w-x-1, image.pixelIndex(x, y)); else @@ -6071,16 +6109,16 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode if (dImage.d->colortable.size() < 256) { // colors are left in the color table, so pick that one as transparent dImage.d->colortable.append(0x0); - memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.numBytes()); + memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount()); } else { - memset(dImage.bits(), 0, dImage.numBytes()); + memset(dImage.bits(), 0, dImage.byteCount()); } break; case 1: case 16: case 24: case 32: - memset(dImage.bits(), 0x00, dImage.numBytes()); + memset(dImage.bits(), 0x00, dImage.byteCount()); break; } diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 1ac56a7..d8809ef 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -165,18 +165,21 @@ public: QRect rect() const; int depth() const; - int numColors() const; + QT_DEPRECATED int numColors() const; + int colorCount() const; QRgb color(int i) const; void setColor(int i, QRgb c); - void setNumColors(int); + QT_DEPRECATED void setNumColors(int); + void setColorCount(int); bool allGray() const; bool isGrayscale() const; uchar *bits(); const uchar *bits() const; - int numBytes() const; + QT_DEPRECATED int numBytes() const; + int byteCount() const; uchar *scanLine(int); const uchar *scanLine(int) const; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index dfeea76..985a20b 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -2150,6 +2150,13 @@ QPixmapData* QPixmap::pixmapData() const */ /*! \fn int QPixmap::numCols() const + \obsolete + \internal + \sa colorCount() +*/ + +/*! \fn int QPixmap::colorCount() const + \since 4.6 \internal */ diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index d11bd03..d95b4ee 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -185,7 +185,8 @@ public: const uchar *qwsBits() const; int qwsBytesPerLine() const; QRgb *clut() const; - int numCols() const; + QT_DEPRECATED int numCols() const; + int colorCount() const; #elif defined(Q_WS_MAC) Qt::HANDLE macQDHandle() const; Qt::HANDLE macQDAlphaHandle() const; diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 9209d45..6175931 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -248,7 +248,7 @@ void QMacPixmapData::fromImage(const QImage &img, } else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) { conv8 = d == 1; // native depth wanted } else if (d == 1) { - if (image.numColors() == 2) { + if (image.colorCount() == 2) { QRgb c0 = image.color(0); // Auto: convert to best QRgb c1 = image.color(1); conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255); @@ -339,7 +339,7 @@ void QMacPixmapData::fromImage(const QImage &img, bool alphamap = image.depth() == 32; if (sfmt == QImage::Format_Indexed8) { const QVector<QRgb> rgb = image.colorTable(); - for (int i = 0, count = image.numColors(); i < count; ++i) { + for (int i = 0, count = image.colorCount(); i < count; ++i) { const int alpha = qAlpha(rgb[i]); if (alpha != 0xff) { alphamap = true; @@ -355,13 +355,13 @@ void QMacPixmapData::fromImage(const QImage &img, int get_index(QImage * qi,QRgb mycol) { int loopc; - for(loopc=0;loopc<qi->numColors();loopc++) { + for(loopc=0;loopc<qi->colorCount();loopc++) { if(qi->color(loopc)==mycol) return loopc; } - qi->setNumColors(qi->numColors()+1); - qi->setColor(qi->numColors(),mycol); - return qi->numColors(); + qi->setColorCount(qi->colorCount()+1); + qi->setColor(qi->colorCount(),mycol); + return qi->colorCount(); } QImage QMacPixmapData::toImage() const @@ -376,7 +376,7 @@ QImage QMacPixmapData::toImage() const const uint sbpr = bytesPerRow; if (format == QImage::Format_MonoLSB) { image.fill(0); - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); for (int y = 0; y < h; ++y) { diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp index a8516a5..69626ed 100644 --- a/src/gui/image/qpixmap_qws.cpp +++ b/src/gui/image/qpixmap_qws.cpp @@ -124,9 +124,14 @@ QRgb* QPixmap::clut() const int QPixmap::numCols() const { + return colorCount(); +} + +int QPixmap::colorCount() const +{ if (data && data->classId() == QPixmapData::RasterClass) { const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data()); - return d->image.numColors(); + return d->image.colorCount(); } return 0; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index fc76dc3..1b01e6f 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -119,7 +119,7 @@ void QRasterPixmapData::resize(int width, int height) is_null = (w <= 0 || h <= 0); if (pixelType() == BitmapType && !image.isNull()) { - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); } diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index cd8a4d4..f7a880c 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -443,7 +443,7 @@ void QS60PixmapData::fromSymbianBitmap(CFbsBitmap* bitmap) // Create default palette if needed if (cfbsBitmap->DisplayMode() == EGray2) { - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); @@ -526,13 +526,13 @@ void QS60PixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags const uchar *sptr = const_cast<const QImage &>(sourceImage).bits(); symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); uchar *dptr = (uchar*)cfbsBitmap->DataAddress(); - Mem::Copy(dptr, sptr, sourceImage.numBytes()); + Mem::Copy(dptr, sptr, sourceImage.byteCount()); symbianBitmapDataAccess->endDataAccess(cfbsBitmap); UPDATE_BUFFER(); if (destFormat == QImage::Format_MonoLSB) { - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); } else { @@ -835,7 +835,7 @@ void* QS60PixmapData::toNativeType(NativeType type) symbianBitmapDataAccess->beginDataAccess(newBitmap); uchar *dptr = (uchar*)newBitmap->DataAddress(); - Mem::Copy(dptr, sptr, source.numBytes()); + Mem::Copy(dptr, sptr, source.byteCount()); symbianBitmapDataAccess->endDataAccess(newBitmap); diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index c735031..3f297df 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -464,7 +464,7 @@ void QX11PixmapData::fromImage(const QImage &img, } else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) { conv8 = (d == 1); // native depth wanted } else if (d == 1) { - if (image.numColors() == 2) { + if (image.colorCount() == 2) { QRgb c0 = image.color(0); // Auto: convert to best QRgb c1 = image.color(1); conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255); @@ -489,7 +489,7 @@ void QX11PixmapData::fromImage(const QImage &img, Visual *visual = (Visual *)xinfo.visual(); XImage *xi = 0; bool trucol = (visual->c_class >= TrueColor); - int nbytes = image.numBytes(); + int nbytes = image.byteCount(); uchar *newbits= 0; #ifndef QT_NO_XRENDER @@ -631,7 +631,7 @@ void QX11PixmapData::fromImage(const QImage &img, if (d8) { // setup pixel translation QVector<QRgb> ctable = cimage.colorTable(); - for (int i=0; i < cimage.numColors(); i++) { + for (int i=0; i < cimage.colorCount(); i++) { int r = qRed (ctable[i]); int g = qGreen(ctable[i]); int b = qBlue (ctable[i]); @@ -957,8 +957,8 @@ void QX11PixmapData::fromImage(const QImage &img, if (d == 8 && !trucol) { // 8 bit pixmap int pop[256]; // pixel popularity - if (image.numColors() == 0) - image.setNumColors(1); + if (image.colorCount() == 0) + image.setColorCount(1); const QImage &cimage = image; memset(pop, 0, sizeof(int)*256); // reset popularity array @@ -988,11 +988,11 @@ void QX11PixmapData::fromImage(const QImage &img, int mindist; }; int ncols = 0; - for (int i=0; i< cimage.numColors(); i++) { // compute number of colors + for (int i=0; i< cimage.colorCount(); i++) { // compute number of colors if (pop[i] > 0) ncols++; } - for (int i = cimage.numColors(); i < 256; i++) // ignore out-of-range pixels + for (int i = cimage.colorCount(); i < 256; i++) // ignore out-of-range pixels pop[i] = 0; // works since we make sure above to have at least @@ -1651,7 +1651,7 @@ QImage QX11PixmapData::toImage() const } if (d == 1) { // bitmap - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, qRgb(255,255,255)); image.setColor(1, qRgb(0,0,0)); } else if (!trucol) { // pixmap with colormap @@ -1707,10 +1707,10 @@ QImage QX11PixmapData::toImage() const int trans; if (ncols < 256) { trans = ncols++; - image.setNumColors(ncols); // create color table + image.setColorCount(ncols); // create color table image.setColor(trans, 0x00000000); } else { - image.setNumColors(ncols); // create color table + image.setColorCount(ncols); // create color table // oh dear... no spare "transparent" pixel. // use first pixel in image (as good as any). trans = image.scanLine(0)[0]; @@ -1733,7 +1733,7 @@ QImage QX11PixmapData::toImage() const } } } else { - image.setNumColors(ncols); // create color table + image.setColorCount(ncols); // create color table } QVector<QColor> colors = QColormap::instance(xinfo.screen()).colormap(); int j = 0; diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 10194e4..38f6b5d 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -201,7 +201,7 @@ QBitmap QPixmapData::mask() const if (mask.isNull()) // allocation failed return QBitmap(); - mask.setNumColors(2); + mask.setColorCount(2); mask.setColor(0, QColor(Qt::color0).rgba()); mask.setColor(1, QColor(Qt::color1).rgba()); diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index d1bb92a..41e2923 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -113,7 +113,8 @@ public: inline int width() const { return w; } inline int height() const { return h; } - inline int numColors() const { return metric(QPaintDevice::PdmNumColors); } + QT_DEPRECATED inline int numColors() const { return metric(QPaintDevice::PdmNumColors); } + inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); } inline int depth() const { return d; } inline bool isNull() const { return is_null; } diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index d83ef2c..c0b840a 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -490,7 +490,7 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q which is applied when \l{QPixmapFilter::}{draw()} is called. The filter lets you specialize the radius of the blur as well - as hint as to whether to prefer performance or quality. + as hints as to whether to prefer performance or quality. By default, the blur effect is produced by applying an exponential filter generated from the specified blurRadius(). Paint engines @@ -505,10 +505,10 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate { public: - QPixmapBlurFilterPrivate() : radius(5), hint(QGraphicsBlurEffect::PerformanceHint) {} + QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {} qreal radius; - QGraphicsBlurEffect::BlurHint hint; + QGraphicsBlurEffect::BlurHints hints; }; @@ -554,9 +554,9 @@ qreal QPixmapBlurFilter::radius() const } /*! - Setting the blur hint to PerformanceHint causes the implementation + Setting the blur hints to PerformanceHint causes the implementation to trade off visual quality to blur the image faster. Setting the - blur hint to QualityHint causes the implementation to improve + blur hints to QualityHint causes the implementation to improve visual quality at the expense of speed. AnimationHint causes the implementation to optimize for animating @@ -568,21 +568,21 @@ qreal QPixmapBlurFilter::radius() const \internal */ -void QPixmapBlurFilter::setBlurHint(QGraphicsBlurEffect::BlurHint hint) +void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints) { Q_D(QPixmapBlurFilter); - d->hint = hint; + d->hints = hints; } /*! - Gets the blur hint of the blur filter. + Gets the blur hints of the blur filter. \internal */ -QGraphicsBlurEffect::BlurHint QPixmapBlurFilter::blurHint() const +QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const { Q_D(const QPixmapBlurFilter); - return d->hint; + return d->hints; } /*! @@ -685,7 +685,7 @@ void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter); if (blurFilter) { blurFilter->setRadius(d->radius); - blurFilter->setBlurHint(d->hint); + blurFilter->setBlurHints(d->hints); blurFilter->draw(painter, p, src, srcRect); return; } diff --git a/src/gui/image/qpixmapfilter_p.h b/src/gui/image/qpixmapfilter_p.h index 2573fc7..46e744e 100644 --- a/src/gui/image/qpixmapfilter_p.h +++ b/src/gui/image/qpixmapfilter_p.h @@ -132,10 +132,10 @@ public: ~QPixmapBlurFilter(); void setRadius(qreal radius); - void setBlurHint(QGraphicsBlurEffect::BlurHint hint); + void setBlurHints(QGraphicsBlurEffect::BlurHints hints); qreal radius() const; - QGraphicsBlurEffect::BlurHint blurHint() const; + QGraphicsBlurEffect::BlurHints blurHints() const; QRectF boundingRectFor(const QRectF &rect) const; void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const; diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 44d689d..14c863b 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -171,7 +171,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre if (image.isNull()) return; } - image.setNumColors(2); + image.setColorCount(2); image.setColor(1, qRgb(0,0,0)); image.setColor(0, qRgb(255,255,255)); } else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { @@ -199,7 +199,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre if (image.isNull()) return; } - image.setNumColors(ncols); + image.setColorCount(ncols); for (int i=0; i<ncols; i++) { int c = i*255/(ncols-1); image.setColor(i, qRgba(c,c,c,0xff)); @@ -230,7 +230,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre if (image.isNull()) return; } - image.setNumColors(info_ptr->num_palette); + image.setColorCount(info_ptr->num_palette); int i = 0; if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { while (i < info_ptr->num_trans) { @@ -508,7 +508,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage) // sanity check palette entries if (color_type == PNG_COLOR_TYPE_PALETTE && outImage->format() == QImage::Format_Indexed8) { - int color_table_size = outImage->numColors(); + int color_table_size = outImage->colorCount(); for (int y=0; y<(int)height; ++y) { uchar *p = outImage->scanLine(y); uchar *end = p + width; @@ -762,9 +762,9 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in, png_colorp palette = 0; png_bytep copy_trans = 0; - if (image.numColors()) { + if (image.colorCount()) { // Paletted - int num_palette = image.numColors(); + int num_palette = image.colorCount(); palette = new png_color[num_palette]; png_set_PLTE(png_ptr, info_ptr, palette, num_palette); int* trans = new int[num_palette]; diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index 28e4a2a..8ec9efb 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -242,11 +242,11 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q } if (nbits == 1) { // bitmap - outImage->setNumColors(2); + outImage->setColorCount(2); outImage->setColor(0, qRgb(255,255,255)); // white outImage->setColor(1, qRgb(0,0,0)); // black } else if (nbits == 8) { // graymap - outImage->setNumColors(maxc+1); + outImage->setColorCount(maxc+1); for (int i=0; i<=maxc; i++) outImage->setColor(i, qRgb(i*255/maxc,i*255/maxc,i*255/maxc)); } @@ -287,7 +287,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy } } - if (image.depth() == 1 && image.numColors() == 2) { + if (image.depth() == 1 && image.colorCount() == 2) { if (qGray(image.color(0)) < qGray(image.color(1))) { // 0=dark/black, 1=light/white - invert image.detach(); diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 1c74351..0d76ea0 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -135,7 +135,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) return false; } - outImage->setNumColors(2); + outImage->setColorCount(2); outImage->setColor(0, qRgb(255,255,255)); // white outImage->setColor(1, qRgb(0,0,0)); // black diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 4bdd16e..ac4711a 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -895,7 +895,7 @@ static bool read_xpm_body( if (image.isNull()) return false; } - image.setNumColors(ncols); + image.setColorCount(ncols); } QMap<quint64, int> colorMap; diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 3b3036d..3e00dba 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -1059,7 +1059,7 @@ QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette, painter.end(); QPixmap selected = QPixmap(QPixmap::fromImage(img)); - int n = (img.numBytes() >> 10) + 1; + int n = (img.byteCount() >> 10) + 1; if (QPixmapCache::cacheLimit() < n) QPixmapCache::setCacheLimit(n); diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index 5f5650f..6f3cbaf 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -286,7 +286,7 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) Actions with a softkey role defined are only visible in the softkey bar when the widget containing the action has focus. If no widget currently has focus, the softkey framework will traverse up the - widget parent heirarchy looking for a widget containing softkey actions. + widget parent hierarchy looking for a widget containing softkey actions. */ /*! diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 387c29b..05e75a2 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -832,6 +832,7 @@ void qt_init(QApplicationPrivate *priv, int) priv->GetGestureInfo = (PtrGetGestureInfo) &TKGetGestureInfo; priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments; #elif !defined(Q_WS_WINCE) + #if !defined(QT_NO_NATIVE_GESTURES) priv->GetGestureInfo = (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"), "GetGestureInfo"); @@ -847,6 +848,7 @@ void qt_init(QApplicationPrivate *priv, int) priv->GetGestureConfig = (PtrGetGestureConfig)QLibrary::resolve(QLatin1String("user32"), "GetGestureConfig"); + #endif // QT_NO_NATIVE_GESTURES priv->BeginPanningFeedback = (PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"), "BeginPanningFeedback"); diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp index 26cde1a..a4e7b1f 100644 --- a/src/gui/kernel/qcursor_win.cpp +++ b/src/gui/kernel/qcursor_win.cpp @@ -153,8 +153,8 @@ static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy) bool invb, invm; bbits = pixmap.toImage().convertToFormat(QImage::Format_Mono); mbits = pixmap.toImage().convertToFormat(QImage::Format_Mono); - invb = bbits.numColors() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); - invm = mbits.numColors() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); + invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); + invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); int sysW = GetSystemMetrics(SM_CXCURSOR); int sysH = GetSystemMetrics(SM_CYCURSOR); @@ -396,8 +396,8 @@ void QCursorData::update() } else { bbits = bm->toImage().convertToFormat(QImage::Format_Mono); mbits = bmm->toImage().convertToFormat(QImage::Format_Mono); - invb = bbits.numColors() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); - invm = mbits.numColors() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); + invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); + invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); } int n = qMax(1, bbits.width() / 8); int h = bbits.height(); diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ff97405..c4a25e1 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -399,6 +399,40 @@ QMouseEventEx::~QMouseEventEx() The function pos() gives the current cursor position, while oldPos() gives the old mouse position. + + There are a few similarities between the events QEvent::HoverEnter + and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave. + However, they are slightly different because we do an update() in the event + handler of HoverEnter and HoverLeave. + + QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us + consider a top-level window A containing a child B which in turn contains a + child C (all with mouse tracking enabled): + + \image hoverEvents.png + + Now, if you move the cursor from the top to the bottom in the middle of A, + you will get the following QEvent::MouseMove events: + + \list 1 + \o A::MouseMove + \o B::MouseMove + \o C::MouseMove + \endlist + + You will get the same events for QEvent::HoverMove, except that the event + always propagates to the top-level regardless whether the event is accepted + or not. It will only stop propagating with the Qt::WA_NoMousePropagation + attribute. + + In this case the events will occur in the following way: + + \list 1 + \o A::HoverMove + \o A::HoverMove, B::HoverMove + \o A::HoverMove, B::HoverMove, C::HoverMove + \endlist + */ /*! diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index abd2128..3d4bb8c 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -52,7 +52,7 @@ #ifdef Q_WS_MAC #include "qmacgesturerecognizer_mac_p.h" #endif -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(QT_NO_NATIVE_GESTURES) #include "qwinnativepangesturerecognizer_win_p.h" #endif @@ -94,7 +94,9 @@ QGestureManager::QGestureManager(QObject *parent) registerGestureRecognizer(new QTapGestureRecognizer); #endif #if defined(Q_OS_WIN) + #if !defined(QT_NO_NATIVE_GESTURES) registerGestureRecognizer(new QWinNativePanGestureRecognizer); + #endif #else registerGestureRecognizer(new QTapAndHoldGestureRecognizer); #endif diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp index 70cd5a5..5d44b3d 100644 --- a/src/gui/kernel/qlayout.cpp +++ b/src/gui/kernel/qlayout.cpp @@ -496,6 +496,21 @@ void QLayout::setContentsMargins(int left, int top, int right, int bottom) } /*! + \since 4.6 + + Sets the \a margins to use around the layout. + + By default, QLayout uses the values provided by the style. On + most platforms, the margin is 11 pixels in all directions. + + \sa contentsMargins() +*/ +void QLayout::setContentsMargins(const QMargins &margins) +{ + setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); +} + +/*! \since 4.3 Extracts the left, top, right, and bottom margins used around the @@ -521,6 +536,23 @@ void QLayout::getContentsMargins(int *left, int *top, int *right, int *bottom) c } /*! + \since 4.6 + + Returns the margins used around the layout. + + By default, QLayout uses the values provided by the style. On + most platforms, the margin is 11 pixels in all directions. + + \sa setContentsMargins() +*/ +QMargins QLayout::contentsMargins() const +{ + int left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + return QMargins(left, top, right, bottom); +} + +/*! \since 4.3 Returns the layout's geometry() rectangle, but taking into account the diff --git a/src/gui/kernel/qlayout.h b/src/gui/kernel/qlayout.h index 83cbab6..2f30294 100644 --- a/src/gui/kernel/qlayout.h +++ b/src/gui/kernel/qlayout.h @@ -46,6 +46,7 @@ #include <QtGui/qlayoutitem.h> #include <QtGui/qsizepolicy.h> #include <QtCore/qrect.h> +#include <QtCore/qmargins.h> #include <limits.h> @@ -122,7 +123,9 @@ public: void setSpacing(int); void setContentsMargins(int left, int top, int right, int bottom); + void setContentsMargins(const QMargins &margins); void getContentsMargins(int *left, int *top, int *right, int *bottom) const; + QMargins contentsMargins() const; QRect contentsRect() const; bool setAlignment(QWidget *w, Qt::Alignment alignment); diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 0ea4764..6b0441b 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -56,7 +56,7 @@ QPanGestureRecognizer::QPanGestureRecognizer() QGesture *QPanGestureRecognizer::create(QObject *target) { if (target && target->isWidgetType()) { -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(QT_NO_NATIVE_GESTURES) // for scroll areas on Windows we want to use native gestures instead if (!qobject_cast<QAbstractScrollArea *>(target->parent())) static_cast<QWidget *>(target)->setAttribute(Qt::WA_AcceptTouchEvents); @@ -77,7 +77,6 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); QGestureRecognizer::Result result; - switch (event->type()) { case QEvent::TouchBegin: { result = QGestureRecognizer::MayBeGesture; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 271b939..c776c36 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -900,7 +900,7 @@ void QWidget::setAutoFillBackground(bool enabled) passing a \c QAction with a softkey role set on it. When the widget containing the softkey actions has focus, its softkeys should appear in the user interface. Softkeys are discovered by traversing the widget - heirarchy so it is possible to define a single set of softkeys that are + hierarchy so it is possible to define a single set of softkeys that are present at all times by calling addAction() for a given top level widget. On some platforms, this concept overlaps with \c QMenuBar such that if no @@ -5238,7 +5238,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP QPainter p(pdev); p.translate(offset); context.painter = &p; - graphicsEffect->draw(&p, source); + graphicsEffect->draw(&p); paintEngine->d_func()->systemClip = QRegion(); } else { context.painter = sharedPainter; @@ -5248,7 +5248,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP } sharedPainter->save(); sharedPainter->translate(offset); - graphicsEffect->draw(sharedPainter, source); + graphicsEffect->draw(sharedPainter); sharedPainter->restore(); } sourced->context = 0; @@ -5470,7 +5470,7 @@ void QWidgetEffectSourcePrivate::draw(QPainter *painter) } QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, - QGraphicsEffectSource::PixmapPadMode mode) const + QGraphicsEffect::PixmapPadMode mode) const { const bool deviceCoordinates = (system == Qt::DeviceCoordinates); if (!context && deviceCoordinates) { @@ -5491,10 +5491,10 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * QRect effectRect; - if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) { + if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); - } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) { + } else if (mode == QGraphicsEffect::PadToTransparentBorder) { effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); } else { @@ -11781,10 +11781,6 @@ void QWidget::ungrabGesture(Qt::GestureType gesture) } -QT_END_NAMESPACE - -#include "moc_qwidget.cpp" - /*! \typedef WId \relates QWidget @@ -12101,3 +12097,8 @@ void QWidgetPrivate::_q_delayedDestroy(WId winId) delete winId; } #endif + +QT_END_NAMESPACE + +#include "moc_qwidget.cpp" + diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 151b90a..df28bac 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -824,7 +824,7 @@ public: QRectF boundingRect(Qt::CoordinateSystem system) const; void draw(QPainter *p); QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset, - QGraphicsEffectSource::PixmapPadMode mode) const; + QGraphicsEffect::PixmapPadMode mode) const; QWidget *m_widget; QWidgetPaintContext *context; diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index b7ba273..fde0d45 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -2047,10 +2047,14 @@ void QWidgetPrivate::registerTouchWindow() void QWidgetPrivate::winSetupGestures() { +#if !defined(QT_NO_NATIVE_GESTURES) Q_Q(QWidget); - if (!q || !q->isVisible()) + if (!q || !q->isVisible() || !nativeGesturePanEnabled) return; + QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); + if (!qAppPriv->SetGestureConfig) + return; WId winid = q->internalWinId(); bool needh = false; @@ -2068,11 +2072,12 @@ void QWidgetPrivate::winSetupGestures() needv = (vbarpolicy == Qt::ScrollBarAlwaysOn || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum())); singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled; - if (!winid) + if (!winid) { winid = q->winId(); // enforces the native winid on the viewport + } } #endif //QT_NO_SCROLLAREA - if (winid && qAppPriv->SetGestureConfig) { + if (winid) { GESTURECONFIG gc[1]; memset(gc, 0, sizeof(gc)); gc[0].dwID = GID_PAN; @@ -2092,6 +2097,7 @@ void QWidgetPrivate::winSetupGestures() qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0])); } +#endif } QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 28676da..7461637 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1445,7 +1445,7 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) icon_data[pos++] = image.width(); icon_data[pos++] = image.height(); if (sizeof(long) == sizeof(quint32)) { - memcpy(icon_data.data() + pos, image.scanLine(0), image.numBytes()); + memcpy(icon_data.data() + pos, image.scanLine(0), image.byteCount()); } else { for (int y = 0; y < image.height(); ++y) { uint *scanLine = reinterpret_cast<uint *>(image.scanLine(y)); diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp index 5fceb13..7dff543 100644 --- a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp +++ b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE +#if !defined(QT_NO_NATIVE_GESTURES) + QWinNativePanGestureRecognizer::QWinNativePanGestureRecognizer() { } @@ -122,4 +124,6 @@ void QWinNativePanGestureRecognizer::reset(QGesture *state) QGestureRecognizer::reset(state); } +#endif // QT_NO_NATIVE_GESTURES + QT_END_NAMESPACE diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h index 8fb0d50..7d53ed2 100644 --- a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h +++ b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE +#if !defined(QT_NO_NATIVE_GESTURES) + class QWinNativePanGestureRecognizer : public QGestureRecognizer { public: @@ -67,6 +69,8 @@ public: void reset(QGesture *state); }; +#endif // QT_NO_NATIVE_GESTURES + QT_END_NAMESPACE #endif // QWINNATIVEPANGESTURERECOGNIZER_WIN_P_H diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 6f5d892..afe9986 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -970,7 +970,7 @@ bool QBrush::operator==(const QBrush &b) const QDebug operator<<(QDebug dbg, const QBrush &b) { #ifndef Q_BROKEN_DEBUG_STREAM - char *BRUSH_STYLES[] = { + const char *BRUSH_STYLES[] = { "NoBrush", "SolidPattern", "Dense1Pattern", diff --git a/src/gui/painting/qcolormap_qws.cpp b/src/gui/painting/qcolormap_qws.cpp index ce4cd09..bc97b08 100644 --- a/src/gui/painting/qcolormap_qws.cpp +++ b/src/gui/painting/qcolormap_qws.cpp @@ -170,7 +170,7 @@ const QColor QColormap::colorAt(uint pixel) const (pixel & green_mask) >> green_shift, (pixel & blue_mask)); } - Q_ASSERT_X(int(pixel) < qt_screen->numCols(), "QColormap::colorAt", "pixel out of bounds of palette"); + Q_ASSERT_X(int(pixel) < qt_screen->colorCount(), "QColormap::colorAt", "pixel out of bounds of palette"); return QColor(qt_screen->clut()[pixel]); } diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index 88b2b7a..17b7241 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE which returns true if the matrix is non-singular (i.e. AB = BA = I). The inverted() function returns an inverted copy of \e this matrix if it is invertible (otherwise it returns the identity - matrix). In addition, QMatrix provides the det() function + matrix). In addition, QMatrix provides the determinant() function returning the matrix's determinant. Finally, the QMatrix class supports matrix multiplication, and @@ -959,9 +959,19 @@ QMatrix &QMatrix::rotate(qreal a) */ /*! + \obsolete \fn qreal QMatrix::det() const Returns the matrix's determinant. + + \sa determinant() +*/ + +/*! + \since 4.6 + \fn qreal QMatrix::determinant() const + + Returns the matrix's determinant. */ /*! @@ -985,8 +995,8 @@ QMatrix &QMatrix::rotate(qreal a) QMatrix QMatrix::inverted(bool *invertible) const { - qreal determinant = det(); - if (determinant == 0.0) { + qreal dtr = determinant(); + if (dtr == 0.0) { if (invertible) *invertible = false; // singular matrix return QMatrix(true); @@ -994,7 +1004,7 @@ QMatrix QMatrix::inverted(bool *invertible) const else { // invertible matrix if (invertible) *invertible = true; - qreal dinv = 1.0/determinant; + qreal dinv = 1.0/dtr; return QMatrix((_m22*dinv), (-_m12*dinv), (-_m21*dinv), (_m11*dinv), ((_m21*_dy - _m22*_dx)*dinv), diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index 8887f0e..152b3c9 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -101,7 +101,8 @@ public: QMatrix &rotate(qreal a); bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); } - qreal det() const { return _m11*_m22 - _m12*_m21; } + qreal determinant() const { return _m11*_m22 - _m12*_m21; } + QT_DEPRECATED qreal det() const { return _m11*_m22 - _m12*_m21; } QMatrix inverted(bool *invertible = 0) const; diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index c8e86b8..9148e4b 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -96,7 +96,8 @@ public: int logicalDpiY() const { return metric(PdmDpiY); } int physicalDpiX() const { return metric(PdmPhysicalDpiX); } int physicalDpiY() const { return metric(PdmPhysicalDpiY); } - int numColors() const { return metric(PdmNumColors); } + QT_DEPRECATED int numColors() const { return metric(PdmNumColors); } + int colorCount() const { return metric(PdmNumColors); } int depth() const { return metric(PdmDepth); } protected: diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp index e686373..c1b887c 100644 --- a/src/gui/painting/qpaintengine_mac.cpp +++ b/src/gui/painting/qpaintengine_mac.cpp @@ -1023,7 +1023,7 @@ CGImageRef qt_mac_createCGImageFromQImage(const QImage &img, const QImage **imag #endif QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(image, static_cast<const QImage *>(image)->bits(), - image->numBytes(), + image->byteCount(), drawImageReleaseData); if (imagePtr) *imagePtr = image; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 8d0b961..3f33319 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1362,7 +1362,7 @@ void QRasterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) Q_D(QRasterPaintEngine); - if (region.numRects() == 1) { + if (region.rectCount() == 1) { clip(region.boundingRect(), op); return; } @@ -4536,7 +4536,7 @@ void QClipData::setClipRect(const QRect &rect) */ void QClipData::setClipRegion(const QRegion ®ion) { - if (region.numRects() == 1) { + if (region.rectCount() == 1) { setClipRect(region.rects().at(0)); return; } diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 1fb8aab..7d1c109 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -602,7 +602,7 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op) void QPaintEngineEx::clip(const QRegion ®ion, Qt::ClipOperation op) { - if (region.numRects() == 1) + if (region.rectCount() == 1) clip(region.boundingRect(), op); QVector<QRect> rects = region.rects(); diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index b48b024..9d1d965 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -690,7 +690,7 @@ bool QRegion::intersects(const QRegion ®ion) const if (!rect_intersects(boundingRect(), region.boundingRect())) return false; - if (numRects() == 1 && region.numRects() == 1) + if (rectCount() == 1 && region.rectCount() == 1) return true; const QVector<QRect> myRects = rects(); @@ -717,7 +717,7 @@ bool QRegion::intersects(const QRect &rect) const const QRect r = rect.normalized(); if (!rect_intersects(boundingRect(), r)) return false; - if (numRects() == 1) + if (rectCount() == 1) return true; const QVector<QRect> myRects = rects(); @@ -739,6 +739,7 @@ QRegion QRegion::intersect(const QRect &r) const #endif /*! + \obsolete \fn int QRegion::numRects() const \since 4.4 @@ -746,6 +747,13 @@ QRegion QRegion::intersect(const QRect &r) const */ /*! + \fn int QRegion::rectCount() const + \since 4.6 + + Returns the number of rectangles that will be returned in rects(). +*/ + +/*! \fn bool QRegion::isEmpty() const Returns true if the region is empty; otherwise returns false. An @@ -1027,7 +1035,7 @@ void addSegmentsToPath(Segment *segment, QPainterPath &path) Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) { QPainterPath result; - if (region.numRects() == 1) { + if (region.rectCount() == 1) { result.addRect(region.boundingRect()); return result; } @@ -4317,6 +4325,12 @@ int QRegion::numRects() const return (d->qt_rgn ? d->qt_rgn->numRects : 0); } +int QRegion::rectCount() const +{ + return (d->qt_rgn ? d->qt_rgn->numRects : 0); +} + + bool QRegion::operator==(const QRegion &r) const { if (!d->qt_rgn) diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 7e459ed..2a1be86 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -116,7 +116,8 @@ public: QRect boundingRect() const; QVector<QRect> rects() const; void setRects(const QRect *rect, int num); - int numRects() const; + QT_DEPRECATED int numRects() const; + int rectCount() const; const QRegion operator|(const QRegion &r) const; const QRegion operator+(const QRegion &r) const; diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 1bd5842..45db80a 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1421,7 +1421,7 @@ QRegion QTransform::map(const QRegion &r) const return copy; } - if (t == TxScale && r.numRects() == 1) + if (t == TxScale && r.rectCount() == 1) return QRegion(mapRect(r.boundingRect())); QPainterPath p = map(qt_regionToPath(r)); diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index d412040..5060f95 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -140,7 +140,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi // Not ready for painting yet, bail out. This can happen in // QWidget::create_sys() - if (!d->image || rgn.numRects() == 0) + if (!d->image || rgn.rectCount() == 0) return; #ifdef Q_WS_WIN @@ -203,7 +203,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi wrgn.translate(-wOffset); QRect wbr = wrgn.boundingRect(); - if (wrgn.numRects() != 1) { + if (wrgn.rectCount() != 1) { int num; XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num); XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded); @@ -242,7 +242,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi } } - if (wrgn.numRects() != 1) + if (wrgn.rectCount() != 1) XSetClipMask(X11->display, d_ptr->gc, XNone); #endif // FALCON diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index e0fcb92..02ffb29 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -301,32 +301,6 @@ short QS60StylePrivate::pixelMetric(int metric) return returnValue; } -void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) -{ - if (name == propertyKeyCurrentlayout) { - static const QStringList layouts = styleProperty(propertyKeyLayouts).toStringList(); - const QString layout = value.toString(); - Q_ASSERT(layouts.contains(layout)); - const int layoutIndex = layouts.indexOf(layout); - setCurrentLayout(layoutIndex); - QApplication::setLayoutDirection(m_layoutHeaders[layoutIndex].mirroring ? Qt::RightToLeft : Qt::LeftToRight); - clearCaches(); - refreshUI(); - } -} - -QVariant QS60StylePrivate::styleProperty(const char *name) const -{ - if (name == propertyKeyLayouts) { - static QStringList layouts; - if (layouts.isEmpty()) - for (int i = 0; i < m_numberOfLayouts; i++) - layouts.append(QLatin1String(m_layoutHeaders[i].layoutName)); - return layouts; - } - return QVariant(); -} - QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *option) { QColor retColor (color); @@ -433,7 +407,7 @@ QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const return Qt::black; const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); - const int pixels = frameImage.numBytes()/sizeof(QRgb); + const int pixels = frameImage.byteCount()/sizeof(QRgb); int estimatedRed = 0; int estimatedGreen = 0; @@ -2873,24 +2847,6 @@ void QS60Style::unpolish(QApplication *application) } /*! - Sets the style property \a name to the \a value. - */ -void QS60Style::setStyleProperty(const char *name, const QVariant &value) -{ - Q_D(QS60Style); - d->setStyleProperty_specific(name, value); -} - -/*! - Returns the value of style property \a name. - */ -QVariant QS60Style::styleProperty(const char *name) const -{ - Q_D(const QS60Style); - return d->styleProperty_specific(name); -} - -/*! \reimp */ bool QS60Style::event(QEvent *e) diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index ab10792..885ea40 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -79,10 +79,6 @@ public: #ifndef Q_NO_USING_KEYWORD using QCommonStyle::polish; #endif - - void setStyleProperty(const char *name, const QVariant &value); - QVariant styleProperty(const char *name) const; - bool event(QEvent *e); #ifndef Q_WS_S60 diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 46547bf..b9789b9 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -388,14 +388,6 @@ public: // draws a specific skin part static void drawSkinPart(QS60StyleEnums::SkinParts part, QPainter *painter, const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags); - // sets style property - void setStyleProperty(const char *name, const QVariant &value); - // sets specific style property - void setStyleProperty_specific(const char *name, const QVariant &value); - // gets style property - QVariant styleProperty(const char *name) const; - // gets specific style property - QVariant styleProperty_specific(const char *name) const; // gets pixel metrics value static short pixelMetric(int metric); // gets color. 'index' is NOT 0-based. diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index c2a207c..b5f2d1c 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1014,23 +1014,6 @@ QS60StylePrivate::QS60StylePrivate() setActiveLayout(); } -void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value) -{ - if (QLatin1String(name) == QLatin1String("foo")) { - // BaR - } else { - setStyleProperty(name, value); - } -} - -QVariant QS60StylePrivate::styleProperty_specific(const char *name) const -{ - if (QLatin1String(name) == QLatin1String("foo")) - return QLatin1String("Bar"); - else - return styleProperty(name); -} - QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, int index, const QStyleOption *option) { diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 706b4e9..4317483 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -308,16 +308,6 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, return result; } -void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value) -{ - setStyleProperty(name, value); -} - -QVariant QS60StylePrivate::styleProperty_specific(const char *name) const -{ - return styleProperty(name); -} - QPixmap QS60StylePrivate::backgroundTexture() { if (!m_background) { diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 1a6bb11..ca5be0e 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -136,6 +136,23 @@ QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation() m_heap->Close(); } +#ifndef FNTSTORE_H_INLINES_SUPPORT_FMM +/* + Workaround: fntstore.h has an inlined function 'COpenFont* CBitmapFont::OpenFont()' + that returns a private data member. The header will change between SDKs. But Qt has + to build on any SDK version and run on other versions of Symbian OS. + This function performs the needed pointer arithmetic to get the right COpenFont* +*/ +COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont) +{ + const TInt offsetIOpenFont = 92; // '_FOFF(CBitmapFont, iOpenFont)' ..if iOpenFont weren't private + const TUint valueIOpenFont = *(TUint*)PtrAdd(aBitmapFont, offsetIOpenFont); + return (valueIOpenFont & 1) ? + (COpenFont*)PtrAdd(aBitmapFont, valueIOpenFont & ~1) : // New behavior: iOpenFont is offset + (COpenFont*)valueIOpenFont; // Old behavior: iOpenFont is pointer +} +#endif // FNTSTORE_H_INLINES_SUPPORT_FMM + const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(const QString &typeface) const { if (!m_extensions.contains(typeface)) { @@ -144,8 +161,14 @@ const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(c spec.iHeight = 1; const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec); Q_ASSERT(err == KErrNone && font); - CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font); - m_extensions.insert(typeface, new QFontEngineS60Extensions(font, bitmapFont->OpenFont())); + const CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font); + COpenFont *openFont = +#ifdef FNTSTORE_H_INLINES_SUPPORT_FMM + bitmapFont->openFont(); +#else + OpenFontFromBitmapFont(bitmapFont); +#endif // FNTSTORE_H_INLINES_SUPPORT_FMM + m_extensions.insert(typeface, new QFontEngineS60Extensions(font, openFont)); } return m_extensions.value(typeface); } diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp index 94974fc..f978bd8 100644 --- a/src/gui/text/qfontengine_qpf.cpp +++ b/src/gui/text/qfontengine_qpf.cpp @@ -938,7 +938,7 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph) g.advance = qRound(metrics.xoff); QT_WRITE(fd, &g, sizeof(g)); - QT_WRITE(fd, img.bits(), img.numBytes()); + QT_WRITE(fd, img.bits(), img.byteCount()); glyphPos = oldSize - glyphDataOffset; #if 0 && defined(DEBUG_FONTENGINE) @@ -948,7 +948,7 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph) quint32 *gmap = (quint32 *)(fontData + glyphMapOffset); gmap[glyph] = qToBigEndian(glyphPos); - glyphDataSize = glyphPos + sizeof(g) + img.numBytes(); + glyphDataSize = glyphPos + sizeof(g) + img.byteCount(); quint32 *blockSizePtr = (quint32 *)(fontData + glyphDataOffset - 4); *blockSizePtr = qToBigEndian(glyphDataSize); } diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 7d81d5a..b0d0baf 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -51,6 +51,7 @@ #include "qdebug.h" #include "qboxlayout.h" #include "qpainter.h" +#include "qmargins.h" #include "qabstractscrollarea_p.h" #include <qwidget.h> @@ -868,6 +869,22 @@ void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int b } /*! + \since 4.6 + Sets \a margins around the scrolling area. This is useful for + applications such as spreadsheets with "locked" rows and columns. + The marginal space is is left blank; put widgets in the unused + area. + + By default all margins are zero. + +*/ +void QAbstractScrollArea::setViewportMargins(const QMargins &margins) +{ + setViewportMargins(margins.left(), margins.top(), + margins.right(), margins.bottom()); +} + +/*! \fn bool QAbstractScrollArea::event(QEvent *event) \reimp @@ -946,7 +963,7 @@ bool QAbstractScrollArea::event(QEvent *e) if (g) { QScrollBar *hBar = horizontalScrollBar(); QScrollBar *vBar = verticalScrollBar(); - QPointF delta = g->lastOffset(); + QPointF delta = g->delta(); if (!delta.isNull()) { if (QApplication::isRightToLeft()) delta.rx() *= -1; diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h index b3a1861..18d1e96 100644 --- a/src/gui/widgets/qabstractscrollarea.h +++ b/src/gui/widgets/qabstractscrollarea.h @@ -52,6 +52,7 @@ QT_MODULE(Gui) #ifndef QT_NO_SCROLLAREA +class QMargins; class QScrollBar; class QAbstractScrollAreaPrivate; @@ -95,6 +96,7 @@ protected Q_SLOTS: protected: QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0); void setViewportMargins(int left, int top, int right, int bottom); + void setViewportMargins(const QMargins &margins); bool event(QEvent *); virtual bool viewportEvent(QEvent *); diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp index 9f9e353..f33a98f 100644 --- a/src/gui/widgets/qlcdnumber.cpp +++ b/src/gui/widgets/qlcdnumber.cpp @@ -85,7 +85,7 @@ public: decimal point with setSmallDecimalPoint(). QLCDNumber emits the overflow() signal when it is asked to display - something beyond its range. The range is set by setNumDigits(), + something beyond its range. The range is set by setDigitCount(), but setSmallDecimalPoint() also influences it. If the display is set to hexadecimal, octal or binary, the integer equivalent of the value is displayed. @@ -160,7 +160,7 @@ public: This signal is emitted whenever the QLCDNumber is asked to display a too-large number or a too-long string. - It is never emitted by setNumDigits(). + It is never emitted by setDigitCount(). */ @@ -345,7 +345,7 @@ static const char *getSegments(char ch) // gets list of segments f The \a parent and \a name arguments are passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(QWidget *parent, const char *name) @@ -367,7 +367,7 @@ QLCDNumber::QLCDNumber(QWidget *parent, const char *name) The \a parent and \a name arguments are passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name) @@ -387,7 +387,7 @@ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name) The \a parent argument is passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(QWidget *parent) @@ -407,7 +407,7 @@ QLCDNumber::QLCDNumber(QWidget *parent) The \a parent argument is passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent) @@ -426,7 +426,7 @@ void QLCDNumberPrivate::init() val = 0; base = QLCDNumber::Dec; smallPoint = false; - q->setNumDigits(ndigits); + q->setDigitCount(ndigits); q->setSegmentStyle(QLCDNumber::Filled); q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); } @@ -441,8 +441,21 @@ QLCDNumber::~QLCDNumber() /*! + \obsolete \property QLCDNumber::numDigits \brief the current number of digits displayed + \sa setDigitCount +*/ + +void QLCDNumber::setNumDigits(int numDigits) +{ + setDigitCount(numDigits); +} + +/*! + \since 4.6 + \property QLCDNumber::digitCount + \brief the current number of digits displayed Corresponds to the current number of digits. If \l QLCDNumber::smallDecimalPoint is false, the decimal point occupies @@ -453,7 +466,7 @@ QLCDNumber::~QLCDNumber() \sa smallDecimalPoint */ -void QLCDNumber::setNumDigits(int numDigits) +void QLCDNumber::setDigitCount(int numDigits) { Q_D(QLCDNumber); if (numDigits > 99) { @@ -508,13 +521,19 @@ int QLCDNumber::numDigits() const return d->ndigits; } +int QLCDNumber::digitCount() const +{ + Q_D(const QLCDNumber); + return d->ndigits; +} + /*! \overload Returns true if \a num is too big to be displayed in its entirety; otherwise returns false. - \sa display(), numDigits(), smallDecimalPoint() + \sa display(), digitCount(), smallDecimalPoint() */ bool QLCDNumber::checkOverflow(int num) const @@ -530,7 +549,7 @@ bool QLCDNumber::checkOverflow(int num) const Returns true if \a num is too big to be displayed in its entirety; otherwise returns false. - \sa display(), numDigits(), smallDecimalPoint() + \sa display(), digitCount(), smallDecimalPoint() */ bool QLCDNumber::checkOverflow(double num) const @@ -1256,7 +1275,7 @@ QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const */ QSize QLCDNumber::sizeHint() const { - return QSize(10 + 9 * (numDigits() + (smallDecimalPoint() ? 0 : 1)), 23); + return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23); } /*! \reimp */ diff --git a/src/gui/widgets/qlcdnumber.h b/src/gui/widgets/qlcdnumber.h index 9753f31..e65637d 100644 --- a/src/gui/widgets/qlcdnumber.h +++ b/src/gui/widgets/qlcdnumber.h @@ -60,6 +60,7 @@ class Q_GUI_EXPORT QLCDNumber : public QFrame // LCD number widget Q_ENUMS(Mode SegmentStyle) Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint) Q_PROPERTY(int numDigits READ numDigits WRITE setNumDigits) + Q_PROPERTY(int digitCount READ digitCount WRITE setDigitCount) Q_PROPERTY(Mode mode READ mode WRITE setMode) Q_PROPERTY(SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle) Q_PROPERTY(double value READ value WRITE display) @@ -82,8 +83,10 @@ public: bool smallDecimalPoint() const; - int numDigits() const; - void setNumDigits(int nDigits); + QT_DEPRECATED int numDigits() const; + QT_DEPRECATED void setNumDigits(int nDigits); + int digitCount() const; + void setDigitCount(int nDigits); bool checkOverflow(double num) const; bool checkOverflow(int num) const; diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index e4252b5..f5dbe1c 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1102,6 +1102,17 @@ void QLineEdit::setTextMargins(int left, int top, int right, int bottom) } /*! + \since 4.6 + Sets the \a margins around the text inside the frame. + + See also textMargins(). +*/ +void QLineEdit::setTextMargins(const QMargins &margins) +{ + setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); +} + +/*! Returns the widget's text margins for \a left, \a top, \a right, and \a bottom. \since 4.5 @@ -1121,6 +1132,18 @@ void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) con } /*! + \since 4.6 + Returns the widget's text margins. + + \sa setTextMargins() +*/ +QMargins QLineEdit::textMargins() const +{ + Q_D(const QLineEdit); + return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin); +} + +/*! \property QLineEdit::inputMask \brief The validation input mask diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index 214509a..ac918c7 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -44,6 +44,7 @@ #include <QtGui/qframe.h> #include <QtCore/qstring.h> +#include <QtCore/qmargins.h> QT_BEGIN_HEADER @@ -158,7 +159,9 @@ public: bool hasAcceptableInput() const; void setTextMargins(int left, int top, int right, int bottom); + void setTextMargins(const QMargins &margins); void getTextMargins(int *left, int *top, int *right, int *bottom) const; + QMargins textMargins() const; public Q_SLOTS: void setText(const QString &); diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 0de7421..18adc6c 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -1465,7 +1465,7 @@ bool QPlainTextEdit::event(QEvent *e) // QPlainTextEdit scrolls by lines only in vertical direction QFontMetrics fm(document()->defaultFont()); int lineHeight = fm.height(); - int newX = hBar->value() - g->lastOffset().x(); + int newX = hBar->value() - g->delta().x(); int newY = d->originalOffsetY - offset.y()/lineHeight; hBar->setValue(newX); vBar->setValue(newY); diff --git a/src/gui/widgets/qprintpreviewwidget.cpp b/src/gui/widgets/qprintpreviewwidget.cpp index d92b1ea..0074c91 100644 --- a/src/gui/widgets/qprintpreviewwidget.cpp +++ b/src/gui/widgets/qprintpreviewwidget.cpp @@ -663,7 +663,9 @@ void QPrintPreviewWidget::setZoomFactor(qreal factor) } /*! + \obsolete Returns the number of pages in the preview. + \sa pageCount() */ int QPrintPreviewWidget::numPages() const { @@ -672,6 +674,16 @@ int QPrintPreviewWidget::numPages() const } /*! + \since 4.6 + Returns the number of pages in the preview. +*/ +int QPrintPreviewWidget::pageCount() const +{ + Q_D(const QPrintPreviewWidget); + return d->pages.size(); +} + +/*! Returns the currently viewed page in the preview. */ int QPrintPreviewWidget::currentPage() const diff --git a/src/gui/widgets/qprintpreviewwidget.h b/src/gui/widgets/qprintpreviewwidget.h index 2823873..08e596d 100644 --- a/src/gui/widgets/qprintpreviewwidget.h +++ b/src/gui/widgets/qprintpreviewwidget.h @@ -82,7 +82,8 @@ public: ViewMode viewMode() const; ZoomMode zoomMode() const; int currentPage() const; - int numPages() const; + QT_DEPRECATED int numPages() const; + int pageCount() const; void setVisible(bool visible); public Q_SLOTS: |