From cbf3771e86272c10519394627784d6c1088f3a3b Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 23 Nov 2012 11:52:51 +0100 Subject: QtBase: examples/widgets/painting code style Change-Id: I3d3c6f3bae20ac8383279437f8f89c92195a704f Reviewed-by: hjk --- examples/widgets/painting/gradients/gradients.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'examples/widgets/painting/gradients/gradients.cpp') diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp index 1474c4ffaf..09985df8fa 100644 --- a/examples/widgets/painting/gradients/gradients.cpp +++ b/examples/widgets/painting/gradients/gradients.cpp @@ -62,7 +62,6 @@ ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent) } else { setAttribute(Qt::WA_NoBackground); - } QPolygonF points; @@ -81,13 +80,11 @@ ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent) connect(m_hoverPoints, SIGNAL(pointsChanged(QPolygonF)), this, SIGNAL(colorsChanged())); } - QPolygonF ShadeWidget::points() const { return m_hoverPoints->points(); } - uint ShadeWidget::colorAt(int x) { generateShade(); @@ -104,7 +101,6 @@ uint ShadeWidget::colorAt(int x) return 0; } - void ShadeWidget::setGradientStops(const QGradientStops &stops) { if (m_shade_type == ARGBShade) { @@ -121,7 +117,6 @@ void ShadeWidget::setGradientStops(const QGradientStops &stops) } } - void ShadeWidget::paintEvent(QPaintEvent *) { generateShade(); @@ -133,7 +128,6 @@ void ShadeWidget::paintEvent(QPaintEvent *) p.drawRect(0, 0, width() - 1, height() - 1); } - void ShadeWidget::generateShade() { if (m_shade.isNull() || m_shade.size() != size()) { @@ -167,11 +161,8 @@ void ShadeWidget::generateShade() p.fillRect(rect(), shade); } } - - } - GradientEditor::GradientEditor(QWidget *parent) : QWidget(parent) { @@ -195,13 +186,11 @@ GradientEditor::GradientEditor(QWidget *parent) connect(m_alpha_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); } - inline static bool x_less_than(const QPointF &p1, const QPointF &p2) { return p1.x() < p2.x(); } - void GradientEditor::pointsUpdated() { qreal w = m_alpha_shade->width(); @@ -217,9 +206,9 @@ void GradientEditor::pointsUpdated() qSort(points.begin(), points.end(), x_less_than); - for (int i=0; icolorAt(int(x))) >> 16, (0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8, @@ -237,7 +226,6 @@ void GradientEditor::pointsUpdated() emit gradientStopsChanged(stops); } - static void set_shade_points(const QPolygonF &points, ShadeWidget *shade) { shade->hoverPoints()->setPoints(points); @@ -255,7 +243,7 @@ void GradientEditor::setGradientStops(const QGradientStops &stops) qreal h_blue = m_blue_shade->height(); qreal h_alpha = m_alpha_shade->height(); - for (int i=0; iwidth(), h_red - qRed(color) * h_red / 255); @@ -454,7 +442,6 @@ void GradientWidget::setDefault(int config) m_renderer->setGradientStops(stops); } - GradientRenderer::GradientRenderer(QWidget *parent) : ArthurFrame(parent) { @@ -477,7 +464,6 @@ void GradientRenderer::setGradientStops(const QGradientStops &stops) update(); } - void GradientRenderer::mousePressEvent(QMouseEvent *) { setDescriptionEnabled(false); @@ -503,7 +489,7 @@ void GradientRenderer::paint(QPainter *p) g = QConicalGradient(pts.at(0), angle); } - for (int i=0; i