return QQmlListProperty<QQuickGradientStop>(this, m_stops);
}
+QGradientStops QQuickGradient::gradientStops() const
+{
+ QGradientStops stops;
+ for (int i = 0; i < m_stops.size(); ++i){
+ int j = 0;
+ while (j < stops.size() && stops.at(j).first < m_stops[i]->position())
+ j++;
+ stops.insert(j, QGradientStop(m_stops.at(i)->position(), m_stops.at(i)->color()));
+ }
+ return stops;
+}
+
void QQuickGradient::doUpdate()
{
emit updated();
QGradientStops stops;
if (d->gradient) {
- QList<QQuickGradientStop *> qxstops = d->gradient->m_stops;
- for (int i = 0; i < qxstops.size(); ++i){
- int j = 0;
- while (j < stops.size() && stops.at(j).first < qxstops[i]->position())
- j++;
- stops.insert(j, QGradientStop(qxstops.at(i)->position(), qxstops.at(i)->color()));
- }
+ stops = d->gradient->gradientStops();
}
rectangle->setGradientStops(stops);
bool m_valid : 1;
};
-class Q_AUTOTEST_EXPORT QQuickGradientStop : public QObject
+class Q_QUICK_PRIVATE_EXPORT QQuickGradientStop : public QObject
{
Q_OBJECT
QColor m_color;
};
-class Q_AUTOTEST_EXPORT QQuickGradient : public QObject
+class Q_QUICK_PRIVATE_EXPORT QQuickGradient : public QObject
{
Q_OBJECT
QQmlListProperty<QQuickGradientStop> stops();
+ QGradientStops gradientStops() const;
+
Q_SIGNALS:
void updated();
QCOMPARE(stops.at(&stops, 1)->position(), 1.0);
QCOMPARE(stops.at(&stops, 1)->color(), QColor("white"));
+ QGradientStops gradientStops = grad->gradientStops();
+ QCOMPARE(gradientStops.count(), 2);
+ QCOMPARE(gradientStops.at(0).first, 0.0);
+ QCOMPARE(gradientStops.at(0).second, QColor("gray"));
+ QCOMPARE(gradientStops.at(1).first, 1.0);
+ QCOMPARE(gradientStops.at(1).second, QColor("white"));
+
QMetaObject::invokeMethod(rect, "resetGradient");
grad = rect->gradient();