equal
deleted
inserted
replaced
688 if (isEmpty() || region.isEmpty()) |
688 if (isEmpty() || region.isEmpty()) |
689 return false; |
689 return false; |
690 |
690 |
691 if (!rect_intersects(boundingRect(), region.boundingRect())) |
691 if (!rect_intersects(boundingRect(), region.boundingRect())) |
692 return false; |
692 return false; |
693 if (numRects() == 1 && region.numRects() == 1) |
693 if (rectCount() == 1 && region.rectCount() == 1) |
694 return true; |
694 return true; |
695 |
695 |
696 const QVector<QRect> myRects = rects(); |
696 const QVector<QRect> myRects = rects(); |
697 const QVector<QRect> otherRects = region.rects(); |
697 const QVector<QRect> otherRects = region.rects(); |
698 |
698 |
715 return false; |
715 return false; |
716 |
716 |
717 const QRect r = rect.normalized(); |
717 const QRect r = rect.normalized(); |
718 if (!rect_intersects(boundingRect(), r)) |
718 if (!rect_intersects(boundingRect(), r)) |
719 return false; |
719 return false; |
720 if (numRects() == 1) |
720 if (rectCount() == 1) |
721 return true; |
721 return true; |
722 |
722 |
723 const QVector<QRect> myRects = rects(); |
723 const QVector<QRect> myRects = rects(); |
724 for (QVector<QRect>::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it) |
724 for (QVector<QRect>::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it) |
725 if (rect_intersects(r, *it)) |
725 if (rect_intersects(r, *it)) |
737 return intersect(QRegion(r)); |
737 return intersect(QRegion(r)); |
738 } |
738 } |
739 #endif |
739 #endif |
740 |
740 |
741 /*! |
741 /*! |
|
742 \obsolete |
742 \fn int QRegion::numRects() const |
743 \fn int QRegion::numRects() const |
743 \since 4.4 |
744 \since 4.4 |
|
745 |
|
746 Returns the number of rectangles that will be returned in rects(). |
|
747 */ |
|
748 |
|
749 /*! |
|
750 \fn int QRegion::rectCount() const |
|
751 \since 4.6 |
744 |
752 |
745 Returns the number of rectangles that will be returned in rects(). |
753 Returns the number of rectangles that will be returned in rects(). |
746 */ |
754 */ |
747 |
755 |
748 /*! |
756 /*! |
1025 } |
1033 } |
1026 |
1034 |
1027 Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) |
1035 Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) |
1028 { |
1036 { |
1029 QPainterPath result; |
1037 QPainterPath result; |
1030 if (region.numRects() == 1) { |
1038 if (region.rectCount() == 1) { |
1031 result.addRect(region.boundingRect()); |
1039 result.addRect(region.boundingRect()); |
1032 return result; |
1040 return result; |
1033 } |
1041 } |
1034 |
1042 |
1035 const QVector<QRect> rects = region.rects(); |
1043 const QVector<QRect> rects = region.rects(); |
3857 } |
3865 } |
3858 |
3866 |
3859 QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) |
3867 QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) |
3860 { |
3868 { |
3861 if (a.count() > 2) { |
3869 if (a.count() > 2) { |
3862 d = new QRegionData; |
3870 QRegionPrivate *qt_rgn = PolygonRegion(a.constData(), a.size(), |
3863 d->ref = 1; |
3871 fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); |
|
3872 if (qt_rgn) { |
|
3873 d = new QRegionData; |
|
3874 d->ref = 1; |
3864 #if defined(Q_WS_X11) |
3875 #if defined(Q_WS_X11) |
3865 d->rgn = 0; |
3876 d->rgn = 0; |
3866 d->xrectangles = 0; |
3877 d->xrectangles = 0; |
3867 #elif defined(Q_WS_WIN) |
3878 #elif defined(Q_WS_WIN) |
3868 d->rgn = 0; |
3879 d->rgn = 0; |
3869 #endif |
3880 #endif |
3870 d->qt_rgn = PolygonRegion(a.constData(), a.size(), |
3881 d->qt_rgn = qt_rgn; |
3871 fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); |
3882 } else { |
|
3883 d = &shared_empty; |
|
3884 d->ref.ref(); |
|
3885 } |
3872 } else { |
3886 } else { |
3873 d = &shared_empty; |
3887 d = &shared_empty; |
3874 d->ref.ref(); |
3888 d->ref.ref(); |
3875 } |
3889 } |
3876 } |
3890 } |
3877 |
|
3878 |
3891 |
3879 QRegion::QRegion(const QRegion &r) |
3892 QRegion::QRegion(const QRegion &r) |
3880 { |
3893 { |
3881 d = r.d; |
3894 d = r.d; |
3882 d->ref.ref(); |
3895 d->ref.ref(); |
4315 int QRegion::numRects() const |
4328 int QRegion::numRects() const |
4316 { |
4329 { |
4317 return (d->qt_rgn ? d->qt_rgn->numRects : 0); |
4330 return (d->qt_rgn ? d->qt_rgn->numRects : 0); |
4318 } |
4331 } |
4319 |
4332 |
|
4333 int QRegion::rectCount() const |
|
4334 { |
|
4335 return (d->qt_rgn ? d->qt_rgn->numRects : 0); |
|
4336 } |
|
4337 |
|
4338 |
4320 bool QRegion::operator==(const QRegion &r) const |
4339 bool QRegion::operator==(const QRegion &r) const |
4321 { |
4340 { |
4322 if (!d->qt_rgn) |
4341 if (!d->qt_rgn) |
4323 return r.isEmpty(); |
4342 return r.isEmpty(); |
4324 if (!r.d->qt_rgn) |
4343 if (!r.d->qt_rgn) |