src/declarative/graphicsitems/qdeclarativepath.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    49 
    49 
    50 QT_BEGIN_NAMESPACE
    50 QT_BEGIN_NAMESPACE
    51 
    51 
    52 /*!
    52 /*!
    53     \qmlclass PathElement QDeclarativePathElement
    53     \qmlclass PathElement QDeclarativePathElement
       
    54     \ingroup qml-view-elements
    54     \since 4.7
    55     \since 4.7
    55     \brief PathElement is the base path type.
    56     \brief PathElement is the base path type.
    56 
    57 
    57     This type is the base for all path types.  It cannot
    58     This type is the base for all path types.  It cannot
    58     be instantiated.
    59     be instantiated.
    59 
    60 
    60     \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic
    61     \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic
    61 */
    62 */
    62 
    63 
    63 /*!
    64 /*!
    64     \internal
       
    65     \class QDeclarativePathElement
       
    66 */
       
    67 
       
    68 /*!
       
    69     \qmlclass Path QDeclarativePath
    65     \qmlclass Path QDeclarativePath
       
    66     \ingroup qml-view-elements
    70     \since 4.7
    67     \since 4.7
    71     \brief A Path object defines a path for use by \l PathView.
    68     \brief A Path object defines a path for use by \l PathView.
    72 
    69 
    73     A Path is composed of one or more path segments - PathLine, PathQuad,
    70     A Path is composed of one or more path segments - PathLine, PathQuad,
    74     PathCubic.
    71     PathCubic.
    78 
    75 
    79     PathAttribute allows named attributes with values to be defined
    76     PathAttribute allows named attributes with values to be defined
    80     along the path.
    77     along the path.
    81 
    78 
    82     \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic
    79     \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic
    83 */
       
    84 
       
    85 /*!
       
    86     \internal
       
    87     \class QDeclarativePath
       
    88     \brief The QDeclarativePath class defines a path.
       
    89     \sa QDeclarativePathView
       
    90 */
    80 */
    91 QDeclarativePath::QDeclarativePath(QObject *parent)
    81 QDeclarativePath::QDeclarativePath(QObject *parent)
    92  : QObject(*(new QDeclarativePathPrivate), parent)
    82  : QObject(*(new QDeclarativePathPrivate), parent)
    93 {
    83 {
    94 }
    84 }
   472 
   462 
   473 void QDeclarativeCurve::setX(qreal x)
   463 void QDeclarativeCurve::setX(qreal x)
   474 {
   464 {
   475     if (_x != x) {
   465     if (_x != x) {
   476         _x = x;
   466         _x = x;
       
   467         emit xChanged();
   477         emit changed();
   468         emit changed();
   478     }
   469     }
   479 }
   470 }
   480 
   471 
   481 qreal QDeclarativeCurve::y() const
   472 qreal QDeclarativeCurve::y() const
   485 
   476 
   486 void QDeclarativeCurve::setY(qreal y)
   477 void QDeclarativeCurve::setY(qreal y)
   487 {
   478 {
   488     if (_y != y) {
   479     if (_y != y) {
   489         _y = y;
   480         _y = y;
       
   481         emit yChanged();
   490         emit changed();
   482         emit changed();
   491     }
   483     }
   492 }
   484 }
   493 
   485 
   494 /****************************************************************************/
   486 /****************************************************************************/
   495 
   487 
   496 /*!
   488 /*!
   497     \qmlclass PathAttribute QDeclarativePathAttribute
   489     \qmlclass PathAttribute QDeclarativePathAttribute
       
   490     \ingroup qml-view-elements
   498     \since 4.7
   491     \since 4.7
   499     \brief The PathAttribute allows setting an attribute at a given position in a Path.
   492     \brief The PathAttribute allows setting an attribute at a given position in a Path.
   500 
   493 
   501     The PathAttribute object allows attibutes consisting of a name and
   494     The PathAttribute object allows attibutes consisting of a name and
   502     a value to be specified for the endpoints of path segments.  The
   495     a value to be specified for the endpoints of path segments.  The
   520 
   513 
   521    \sa Path
   514    \sa Path
   522 */
   515 */
   523 
   516 
   524 /*!
   517 /*!
   525     \internal
       
   526     \class QDeclarativePathAttribute
       
   527     \brief The QDeclarativePathAttribute class allows to set the value of an attribute at a given position in the path.
       
   528 
       
   529     \sa QDeclarativePath
       
   530 */
       
   531 
       
   532 
       
   533 /*!
       
   534     \qmlproperty string PathAttribute::name
   518     \qmlproperty string PathAttribute::name
   535     the name of the attribute to change.
   519     the name of the attribute to change.
   536 
   520 
   537     This attribute will be available to the delegate as PathView.<name>
   521     This attribute will be available to the delegate as PathView.<name>
   538 
   522 
   574 
   558 
   575 void QDeclarativePathAttribute::setValue(qreal value)
   559 void QDeclarativePathAttribute::setValue(qreal value)
   576 {
   560 {
   577     if (_value != value) {
   561     if (_value != value) {
   578         _value = value;
   562         _value = value;
       
   563         emit valueChanged();
   579         emit changed();
   564         emit changed();
   580     }
   565     }
   581 }
   566 }
   582 
   567 
   583 /****************************************************************************/
   568 /****************************************************************************/
   584 
   569 
   585 /*!
   570 /*!
   586     \qmlclass PathLine QDeclarativePathLine
   571     \qmlclass PathLine QDeclarativePathLine
       
   572     \ingroup qml-view-elements
   587     \since 4.7
   573     \since 4.7
   588     \brief The PathLine defines a straight line.
   574     \brief The PathLine defines a straight line.
   589 
   575 
   590     The example below creates a path consisting of a straight line from
   576     The example below creates a path consisting of a straight line from
   591     0,100 to 200,100:
   577     0,100 to 200,100:
   599 
   585 
   600     \sa Path, PathQuad, PathCubic
   586     \sa Path, PathQuad, PathCubic
   601 */
   587 */
   602 
   588 
   603 /*!
   589 /*!
   604     \internal
       
   605     \class QDeclarativePathLine
       
   606     \brief The QDeclarativePathLine class defines a straight line.
       
   607 
       
   608     \sa QDeclarativePath
       
   609 */
       
   610 
       
   611 /*!
       
   612     \qmlproperty real PathLine::x
   590     \qmlproperty real PathLine::x
   613     \qmlproperty real PathLine::y
   591     \qmlproperty real PathLine::y
   614 
   592 
   615     Defines the end point of the line.
   593     Defines the end point of the line.
   616 */
   594 */
   622 
   600 
   623 /****************************************************************************/
   601 /****************************************************************************/
   624 
   602 
   625 /*!
   603 /*!
   626     \qmlclass PathQuad QDeclarativePathQuad
   604     \qmlclass PathQuad QDeclarativePathQuad
       
   605     \ingroup qml-view-elements
   627     \since 4.7
   606     \since 4.7
   628     \brief The PathQuad defines a quadratic Bezier curve with a control point.
   607     \brief The PathQuad defines a quadratic Bezier curve with a control point.
   629 
   608 
   630     The following QML produces the path shown below:
   609     The following QML produces the path shown below:
   631     \table
   610     \table
   642 
   621 
   643     \sa Path, PathCubic, PathLine
   622     \sa Path, PathCubic, PathLine
   644 */
   623 */
   645 
   624 
   646 /*!
   625 /*!
   647     \internal
       
   648     \class QDeclarativePathQuad
       
   649     \brief The QDeclarativePathQuad class defines a quadratic Bezier curve with a control point.
       
   650 
       
   651     \sa QDeclarativePath
       
   652 */
       
   653 
       
   654 
       
   655 /*!
       
   656     \qmlproperty real PathQuad::x
   626     \qmlproperty real PathQuad::x
   657     \qmlproperty real PathQuad::y
   627     \qmlproperty real PathQuad::y
   658 
   628 
   659     Defines the end point of the curve.
   629     Defines the end point of the curve.
   660 */
   630 */
   676 
   646 
   677 void QDeclarativePathQuad::setControlX(qreal x)
   647 void QDeclarativePathQuad::setControlX(qreal x)
   678 {
   648 {
   679     if (_controlX != x) {
   649     if (_controlX != x) {
   680         _controlX = x;
   650         _controlX = x;
       
   651         emit controlXChanged();
   681         emit changed();
   652         emit changed();
   682     }
   653     }
   683 }
   654 }
   684 
   655 
   685 
   656 
   693 
   664 
   694 void QDeclarativePathQuad::setControlY(qreal y)
   665 void QDeclarativePathQuad::setControlY(qreal y)
   695 {
   666 {
   696     if (_controlY != y) {
   667     if (_controlY != y) {
   697         _controlY = y;
   668         _controlY = y;
       
   669         emit controlYChanged();
   698         emit changed();
   670         emit changed();
   699     }
   671     }
   700 }
   672 }
   701 
   673 
   702 void QDeclarativePathQuad::addToPath(QPainterPath &path)
   674 void QDeclarativePathQuad::addToPath(QPainterPath &path)
   706 
   678 
   707 /****************************************************************************/
   679 /****************************************************************************/
   708 
   680 
   709 /*!
   681 /*!
   710    \qmlclass PathCubic QDeclarativePathCubic
   682    \qmlclass PathCubic QDeclarativePathCubic
       
   683     \ingroup qml-view-elements
   711     \since 4.7
   684     \since 4.7
   712    \brief The PathCubic defines a cubic Bezier curve with two control points.
   685    \brief The PathCubic defines a cubic Bezier curve with two control points.
   713 
   686 
   714     The following QML produces the path shown below:
   687     The following QML produces the path shown below:
   715     \table
   688     \table
   730 
   703 
   731     \sa Path, PathQuad, PathLine
   704     \sa Path, PathQuad, PathLine
   732 */
   705 */
   733 
   706 
   734 /*!
   707 /*!
   735     \internal
       
   736     \class QDeclarativePathCubic
       
   737     \brief The QDeclarativePathCubic class defines a cubic Bezier curve with two control points.
       
   738 
       
   739     \sa QDeclarativePath
       
   740 */
       
   741 
       
   742 /*!
       
   743     \qmlproperty real PathCubic::x
   708     \qmlproperty real PathCubic::x
   744     \qmlproperty real PathCubic::y
   709     \qmlproperty real PathCubic::y
   745 
   710 
   746     Defines the end point of the curve.
   711     Defines the end point of the curve.
   747 */
   712 */
   759 
   724 
   760 void QDeclarativePathCubic::setControl1X(qreal x)
   725 void QDeclarativePathCubic::setControl1X(qreal x)
   761 {
   726 {
   762     if (_control1X != x) {
   727     if (_control1X != x) {
   763         _control1X = x;
   728         _control1X = x;
       
   729         emit control1XChanged();
   764         emit changed();
   730         emit changed();
   765     }
   731     }
   766 }
   732 }
   767 
   733 
   768 qreal QDeclarativePathCubic::control1Y() const
   734 qreal QDeclarativePathCubic::control1Y() const
   772 
   738 
   773 void QDeclarativePathCubic::setControl1Y(qreal y)
   739 void QDeclarativePathCubic::setControl1Y(qreal y)
   774 {
   740 {
   775     if (_control1Y != y) {
   741     if (_control1Y != y) {
   776         _control1Y = y;
   742         _control1Y = y;
       
   743         emit control1YChanged();
   777         emit changed();
   744         emit changed();
   778     }
   745     }
   779 }
   746 }
   780 
   747 
   781 /*!
   748 /*!
   791 
   758 
   792 void QDeclarativePathCubic::setControl2X(qreal x)
   759 void QDeclarativePathCubic::setControl2X(qreal x)
   793 {
   760 {
   794     if (_control2X != x) {
   761     if (_control2X != x) {
   795         _control2X = x;
   762         _control2X = x;
       
   763         emit control2XChanged();
   796         emit changed();
   764         emit changed();
   797     }
   765     }
   798 }
   766 }
   799 
   767 
   800 qreal QDeclarativePathCubic::control2Y() const
   768 qreal QDeclarativePathCubic::control2Y() const
   804 
   772 
   805 void QDeclarativePathCubic::setControl2Y(qreal y)
   773 void QDeclarativePathCubic::setControl2Y(qreal y)
   806 {
   774 {
   807     if (_control2Y != y) {
   775     if (_control2Y != y) {
   808         _control2Y = y;
   776         _control2Y = y;
       
   777         emit control2YChanged();
   809         emit changed();
   778         emit changed();
   810     }
   779     }
   811 }
   780 }
   812 
   781 
   813 void QDeclarativePathCubic::addToPath(QPainterPath &path)
   782 void QDeclarativePathCubic::addToPath(QPainterPath &path)
   817 
   786 
   818 /****************************************************************************/
   787 /****************************************************************************/
   819 
   788 
   820 /*!
   789 /*!
   821     \qmlclass PathPercent QDeclarativePathPercent
   790     \qmlclass PathPercent QDeclarativePathPercent
       
   791     \ingroup qml-view-elements
   822     \since 4.7
   792     \since 4.7
   823     \brief The PathPercent manipulates the way a path is interpreted.
   793     \brief The PathPercent manipulates the way a path is interpreted.
   824 
   794 
   825     The examples below show the normal distrubution of items along a path
   795     The examples below show the normal distrubution of items along a path
   826     compared to a distribution which places 50% of the items along the
   796     compared to a distribution which places 50% of the items along the
   854     \endtable
   824     \endtable
   855 
   825 
   856     \sa Path
   826     \sa Path
   857 */
   827 */
   858 
   828 
   859 /*!
       
   860     \internal
       
   861     \class QDeclarativePathPercent
       
   862     \brief The QDeclarativePathPercent class manipulates the way a path is interpreted.
       
   863 
       
   864     QDeclarativePathPercent allows you to bunch up items (or spread out items) along various
       
   865     segments of a QDeclarativePathView's path.
       
   866 
       
   867     \sa QDeclarativePath
       
   868 
       
   869 */
       
   870 
       
   871 qreal QDeclarativePathPercent::value() const
   829 qreal QDeclarativePathPercent::value() const
   872 {
   830 {
   873     return _value;
   831     return _value;
   874 }
   832 }
   875 
   833 
   876 void QDeclarativePathPercent::setValue(qreal value)
   834 void QDeclarativePathPercent::setValue(qreal value)
   877 {
   835 {
   878     if (_value != value) {
   836     if (_value != value) {
   879         _value = value;
   837         _value = value;
       
   838         emit valueChanged();
   880         emit changed();
   839         emit changed();
   881     }
   840     }
   882 }
   841 }
   883 QT_END_NAMESPACE
   842 QT_END_NAMESPACE