src/gui/painting/qbrush.cpp
changeset 30 5dc02b23752f
parent 22 79de32ba3296
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   909 
   909 
   910     Returns true if the brush is different from the given \a brush;
   910     Returns true if the brush is different from the given \a brush;
   911     otherwise returns false.
   911     otherwise returns false.
   912 
   912 
   913     Two brushes are different if they have different styles, colors or
   913     Two brushes are different if they have different styles, colors or
   914     pixmaps.
   914     transforms or different pixmaps or gradients depending on the style.
   915 
   915 
   916     \sa operator==()
   916     \sa operator==()
   917 */
   917 */
   918 
   918 
   919 /*!
   919 /*!
   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