diff options
author | David Schulz <david.schulz@digia.com> | 2012-11-23 11:52:51 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-23 17:04:00 +0100 |
commit | cbf3771e86272c10519394627784d6c1088f3a3b (patch) | |
tree | f526458bba0f2c5fe8ae1c05b678d9966a4eaf77 /examples/widgets/painting/pathstroke | |
parent | 92724e533d13f56d359122d7d83ddc2316a75ef8 (diff) |
QtBase: examples/widgets/painting code style
Change-Id: I3d3c6f3bae20ac8383279437f8f89c92195a704f
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'examples/widgets/painting/pathstroke')
-rw-r--r-- | examples/widgets/painting/pathstroke/main.cpp | 1 | ||||
-rw-r--r-- | examples/widgets/painting/pathstroke/pathstroke.cpp | 135 | ||||
-rw-r--r-- | examples/widgets/painting/pathstroke/pathstroke.h | 4 |
3 files changed, 70 insertions, 70 deletions
diff --git a/examples/widgets/painting/pathstroke/main.cpp b/examples/widgets/painting/pathstroke/main.cpp index 959202b6f6..8e1c263320 100644 --- a/examples/widgets/painting/pathstroke/main.cpp +++ b/examples/widgets/painting/pathstroke/main.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "pathstroke.h" + #include <QApplication> int main(int argc, char **argv) diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp index 4b71991d04..c11c1e8160 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.cpp +++ b/examples/widgets/painting/pathstroke/pathstroke.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include "pathstroke.h" #include "arthurstyle.h" #include "arthurwidgets.h" +#include "pathstroke.h" #include <stdio.h> @@ -236,11 +236,9 @@ void PathStrokeControls::layoutForDesktop() // Set up connections - connect(animated, SIGNAL(toggled(bool)), - m_renderer, SLOT(setAnimation(bool))); + connect(animated, SIGNAL(toggled(bool)), m_renderer, SLOT(setAnimation(bool))); - connect(penWidth, SIGNAL(valueChanged(int)), - m_renderer, SLOT(setPenWidth(int))); + connect(penWidth, SIGNAL(valueChanged(int)), m_renderer, SLOT(setPenWidth(int))); connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource())); #ifdef QT_OPENGL_SUPPORT @@ -332,10 +330,14 @@ void PathStrokeControls::layoutForSmallScreens() } void PathStrokeControls::emitQuitSignal() -{ emit quitPressed(); } +{ + emit quitPressed(); +} void PathStrokeControls::emitOkSignal() -{ emit okPressed(); } +{ + emit okPressed(); +} PathStrokeWidget::PathStrokeWidget(bool smallScreen) @@ -362,19 +364,16 @@ PathStrokeWidget::PathStrokeWidget(bool smallScreen) connect(m_controls, SIGNAL(quitPressed()), QApplication::instance(), SLOT(quit())); } - void PathStrokeWidget::showControls() { m_controls->showFullScreen(); } - void PathStrokeWidget::hideControls() { m_controls->hide(); } - void PathStrokeWidget::setStyle( QStyle * style ) { QWidget::setStyle(style); @@ -388,7 +387,6 @@ void PathStrokeWidget::setStyle( QStyle * style ) } } - PathStrokeRenderer::PathStrokeRenderer(QWidget *parent, bool smallScreen) : ArthurFrame(parent) { @@ -420,9 +418,8 @@ void PathStrokeRenderer::paint(QPainter *painter) path.moveTo(m_points.at(0)); if (m_pathMode == LineMode) { - for (int i=1; i<m_points.size(); ++i) { + for (int i=1; i<m_points.size(); ++i) path.lineTo(m_points.at(i)); - } } else { int i=1; while (i + 2 < m_points.size()) { @@ -595,67 +592,67 @@ bool PathStrokeRenderer::event(QEvent *e) case QEvent::TouchBegin: touchBegin = true; case QEvent::TouchUpdate: - { - const QTouchEvent *const event = static_cast<const QTouchEvent*>(e); - const QList<QTouchEvent::TouchPoint> points = event->touchPoints(); - foreach (const QTouchEvent::TouchPoint &touchPoint, points) { - const int id = touchPoint.id(); - switch (touchPoint.state()) { - case Qt::TouchPointPressed: - { - // find the point, move it - QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values()); - int activePoint = -1; - qreal distance = -1; - const int pointsCount = m_points.size(); - for (int i=0; i<pointsCount; ++i) { - if (activePoints.contains(i)) - continue; - - qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length(); - if ((distance < 0 && d < 12 * m_pointSize) || d < distance) { - distance = d; - activePoint = i; - } - } - if (activePoint != -1) { - m_fingerPointMapping.insert(touchPoint.id(), activePoint); - m_points[activePoint] = touchPoint.pos(); - } - } - break; - case Qt::TouchPointReleased: - { - // move the point and release - QHash<int,int>::iterator it = m_fingerPointMapping.find(id); - m_points[it.value()] = touchPoint.pos(); - m_fingerPointMapping.erase(it); - } - break; - case Qt::TouchPointMoved: - { - // move the point - const int pointIdx = m_fingerPointMapping.value(id, -1); - if (pointIdx >= 0) - m_points[pointIdx] = touchPoint.pos(); + { + const QTouchEvent *const event = static_cast<const QTouchEvent*>(e); + const QList<QTouchEvent::TouchPoint> points = event->touchPoints(); + foreach (const QTouchEvent::TouchPoint &touchPoint, points) { + const int id = touchPoint.id(); + switch (touchPoint.state()) { + case Qt::TouchPointPressed: + { + // find the point, move it + QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values()); + int activePoint = -1; + qreal distance = -1; + const int pointsCount = m_points.size(); + for (int i=0; i<pointsCount; ++i) { + if (activePoints.contains(i)) + continue; + + qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length(); + if ((distance < 0 && d < 12 * m_pointSize) || d < distance) { + distance = d; + activePoint = i; } - break; - default: - break; } - } - if (m_fingerPointMapping.isEmpty()) { - e->ignore(); - return false; - } else { - if (touchBegin) { - m_wasAnimated = m_timer.isActive(); - setAnimation(false); + if (activePoint != -1) { + m_fingerPointMapping.insert(touchPoint.id(), activePoint); + m_points[activePoint] = touchPoint.pos(); } - update(); - return true; + break; + } + case Qt::TouchPointReleased: + { + // move the point and release + QHash<int,int>::iterator it = m_fingerPointMapping.find(id); + m_points[it.value()] = touchPoint.pos(); + m_fingerPointMapping.erase(it); + break; + } + case Qt::TouchPointMoved: + { + // move the point + const int pointIdx = m_fingerPointMapping.value(id, -1); + if (pointIdx >= 0) + m_points[pointIdx] = touchPoint.pos(); + break; + } + default: + break; } } + if (m_fingerPointMapping.isEmpty()) { + e->ignore(); + return false; + } else { + if (touchBegin) { + m_wasAnimated = m_timer.isActive(); + setAnimation(false); + } + update(); + return true; + } + } break; case QEvent::TouchEnd: if (m_fingerPointMapping.isEmpty()) { diff --git a/examples/widgets/painting/pathstroke/pathstroke.h b/examples/widgets/painting/pathstroke/pathstroke.h index a4b5b2d86f..6afc271e41 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.h +++ b/examples/widgets/painting/pathstroke/pathstroke.h @@ -43,6 +43,7 @@ #define PATHSTROKE_H #include "arthurwidgets.h" + #include <QtWidgets> class PathStrokeRenderer : public ArthurFrame @@ -126,6 +127,7 @@ private: class PathStrokeControls : public QWidget { Q_OBJECT + public: PathStrokeControls(QWidget* parent, PathStrokeRenderer* renderer, bool smallScreen); @@ -154,6 +156,7 @@ private slots: class PathStrokeWidget : public QWidget { Q_OBJECT + public: PathStrokeWidget(bool smallScreen); void setStyle ( QStyle * style ); @@ -165,7 +168,6 @@ private: private slots: void showControls(); void hideControls(); - }; #endif // PATHSTROKE_H |