921 |
921 |
922 Returns true if the brush is equal to the given \a brush; |
922 Returns true if the brush is equal to the given \a brush; |
923 otherwise returns false. |
923 otherwise returns false. |
924 |
924 |
925 Two brushes are equal if they have equal styles, colors and |
925 Two brushes are equal if they have equal styles, colors and |
926 pixmaps. |
926 transforms and equal pixmaps or gradients depending on the style. |
927 |
927 |
928 \sa operator!=() |
928 \sa operator!=() |
929 */ |
929 */ |
930 |
930 |
931 bool QBrush::operator==(const QBrush &b) const |
931 bool QBrush::operator==(const QBrush &b) const |
932 { |
932 { |
933 if (b.d == d) |
933 if (b.d == d) |
934 return true; |
934 return true; |
935 if (b.d->style == d->style && b.d->color == d->color) { |
935 if (b.d->style != d->style || b.d->color != d->color || b.d->transform != d->transform) |
936 switch (d->style) { |
936 return false; |
937 case Qt::TexturePattern: { |
937 switch (d->style) { |
938 QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap(); |
938 case Qt::TexturePattern: |
939 QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap(); |
939 { |
|
940 const QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap(); |
|
941 const QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap(); |
940 return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey()); |
942 return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey()); |
941 } |
943 } |
942 case Qt::LinearGradientPattern: |
944 case Qt::LinearGradientPattern: |
943 case Qt::RadialGradientPattern: |
945 case Qt::RadialGradientPattern: |
944 case Qt::ConicalGradientPattern: |
946 case Qt::ConicalGradientPattern: |
945 { |
947 { |
946 QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data()); |
948 const QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data()); |
947 QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data()); |
949 const QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data()); |
948 return d1->gradient == d2->gradient; |
950 return d1->gradient == d2->gradient; |
949 } |
|
950 default: |
|
951 return true; |
|
952 } |
951 } |
953 } |
952 default: |
954 return false; |
953 return true; |
|
954 } |
955 } |
955 } |
956 |
956 |
957 /*! |
957 /*! |
958 \fn QBrush::operator const QColor&() const |
958 \fn QBrush::operator const QColor&() const |
959 |
959 |