diff options
36 files changed, 1289 insertions, 914 deletions
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index e65808f..fa9f05b 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -3,18 +3,18 @@ \target qmlexamples \title QML Examples -A viewer application is included that allows you to quickly explore many of the +A \l {qmlviewer}{viewer} application is included that allows you to quickly explore many of the examples. It has some useful options, revealed by: \code - bin/duiviewer -help + bin/qmlviewer -help \endcode -There are several illustrative XML examples available. From your build +There are several illustrative QML examples available. From your build directory, \code - bin/duiviewer $QT_SOURCE_DIR/examples/declarative/mediabrowser/mediabrowser.qml + bin/qmlviewer $QT_SOURCE_DIR/demos/declarative/phonebrowser/phonebrowser.qml \endcode Many other simple examples can be found under the \c examples/declarative sub @@ -32,5 +32,4 @@ own QML-based applications. software rasterizer, a simple canvas backend is used by default. To use Graphics View instead, set \c QML_USE_GRAPHICSVIEW=1. - */ diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index e0d4ca3..fc747a9 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -48,7 +48,7 @@ element whose text is determined by whether or not it has \e {active focus}. An \l Item requests focus by setting the \c {Item::focus} property to true. For very simple cases simply setting the \c {Item::focus} property is sometimes -sufficient. If we run the following example in the \c duiviewer, we see that +sufficient. If we run the following example in the \c qmlviewer, we see that the \c {<KeyActions/>} element has \e {active focus} and pressing the \e A, \e B, or \e C keys modifies the text appropriately. diff --git a/doc/src/declarative/pics/squish.png b/doc/src/declarative/pics/squish.png Binary files differnew file mode 100644 index 0000000..73bf292 --- /dev/null +++ b/doc/src/declarative/pics/squish.png diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc index caadbf5..aa94c06 100644 --- a/doc/src/declarative/tutorial1.qdoc +++ b/doc/src/declarative/tutorial1.qdoc @@ -43,10 +43,10 @@ The \c anchors.horizontalCenter property refers to the horizontal center of an e \section2 Viewing the example -To view what you have created, run the duiviewer (located in the \c bin directory) with your filename as the first argument. For example, to run the provided completed Tutorial 1 example from the install location, you would type: +To view what you have created, run the qmlviewer (located in the \c bin directory) with your filename as the first argument. For example, to run the provided completed Tutorial 1 example from the install location, you would type: \code -bin/duiviewer examples/tutorials/t1/tutorial1.qml +bin/qmlviewer examples/tutorials/t1/tutorial1.qml \endcode [\l tutorial] [Next: \l tutorial2] diff --git a/doc/src/duiviewer.qdoc b/doc/src/qmlviewer.qdoc index f967f87..e8fdec4 100644 --- a/doc/src/duiviewer.qdoc +++ b/doc/src/qmlviewer.qdoc @@ -40,23 +40,22 @@ ****************************************************************************/ /*! - \page duiviewer.html - \title Declarative UI Viewer (duiviewer) + \page qmlviewer.html + \title Qt Declarative UI Viewer (qmlviewer) \ingroup qttools - \keyword duiviewer + \keyword qmlviewer This page documents the \e{Declarative UI Viewer} for the Qt GUI - toolkit. The \c duiviewer reads an XML format declarative user interface definition - (\c .qml) file - and displays the user interface it describes. + toolkit. The \c qmlviewer reads a declarative user interface definition + (\c .qml) file and displays the user interface it describes. \section1 Options - When run with the \c -help option, duiviewer shows available options. + When run with the \c -help option, qmlviewer shows available options. \section1 Dummy Data - One use of duiviewer is to allow QML files to be viewed stand-alone, + One use of qmlviewer is to allow QML files to be viewed stand-alone, rather than being loaded from within a Qt program. Qt applications will usually bind objects and properties into the execution context before running the QML. To stand-in for such bindings, you can provide dummy diff --git a/doc/src/tutorials/declarative.qdoc b/doc/src/tutorials/declarative.qdoc index 3724b10..16dad6e 100644 --- a/doc/src/tutorials/declarative.qdoc +++ b/doc/src/tutorials/declarative.qdoc @@ -77,7 +77,7 @@ sub directory the files are numbered in an order of increasing features. The code in this example is not compiled, but interpreted at run time. - This means you should use the duiviewer application provided with + This means you should use the qmlviewer application provided with Qt to run the examples. \list diff --git a/examples/declarative/contacts/dummydata/contactModel.qml b/examples/declarative/contacts/dummydata/contactModel.qml index 341b7a6..48b2fd9 100644 --- a/examples/declarative/contacts/dummydata/contactModel.qml +++ b/examples/declarative/contacts/dummydata/contactModel.qml @@ -1,103 +1,103 @@ -<ListModel> - <Contact> - <firstName>Aaron</firstName> - <lastName>Kennedy</lastName> - <portrait>contact.png</portrait> - <emails> - <Email address="akennedy@trolltech.com"/> - <Email address="aaron.kennedy@trolltech.com"/> - </emails> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>1</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>2</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>3</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>4</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>5</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>6</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>7</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>8</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Contact</firstName> - <lastName>9</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Alan</firstName> - <lastName>Alpert</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Betty</firstName> - <lastName>Boo</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Foo</firstName> - <lastName>Bar</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Marius</firstName> - <lastName>Bugge Monsen</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Martin</firstName> - <lastName>Jones</lastName> - <portrait>contact.png</portrait> - <emails> - <Email address="mjones@trolltech.com"/> - <Email address="martin.jones@trolltech.com"/> - </emails> - </Contact> - <Contact> - <firstName>Michael</firstName> - <lastName>Brasser</lastName> - <portrait>contact.png</portrait> - <emails> - <Email address="mbrasser@trolltech.com"/> - </emails> - </Contact> - <Contact> - <firstName>Yann</firstName> - <lastName>Bodson</lastName> - <portrait>contact.png</portrait> - </Contact> - <Contact> - <firstName>Yogi</firstName> - <lastName>Bear</lastName> - <portrait>contact.png</portrait> - </Contact> -</ListModel> +ListModel2 { + ListElement { + firstName: "Aaron" + lastName: "Kennedy" + portrait: "contact.png" + emails: [ + ListElement { address: "akennedy@trolltech.com" }, + ListElement { address: "aaron.kennedy@trolltech.com" } + ] + } + ListElement { + firstName: "ListElement" + lastName: 1 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 2 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 3 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 4 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 5 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 6 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 7 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 8 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 9 + portrait: "contact.png" + } + ListElement { + firstName: "Alan" + lastName: "Alpert" + portrait: "contact.png" + } + ListElement { + firstName: "Betty" + lastName: "Boo" + portrait: "contact.png" + } + ListElement { + firstName: "Foo" + lastName: "Bar" + portrait: "contact.png" + } + ListElement { + firstName: "Marius" + lastName: "Bugge Monsen" + portrait: "contact.png" + } + ListElement { + firstName: "Martin" + lastName: "Jones" + portrait: "contact.png" + emails: [ + ListElement { address: "mjones@trolltech.com" }, + ListElement { address: "martin.jones@trolltech.com" } + ] + } + ListElement { + firstName: "Michael" + lastName: "Brasser" + portrait: "contact.png" + emails: ListElement { + address: "mbrasser@trolltech.com" + } + } + ListElement { + firstName: "Yann" + lastName: "Bodson" + portrait: "contact.png" + } + ListElement { + firstName: "Yogi" + lastName: "Bear" + portrait: "contact.png" + } +} diff --git a/examples/declarative/easing/easing.qml b/examples/declarative/easing/easing.qml index f95d8c6..32c1b9b 100644 --- a/examples/declarative/easing/easing.qml +++ b/examples/declarative/easing/easing.qml @@ -1,67 +1,92 @@ -<Rect id="Window" width="640" height="{Layout.height}" color="white"> +Rect { + id: Window + width: 640 + height: Layout.height + color: "white" - <resources> - <ListModel id="EasingTypes"> - <ListItem><type>easeLinear</type></ListItem> - <ListItem><type>easeInQuad</type></ListItem> - <ListItem><type>easeOutQuad</type></ListItem> - <ListItem><type>easeInOutQuad</type></ListItem> - <ListItem><type>easeOutInQuad</type></ListItem> - <ListItem><type>easeInCubic</type></ListItem> - <ListItem><type>easeOutCubic</type></ListItem> - <ListItem><type>easeInOutCubic</type></ListItem> - <ListItem><type>easeOutInCubic</type></ListItem> - <ListItem><type>easeInQuart</type></ListItem> - <ListItem><type>easeOutQuart</type></ListItem> - <ListItem><type>easeInOutQuart</type></ListItem> - <ListItem><type>easeOutInQuart</type></ListItem> - <ListItem><type>easeInQuint</type></ListItem> - <ListItem><type>easeOutQuint</type></ListItem> - <ListItem><type>easeInOutQuint</type></ListItem> - <ListItem><type>easeOutInQuint</type></ListItem> - <ListItem><type>easeInSine</type></ListItem> - <ListItem><type>easeOutSine</type></ListItem> - <ListItem><type>easeInOutSine</type></ListItem> - <ListItem><type>easeOutInSine</type></ListItem> - <ListItem><type>easeInExpo</type></ListItem> - <ListItem><type>easeOutExpo</type></ListItem> - <ListItem><type>easeInOutExpo</type></ListItem> - <ListItem><type>easeOutInExpo</type></ListItem> - <ListItem><type>easeInCirc</type></ListItem> - <ListItem><type>easeOutCirc</type></ListItem> - <ListItem><type>easeInOutCirc</type></ListItem> - <ListItem><type>easeOutInCirc</type></ListItem> - <ListItem><type>easeInElastic</type></ListItem> - <ListItem><type>easeOutElastic</type></ListItem> - <ListItem><type>easeInOutElastic</type></ListItem> - <ListItem><type>easeOutInElastic</type></ListItem> - <ListItem><type>easeInBack</type></ListItem> - <ListItem><type>easeOutBack</type></ListItem> - <ListItem><type>easeInOutBack</type></ListItem> - <ListItem><type>easeOutInBack</type></ListItem> - <ListItem><type>easeOutBounce</type></ListItem> - <ListItem><type>easeInBounce</type></ListItem> - <ListItem><type>easeInOutBounce</type></ListItem> - <ListItem><type>easeOutInBounce</type></ListItem> - </ListModel> - </resources> - - <VerticalLayout id="Layout" anchors.left="{Window.left}" anchors.right="{Window.right}"> - <Repeater dataSource="{EasingTypes}"> - <Component> - <Text id="Text" text="{type}" height="18" font.italic="true"> - <x> - <SequentialAnimation id="Anim"> - <NumericAnimation from="0" to="{Window.width / 2}" easing="{type}" duration="1000"/> - <PauseAnimation duration="300"/> - <NumericAnimation to="0" from="{Window.width / 2}" easing="{type}" duration="1000"/> - </SequentialAnimation> - </x> - <children> - <MouseRegion onClicked="Anim.running=true" anchors.fill="{parent}"/> - </children> - </Text> - </Component> - </Repeater> - </VerticalLayout> -</Rect> + ListModel2 { + id: EasingTypes + ListElement { type: "easeLinear" } + ListElement { type: "easeInQuad" } + ListElement { type: "easeOutQuad" } + ListElement { type: "easeInOutQuad" } + ListElement { type: "easeOutInQuad" } + ListElement { type: "easeInCubic" } + ListElement { type: "easeOutCubic" } + ListElement { type: "easeInOutCubic" } + ListElement { type: "easeOutInCubic" } + ListElement { type: "easeInQuart" } + ListElement { type: "easeOutQuart" } + ListElement { type: "easeInOutQuart" } + ListElement { type: "easeOutInQuart" } + ListElement { type: "easeInQuint" } + ListElement { type: "easeOutQuint" } + ListElement { type: "easeInOutQuint" } + ListElement { type: "easeOutInQuint" } + ListElement { type: "easeInSine" } + ListElement { type: "easeOutSine" } + ListElement { type: "easeInOutSine" } + ListElement { type: "easeOutInSine" } + ListElement { type: "easeInExpo" } + ListElement { type: "easeOutExpo" } + ListElement { type: "easeInOutExpo" } + ListElement { type: "easeOutInExpo" } + ListElement { type: "easeInCirc" } + ListElement { type: "easeOutCirc" } + ListElement { type: "easeInOutCirc" } + ListElement { type: "easeOutInCirc" } + ListElement { type: "easeInElastic" } + ListElement { type: "easeOutElastic" } + ListElement { type: "easeInOutElastic" } + ListElement { type: "easeOutInElastic" } + ListElement { type: "easeInBack" } + ListElement { type: "easeOutBack" } + ListElement { type: "easeInOutBack" } + ListElement { type: "easeOutInBack" } + ListElement { type: "easeOutBounce" } + ListElement { type: "easeInBounce" } + ListElement { type: "easeInOutBounce" } + ListElement { type: "easeOutInBounce" } + } + + VerticalLayout { + id: Layout + anchors.left: Window.left + anchors.right: Window.right + Repeater { + dataSource: EasingTypes + Component { + Text { + id: Text + text: type + height: 18 + font.italic: true + x: SequentialAnimation { + id: Anim + NumericAnimation { + from: 0 + to: Window.width / 2 + easing: type + duration: 1000 + } + PauseAnimation { + duration: 300 + } + NumericAnimation { + to: 0 + from: Window.width / 2 + easing: type + duration: 1000 + } + } + children: [ + MouseRegion { + onClicked: { Anim.running=true } + anchors.fill: parent + } + ] + } + } + } + } +} diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml index e1617a3..1c96b7f 100644 --- a/examples/declarative/listview/dummydata/MyPetsModel.qml +++ b/examples/declarative/listview/dummydata/MyPetsModel.qml @@ -1,60 +1,59 @@ -<!-- -ListModel allows free form list models to be defined and populated. -Be sure to name the file the same as the id. ---> -<ListModel id="MyPetsModel"> - <Pet> - <name>Polly</name> - <type>Parrot</type> - <age>12</age> - <size>Small</size> - </Pet> - <Pet> - <name>Penny</name> - <type>Turtle</type> - <age>4</age> - <size>Small</size> - </Pet> - <Pet> - <name>Warren</name> - <type>Rabbit</type> - <age>2</age> - <size>Small</size> - </Pet> - <Pet> - <name>Spot</name> - <type>Dog</type> - <age>9</age> - <size>Medium</size> - </Pet> - <Pet> - <name>Whiskers</name> - <type>Cat</type> - <age>2</age> - <size>Medium</size> - </Pet> - <Pet> - <name>Joey</name> - <type>Kangaroo</type> - <age>1</age> - <size>Medium</size> - </Pet> - <Pet> - <name>Kimba</name> - <type>Bunny</type> - <age>65</age> - <size>Large</size> - </Pet> - <Pet> - <name>Rover</name> - <type>Dog</type> - <age>5</age> - <size>Large</size> - </Pet> - <Pet> - <name>Tiny</name> - <type>Elephant</type> - <age>15</age> - <size>Large</size> - </Pet> -</ListModel> +// ListModel allows free form list models to be defined and populated. +// Be sure to name the file the same as the id. +ListModel2 { + id: MyListElementsModel + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Whiskers" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/declarative/listview/dummydata/Recipies.qml b/examples/declarative/listview/dummydata/Recipies.qml index 49bc610..6b20409 100644 --- a/examples/declarative/listview/dummydata/Recipies.qml +++ b/examples/declarative/listview/dummydata/Recipies.qml @@ -1,112 +1,87 @@ -<ListModel id="Recipies"> - <Recipe title="Pancakes" picture="content/pics/pancakes.jpg"> - <ingredients> - <![CDATA[ - <html> - <ul> - <li> 1 cup (150g) self-raising flour - <li> 1 tbs caster sugar - <li> 3/4 cup (185ml) milk - <li> 1 egg - </ul> - </html> - ]]> - </ingredients> - <method> - <![CDATA[ - <html> - <ol> - <li> Sift flour and sugar together into a bowl. Add a pinch of salt. - <li> Beat milk and egg together, then add to dry ingredients. Beat until smooth. - <li> Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. - <li> Turn over and cook other side until golden. - </ol> - ]]> - </method> - </Recipe> - <Recipe title="Fruit Salad" picture="content/pics/fruit-salad.jpg"> - <ingredients> - * Seasonal Fruit - </ingredients> - <method> - * Chop fruit and place in a bowl. - </method> - </Recipe> - <Recipe title="Vegetable Soup" picture="content/pics/vegetable-soup.jpg"> - <ingredients> - <![CDATA[ - <html> - <ul> - <li> 1 onion - <li> 1 turnip - <li> 1 potato - <li> 1 carrot - <li> 1 head of celery - <li> 1 1/2 litres of water - </ul> - </html> - ]]> - </ingredients> - <method> - <![CDATA[ - <html> - <ol> - <li> Chop vegetables. - <li> Boil in water until vegetables soften. - <li> Season with salt and pepper to taste. - </ol> - </html> - ]]> - </method> - </Recipe> - <Recipe title="Hamburger" picture="content/pics/hamburger.jpg"> - <ingredients> - <![CDATA[ - <html> - <ul> - <li> 500g minced beef - <li> Seasoning - <li> lettuce, tomato, onion, cheese - <li> 1 hamburger bun for each burger - </ul> - </html> - ]]> - </ingredients> - <method> - <![CDATA[ - <html> - <ol> - <li> Mix the beef, together with seasoning, in a food processor. - <li> Shape the beef into burgers. - <li> Grill the burgers for about 5 mins on each side (until cooked through) - <li> Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. - </ol> - </html> - ]]> - </method> - </Recipe> - <Recipe title="Lemonade" picture="content/pics/lemonade.jpg"> - <ingredients> - <![CDATA[ - <html> - <ul> - <li> 1 cup Lemon Juice - <li> 1 cup Sugar - <li> 6 Cups of Water (2 cups warm water, 4 cups cold water) - </ul> - </html> - ]]> - </ingredients> - <method> - <![CDATA[ - <html> - <ol> - <li> Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. - <li> Pour in lemon juice, stir again, and add 4 cups of cold water. - <li> Chill or serve over ice cubes. - </ol> - </html> - ]]> - </method> - </Recipe> -</ListModel> +ListModel2 { + id: Recipies + ListElement { + title: "Pancakes" + picture: "content/pics/pancakes.jpg" + ingredients: "<html> \ + <ul> \ + <li> 1 cup (150g) self-raising flour \ + <li> 1 tbs caster sugar \ + <li> 3/4 cup (185ml) milk \ + <li> 1 egg \ + </ul> \ + </html>" + method: "<html> \ + <ol> \ + <li> Sift flour and sugar together into a bowl. Add a pinch of salt. \ + <li> Beat milk and egg together, then add to dry ingredients. Beat until smooth. \ + <li> Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. \ + <li> Turn over and cook other side until golden. \ + </ol>" + } + ListElement { + title: "Fruit Salad" + picture: "content/pics/fruit-salad.jpg" + ingredients: "* Seasonal Fruit" + method: "* Chop fruit and place in a bowl." + } + ListElement { + title: "Vegetable Soup" + picture: "content/pics/vegetable-soup.jpg" + ingredients: "<html> \ + <ul> \ + <li> 1 onion \ + <li> 1 turnip \ + <li> 1 potato \ + <li> 1 carrot \ + <li> 1 head of celery \ + <li> 1 1/2 litres of water \ + </ul> \ + </html>" + method: "<html> \ + <ol> \ + <li> Chop vegetables. \ + <li> Boil in water until vegetables soften. \ + <li> Season with salt and pepper to taste. \ + </ol> \ + </html>" + } + ListElement { + title: "Hamburger" + picture: "content/pics/hamburger.jpg" + ingredients: "<html> \ + <ul> \ + <li> 500g minced beef \ + <li> Seasoning \ + <li> lettuce, tomato, onion, cheese \ + <li> 1 hamburger bun for each burger \ + </ul> \ + </html>" + method: "<html> \ + <ol> \ + <li> Mix the beef, together with seasoning, in a food processor. \ + <li> Shape the beef into burgers. \ + <li> Grill the burgers for about 5 mins on each side (until cooked through) \ + <li> Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. \ + </ol> \ + </html>" + } + ListElement { + title: "Lemonade" + picture: "content/pics/lemonade.jpg" + ingredients: "<html> \ + <ul> \ + <li> 1 cup Lemon Juice \ + <li> 1 cup Sugar \ + <li> 6 Cups of Water (2 cups warm water, 4 cups cold water) \ + </ul> \ + </html>" + method: "<html> \ + <ol> \ + <li> Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. \ + <li> Pour in lemon juice, stir again, and add 4 cups of cold water. \ + <li> Chill or serve over ice cubes. \ + </ol> \ + </html>" + } +} diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index fb65fa3..cde2612 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -1,73 +1,166 @@ -<Item id="field" width="370" height="480"> - <properties> - <Property name="clickx" type="Int" value="0"/> - <Property name="clicky" type="Int" value="0"/> - </properties> - <resources> - <Component id="tile"> - <Flipable id="flipable" width="40" height="40"> - <axis> - <Axis startX="20" startY="20" endX="20" endY="0" /> - </axis> - <front> - <Image source="pics/front.png" width="40" height="40"> - <Image anchors.horizontalCenter="{parent.horizontalCenter}" - anchors.verticalCenter="{parent.verticalCenter}" - source="pics/flag.png" opacity="{modelData.hasFlag}"> - <opacity> - <Behaviour> - <NumericAnimation property="opacity" duration="250"/> - </Behaviour> - </opacity> - </Image> - </Image> - </front> - <back> - <Image source="pics/back.png" width="40" height="40"> - <Text anchors.horizontalCenter="{parent.horizontalCenter}" anchors.verticalCenter="{parent.verticalCenter}" - text="{modelData.hint}" color="white" font.bold="true" - opacity="{modelData.hasMine == false && modelData.hint > 0}"/> - <Image anchors.horizontalCenter="{parent.horizontalCenter}" anchors.verticalCenter="{parent.verticalCenter}" - source="pics/bomb.png" opacity="{modelData.hasMine}"/> - <Explosion anchors.horizontalCenter="{parent.horizontalCenter}" anchors.verticalCenter="{parent.verticalCenter}" explode="{modelData.hasMine==true && modelData.flipped==true}"/> - </Image> - </back> - <states> - <State name="back" when="{modelData.flipped == true}"> - <SetProperty target="{flipable}" property="rotation" value="180" /> - </State> - </states> - <transitions> - <Transition> - <SequentialAnimation> - <PauseAnimation duration="{var ret = Math.abs(flipable.parent.x-field.clickx) + Math.abs(flipable.parent.y-field.clicky); if (ret > 0) {if(modelData.hasMine==true && modelData.flipped==true){ret*3;}else{ret;}} else {0}}"/> - <NumericAnimation easing="easeInOutQuad" properties="rotation"/> - </SequentialAnimation> - </Transition> - </transitions> - <MouseRegion anchors.fill="{parent}" - onClicked="field.clickx = flipable.parent.x; field.clicky = flipable.parent.y; row = Math.floor(index/9); col = index - (Math.floor(index/9) * 9); if(mouse.button==undefined || mouse.button==Qt.RightButton){flag(row,col);}else{flip(row,col);}" /> - </Flipable> - </Component> - </resources> - <Image source="pics/No-Ones-Laughing-3.jpg" tile="true"/> - <Description text="Use the 'minehunt' executable to run this demo!" width="300" opacity="{tiles?0:1}" anchors.horizontalCenter="{parent.horizontalCenter}" anchors.verticalCenter="{parent.verticalCenter}"/> - <Repeater dataSource="{tiles}" x="1" y="1"> - <Component> - <ComponentInstance component="{tile}" - x="{(index - (Math.floor(index/9) * 9)) * 41}" - y="{Math.floor(index/9) * 41}"/> - </Component> - </Repeater> - <Item id="gamedata" width="370" height="100" y="380"> - <Text color="white" font.size="18" x="20" y="20">In play:</Text> - <Image x="100" y="20" source="pics/bomb-color.png"/> - <Text x="100" y="60" color="white" text="{numMines}"/> - <Image x="140" y="20" source="pics/flag-color.png"/> - <Text x="140" y="60" color="white" text="{numFlags}"/> - - <Image x="240" y="0" source="{if(isPlaying==true){'pics/smile.png'}else{if(hasWon==true){'pics/glee.png'}else{'pics/frown.png'}}}"> - <MouseRegion anchors.fill="{parent}" onClicked="reset()"/> - </Image> - </Item> -</Item> +Item { + id: field + width: 370 + height: 480 + properties: Property { + name: "clickx" + type: "Int" + value: 0 + } + properties: Property { + name: "clicky" + type: "Int" + value: 0 + } + resources: [ + Component { + id: tile + Flipable { + id: flipable + width: 40 + height: 40 + axis: Axis { + startX: 20 + startY: 20 + endX: 20 + endY: 0 + } + front: Image { + source: "pics/front.png" + width: 40 + height: 40 + Image { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + source: "pics/flag.png" + opacity: modelData.hasFlag + opacity: Behaviour { + NumericAnimation { + property: "opacity" + duration: 250 + } + } + } + } + back: Image { + source: "pics/back.png" + width: 40 + height: 40 + Text { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + text: modelData.hint + color: "white" + font.bold: true + opacity: modelData.hasMine == false && modelData.hint > 0 + } + Image { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + source: "pics/bomb.png" + opacity: modelData.hasMine + } + Explosion { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + explode: modelData.hasMine==true && modelData.flipped==true + } + } + states: [ + State { + name: "back" + when: modelData.flipped == true + SetProperty { + target: flipable + property: "rotation" + value: 180 + } + } + ] + transitions: [ + Transition { + SequentialAnimation { + PauseAnimation { + duration: {var ret = Math.abs(flipable.parent.x-field.clickx) + Math.abs(flipable.parent.y-field.clicky); if (ret > 0) {if(modelData.hasMine==true && modelData.flipped==true){ret*3;}else{ret;}} else {0}} + } + NumericAnimation { + easing: "easeInOutQuad" + properties: "rotation" + } + } + } + ] + MouseRegion { + anchors.fill: parent + onClicked: { field.clickx = flipable.parent.x; field.clicky = flipable.parent.y; row = Math.floor(index/9); col = index - (Math.floor(index/9) * 9); if(mouse.button==undefined || mouse.button==Qt.RightButton){flag(row,col);}else{flip(row,col);} } + } + } + } + ] + Image { + source: "pics/No-Ones-Laughing-3.jpg" + tile: true + } + Description { + text: "Use the 'minehunt' executable to run this demo!" + width: 300 + opacity: tiles?0:1 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + Repeater { + dataSource: tiles + x: 1 + y: 1 + Component { + ComponentInstance { + component: tile + x: (index - (Math.floor(index/9) * 9)) * 41 + y: Math.floor(index/9) * 41 + } + } + } + Item { + id: gamedata + width: 370 + height: 100 + y: 380 + Text { + color: "white" + font.size: 18 + x: 20 + y: 20 + } + Image { + x: 100 + y: 20 + source: "pics/bomb-color.png" + } + Text { + x: 100 + y: 60 + color: "white" + text: numMines + } + Image { + x: 140 + y: 20 + source: "pics/flag-color.png" + } + Text { + x: 140 + y: 60 + color: "white" + text: numFlags + } + Image { + x: 240 + y: 0 + source: if(isPlaying==true){'pics/smile.png'}else{if(hasWon==true){'pics/glee.png'}else{'pics/frown.png'}} + MouseRegion { + anchors.fill: parent + onClicked: { reset() } + } + } + } +} diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml index 7aaf51a..6d10425 100644 --- a/examples/declarative/mouseregion/mouse.qml +++ b/examples/declarative/mouseregion/mouse.qml @@ -1,24 +1,48 @@ -<Rect color="white" width="200" height="200"> - <Rect width="50" height="50" color="red"> - <Text text="Click" anchors.centeredIn="{parent}"/> - <MouseRegion onPressed="print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')')" - onReleased="print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')')" - onClicked="print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')')" - onDoubleClicked="print('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')')" - onPressAndHold="print('press and hold')" - onExitedWhilePressed="print('exiting while pressed')" - onReenteredWhilePressed="print('reentering while pressed')" anchors.fill="{parent}"/> - </Rect> - <Rect y="100" width="50" height="50" color="blue"> - <Text text="Drag" anchors.centeredIn="{parent}"/> - <MouseRegion drag.target="{parent}" - drag.axis="x" drag.xmin="0" drag.xmax="150" - onPressed="print('press')" - onReleased="print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')')" - onClicked="print('click' + '(wasHeld: ' + mouse.wasHeld + ')')" - onDoubleClicked="print('double click')" - onPressAndHold="print('press and hold')" - onExitedWhilePressed="print('exiting while pressed')" - onReenteredWhilePressed="print('reentering while pressed')" anchors.fill="{parent}"/> - </Rect> -</Rect> +Rect { + color: "white" + width: 200 + height: 200 + Rect { + width: 50 + height: 50 + color: "red" + Text { + text: "Click" + anchors.centeredIn: parent + } + MouseRegion { + onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') } + onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') } + onClicked: { print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') } + onDoubleClicked: { print('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') } + onPressAndHold: { print('press and hold') } + onExitedWhilePressed: { print('exiting while pressed') } + onReenteredWhilePressed: { print('reentering while pressed') } + anchors.fill: parent + } + } + Rect { + y: 100 + width: 50 + height: 50 + color: "blue" + Text { + text: "Drag" + anchors.centeredIn: parent + } + MouseRegion { + drag.target: parent + drag.axis: "x" + drag.xmin: 0 + drag.xmax: 150 + onPressed: { print('press') } + onReleased: { print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') } + onClicked: { print('click' + '(wasHeld: ' + mouse.wasHeld + ')') } + onDoubleClicked: { print('double click') } + onPressAndHold: { print('press and hold') } + onExitedWhilePressed: { print('exiting while pressed') } + onReenteredWhilePressed: { print('reentering while pressed') } + anchors.fill: parent + } + } +} diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index b65f2bc..7d26e88 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -1,41 +1,115 @@ -<Rect width="400" height="500" radius="7" pen.color="black" id="Page"> - <properties> - <Property name="day" type="string" /> - <Property name="stickies" /> - </properties> - - <Image x="10" y="10" source="cork.jpg" opaque="true"/> - <Text x="20" y="20" height="40" font.size="14" font.bold="true" width="370" text="{day}" style="Outline" styleColor="#dedede"/> - - <Repeater dataSource="{Page.stickies}"> - <Item x="{Math.random() * 200 + 100}" y="{Math.random() * 300 + 50}" id="StickyPage"> - <rotation> - <Follow source="{-Flick.xVelocity / 100}" spring="2.0" damping="0.1"/> - </rotation> - <Item id="Sticky" scale="0.5"> - <Image id="StickyImage" source="sticky.png" smooth="true" y="-20" x="{8 + -width * 0.6 / 2}" scale="0.6" /> - <TextEdit id="MyText" smooth="true" font.size="28" readOnly="false" x="-104" y="36" wrap="true" rotation="-8" text="{noteText}" width="195" height="172" /> - <Item y="-20" x="{StickyImage.x}" width="{StickyImage.width * StickyImage.scale}" height="{StickyImage.height * StickyImage.scale}" > - <MouseRegion id="Mouse" onClicked="MyText.focus = true" anchors.fill="{parent}" drag.target="{StickyPage}" drag.axis="xy" drag.ymin="0" drag.ymax="500" drag.xmin="0" drag.xmax="400"/> - </Item> - </Item> - <Image source="tack.png" x="{-width / 2}" y="{-height * 0.7 / 2}" scale="0.7" /> - - <states> - <State name="pressed" when="{Mouse.pressed}"> - <SetProperties target="{Sticky}" rotation="8" scale="1"/> - <SetProperties target="{Page}" z="8"/> - </State> - </states> - <transitions> - <Transition> - <NumericAnimation properties="rotation,scale" duration="200"/> - </Transition> - </transitions> - </Item> - </Repeater> - - - - -</Rect> +Rect { + width: 400 + height: 500 + radius: 7 + pen.color: "black" + id: Page + properties: Property { + name: "day" + type: "string" + } + properties: Property { + name: "stickies" + } + Image { + x: 10 + y: 10 + source: "cork.jpg" + opaque: true + } + Text { + x: 20 + y: 20 + height: 40 + font.size: 14 + font.bold: true + width: 370 + text: day + style: Outline + styleColor: "#dedede" + } + Repeater { + dataSource: Page.stickies + Item { + x: Math.random() * 200 + 100 + y: Math.random() * 300 + 50 + id: StickyPage + rotation: Follow { + source: -Flick.xVelocity / 100 + spring: 2.0 + damping: 0.1 + } + Item { + id: Sticky + scale: 0.5 + Image { + id: StickyImage + source: "sticky.png" + smooth: true + y: -20 + x: 8 + -width * 0.6 / 2 + scale: 0.6 + } + TextEdit { + id: MyText + smooth: true + font.size: 28 + readOnly: false + x: -104 + y: 36 + wrap: true + rotation: -8 + text: noteText + width: 195 + height: 172 + } + Item { + y: -20 + x: StickyImage.x + width: StickyImage.width * StickyImage.scale + height: StickyImage.height * StickyImage.scale + MouseRegion { + id: Mouse + onClicked: { MyText.focus = true } + anchors.fill: parent + drag.target: StickyPage + drag.axis: "xy" + drag.ymin: 0 + drag.ymax: 500 + drag.xmin: 0 + drag.xmax: 400 + } + } + } + Image { + source: "tack.png" + x: -width / 2 + y: -height * 0.7 / 2 + scale: 0.7 + } + states: [ + State { + name: "pressed" + when: Mouse.pressed + SetProperties { + target: Sticky + rotation: 8 + scale: 1 + } + SetProperties { + target: Page + z: 8 + } + } + ] + transitions: [ + Transition { + NumericAnimation { + properties: "rotation,scale" + duration: 200 + } + } + ] + } + } +} diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml index 0215d37..ff95527 100644 --- a/examples/declarative/velocity/velocity.qml +++ b/examples/declarative/velocity/velocity.qml @@ -1,81 +1,113 @@ -<Rect color="lightSteelBlue" width="800" height="600"> - <ListModel id="List"> - <Day> - <name>Sunday</name> - <dayColor>#808080</dayColor> - <notes> - <Note noteText="Lunch" /> - <Note noteText="Party" /> - </notes> - </Day> - <Day> - <name>Monday</name> - <dayColor>blue</dayColor> - <notes> - <Note noteText="Pickup kids" /> - <Note noteText="Checkout kinetic" /> - <Note noteText="Read email" /> - </notes> - </Day> - <Day> - <name>Tuesday</name> - <dayColor>yellow</dayColor> - <notes> - <Note noteText="Walk dog" /> - <Note noteText="Buy newspaper" /> - </notes> - </Day> - <Day> - <name>Wednesday</name> - <dayColor>purple</dayColor> - <notes> - <Note noteText="Cook dinner" /> - <Note noteText="Eat dinner" /> - </notes> - </Day> - <Day> - <name>Thursday</name> - <dayColor>blue</dayColor> - <notes> - <Note noteText="5:30pm Meeting" /> - <Note noteText="Weed garden" /> - </notes> - </Day> - <Day> - <name>Friday</name> - <dayColor>green</dayColor> - <notes> - <Note noteText="Still work" /> - <Note noteText="Drink" /> - </notes> - </Day> - <Day> - <name>Saturday</name> - <dayColor>orange</dayColor> - <notes> - <Note noteText="Drink" /> - <Note noteText="Drink" /> - </notes> - </Day> - </ListModel> - - <Flickable id="Flick" anchors.fill="{parent}" viewportWidth="{Lay.width}"> - <HorizontalLayout id="Lay"> - <Repeater dataSource="{List}"> - <Component> - <Day day="{name}" color="{dayColor}" stickies="{notes}"/> - </Component> - </Repeater> - <!-- - <Day color="#808080" day="Sunday" /> - <Day color="blue" day="Monday"/> - <Day color="yellow" day="Tuesday"/> - <Day color="purple" day="Wednesday"/> - <Day color="blue" day="Thursday"/> - <Day color="green" day="Friday"/> - <Day color="orange" day="Saturday"/> - --> - </HorizontalLayout> - </Flickable> - -</Rect> +Rect { + color: "lightSteelBlue" + width: 800 + height: 600 + ListModel2 { + id: List + ListElement { + name: "Sunday" + dayColor: "#808080" + notes: [ + ListElement { + noteText: "Lunch" + }, + ListElement { + noteText: "Party" + } + ] + } + ListElement { + name: "Monday" + dayColor: "blue" + notes: [ + ListElement { + noteText: "Pickup kids" + }, + ListElement { + noteText: "Checkout kinetic" + }, + ListElement { + noteText: "Read email" + } + ] + } + ListElement { + name: "Tuesday" + dayColor: "yellow" + notes: [ + ListElement { + noteText: "Walk dog" + }, + ListElement { + noteText: "Buy newspaper" + } + ] + } + ListElement { + name: "Wednesday" + dayColor: "purple" + notes: [ + ListElement { + noteText: "Cook dinner" + }, + ListElement { + noteText: "Eat dinner" + } + ] + } + ListElement { + name: "Thursday" + dayColor: "blue" + notes: [ + ListElement { + noteText: "5:30pm Meeting" + }, + ListElement { + noteText: "Weed garden" + } + ] + } + ListElement { + name: "Friday" + dayColor: "green" + notes: [ + ListElement { + noteText: "Still work" + }, + ListElement { + noteText: "Drink" + } + ] + } + ListElement { + name: "Saturday" + dayColor: "orange" + notes: [ + ListElement { + noteText: "Drink" + }, + ListElement { + noteText: "Drink" + } + ] + } + } + Flickable { + id: Flick + anchors.fill: parent + viewportWidth: Lay.width + HorizontalLayout { + id: Lay + Repeater { + dataSource: List + Component { + Day { + day: name + color: dayColor + stickies: notes + } + } + } + } + } +} diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml index 5e98d1b..3877adf 100644 --- a/examples/declarative/xmldata/daringfireball.qml +++ b/examples/declarative/xmldata/daringfireball.qml @@ -1,25 +1,59 @@ -<Rect color="white" width="600" height="600"> - <resources> - <XmlListModel id="feedModel" source="http://daringfireball.net/index.xml" - query="doc($src)/feed/entry"> - <namespaceDeclarations> - declare default element namespace 'http://www.w3.org/2005/Atom'; - </namespaceDeclarations> - <Role name="title" query="title/string()"/> - <Role name="tagline" query="author/name/string()"/> - <Role name="content" query="content/string()" isCData="true"/> - </XmlListModel> - <Component id="feedDelegate"> - <Item height="{contents.height + 20}"> - <Text x="10" id="TitleText" text="{title}" font.bold="true"/> - <Text text="{'by ' + tagline}" anchors.left="{TitleText.right}" anchors.leftMargin="10" font.italic="true"/> - <Text x="10" text="{content}" anchors.top="{TitleText.bottom}" width="580" wrap="true"> - <onLinkActivated>print('link clicked: ' + link)</onLinkActivated> - </Text> - </Item> - </Component> - </resources> - - <ListView id="list" anchors.fill="{parent}" clip="true" - model="{feedModel}" delegate="{feedDelegate}"/> -</Rect> +Rect { + color: "white" + width: 600 + height: 600 + resources: [ + XmlListModel { + id: feedModel + source: "http://daringfireball.net/index.xml" + query: "doc($src)/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + Role { + name: "title" + query: "title/string()" + } + Role { + name: "tagline" + query: "author/name/string()" + } + Role { + name: "content" + query: "content/string()" + isCData: true + } + }, + Component { + id: feedDelegate + Item { + height: contents.height + 20 + Text { + x: 10 + id: TitleText + text: title + font.bold: true + } + Text { + text: 'by ' + tagline + anchors.left: TitleText.right + anchors.leftMargin: 10 + font.italic: true + } + Text { + x: 10 + text: content + anchors.top: TitleText.bottom + width: 580 + wrap: true + onLinkActivated: { print('link clicked: ' + link) } + } + } + } + ] + ListView { + id: list + anchors.fill: parent + clip: true + model: feedModel + delegate: feedDelegate + } +} diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index 32a706e..a465cdd 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -1,38 +1,111 @@ -<Rect color="black" gradientColor="#AAAAAA" width="600" height="600"> - <resources> - <XmlListModel id="feedModel" source="http://rss.news.yahoo.com/rss/oceania" query="doc($src)/rss/channel/item"> - <Role name="title" query="title/string()"/> - <Role name="link" query="link/string()"/> - <Role name="description" query="description/string()" isCData="true"/> - </XmlListModel> - <Component id="feedDelegate"> - <Item id="Delegate" height="{Wrapper.height + 10}"> - <MouseRegion anchors.fill="{Wrapper}" onPressed="Delegate.ListView.list.currentIndex = index;" - onClicked="if (Wrapper.state == 'Details') { Wrapper.state = '';} else {Wrapper.state = 'Details';}"/> - <Rect id="Wrapper" y="5" height="{TitleText.height + 10}" width="580" color="#F0F0F0" radius="5"> - <Text x="10" y="5" id="TitleText" text="{'<a href=\'' + link + '\'>' + title + '</a>'}" font.bold="true" font.family="Helvetica" font.size="14" onLinkActivated="print('link clicked: ' + link)"/> - <Text x="10" id="Description" text="{description}" width="560" wrap="true" font.family="Helvetica" - anchors.top="{TitleText.bottom}" anchors.topMargin="5" opacity="0"/> - - <states> - <State name="Details"> - <SetProperty target="{Wrapper}" property="height" binding="contents.height + 10"/> - <SetProperty target="{Description}" property="opacity" value="1"/> - </State> - </states> - <transitions> - <Transition fromState="*" toState="Details" reversible="true"> - <SequentialAnimation> - <NumericAnimation duration="200" properties="height" easing="easeOutQuad"/> - <NumericAnimation duration="200" properties="opacity"/> - </SequentialAnimation> - </Transition> - </transitions> - </Rect> - </Item> - </Component> - </resources> - - <ListView id="list" x="10" y="10" width="{parent.width - 20}" height="{parent.height - 20}" clip="true" - model="{feedModel}" delegate="{feedDelegate}" currentItemPositioning="Snap"/> -</Rect> +Rect { + color: "black" + gradientColor: "#AAAAAA" + width: 600 + height: 600 + resources: [ + XmlListModel { + id: feedModel + source: "http://rss.news.yahoo.com/rss/oceania" + query: "doc($src)/rss/channel/item" + Role { + name: "title" + query: "title/string()" + } + Role { + name: "link" + query: "link/string()" + } + Role { + name: "description" + query: "description/string()" + isCData: true + } + }, + Component { + id: feedDelegate + Item { + id: Delegate + height: Wrapper.height + 10 + MouseRegion { + anchors.fill: Wrapper + onPressed: { Delegate.ListView.list.currentIndex = index; } + onClicked: { if (Wrapper.state == 'Details') { Wrapper.state = '';} else {Wrapper.state = 'Details';} } + } + Rect { + id: Wrapper + y: 5 + height: TitleText.height + 10 + width: 580 + color: "#F0F0F0" + radius: 5 + Text { + x: 10 + y: 5 + id: TitleText + text: '<a href=\'' + link + '\'>' + title + '</a>' + font.bold: true + font.family: "Helvetica" + font.size: 14 + onLinkActivated: { print('link clicked: ' + link) } + } + Text { + x: 10 + id: Description + text: description + width: 560 + wrap: true + font.family: "Helvetica" + anchors.top: TitleText.bottom + anchors.topMargin: 5 + opacity: 0 + } + states: [ + State { + name: "Details" + SetProperty { + target: Wrapper + property: "height" + binding: "contents.height + 10" + } + SetProperty { + target: Description + property: "opacity" + value: 1 + } + } + ] + transitions: [ + Transition { + fromState: "*" + toState: "Details" + reversible: true + SequentialAnimation { + NumericAnimation { + duration: 200 + properties: "height" + easing: "easeOutQuad" + } + NumericAnimation { + duration: 200 + properties: "opacity" + } + } + } + ] + } + } + } + ] + ListView { + id: list + x: 10 + y: 10 + width: parent.width - 20 + height: parent.height - 20 + clip: true + model: feedModel + delegate: feedDelegate + currentItemPositioning: "Snap" + } +} diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index 1d15827..81ed750 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -58,7 +58,7 @@ public: QFxItem *front; QFxItem *back; QFxAxis *axis; - QFxRotation axisRotation; + QFxRotation3D axisRotation; qreal rotation; }; diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp index 69d4679..d2739ea 100644 --- a/src/declarative/fx/qfxkeyactions.cpp +++ b/src/declarative/fx/qfxkeyactions.cpp @@ -736,7 +736,7 @@ void QFxKeyActions::setKey_Space(const QString &s) /*! \qmlproperty string KeyActions::escape - \qmlproperty string KeyActions::return + \qmlproperty string KeyActions::keyReturn \qmlproperty string KeyActions::enter \qmlproperty string KeyActions::delete \qmlproperty string KeyActions::space diff --git a/src/declarative/fx/qfxkeyactions.h b/src/declarative/fx/qfxkeyactions.h index 7ad323a..b0d002d 100644 --- a/src/declarative/fx/qfxkeyactions.h +++ b/src/declarative/fx/qfxkeyactions.h @@ -101,7 +101,7 @@ class Q_DECLARATIVE_EXPORT QFxKeyActions : public QFxItem Q_PROPERTY(QString digit9 READ key_9 WRITE setKey_9) Q_PROPERTY(QString asterisk READ key_Asterisk WRITE setKey_Asterisk) Q_PROPERTY(QString escape READ key_Escape WRITE setKey_Escape) - Q_PROPERTY(QString return READ key_Return WRITE setKey_Return) + Q_PROPERTY(QString keyReturn READ key_Return WRITE setKey_Return) Q_PROPERTY(QString enter READ key_Enter WRITE setKey_Enter) Q_PROPERTY(QString delete READ key_Delete WRITE setKey_Delete) Q_PROPERTY(QString space READ key_Space WRITE setKey_Space) diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index c355158..2bed170 100644 --- a/src/declarative/fx/qfxtransform.cpp +++ b/src/declarative/fx/qfxtransform.cpp @@ -178,8 +178,8 @@ void QFxAxis::setEndZ(qreal z) } /*! - \qmlclass AxisRotation - \brief The AxisRotation element provides a way to rotate an Item around an axis. + \qmlclass Rotation3D + \brief The Rotation3D element provides a way to rotate an Item around an axis. Here is an example of various rotations applied to an \l Image. \code @@ -187,22 +187,22 @@ void QFxAxis::setEndZ(qreal z) <Image src="qt.png"/> <Image src="qt.png"> <transform> - <AxisRotation axis.startX="30" axis.endX="30" axis.endY="60" angle="18"/> + <Rotation3D axis.startX="30" axis.endX="30" axis.endY="60" angle="18"/> </transform> </Image> <Image src="qt.png"> <transform> - <AxisRotation axis.startX="30" axis.endX="30" axis.endY="60" angle="36"/> + <Rotation3D axis.startX="30" axis.endX="30" axis.endY="60" angle="36"/> </transform> </Image> <Image src="qt.png"> <transform> - <AxisRotation axis.startX="30" axis.endX="30" axis.endY="60" angle="54"/> + <Rotation3D axis.startX="30" axis.endX="30" axis.endY="60" angle="54"/> </transform> </Image> <Image src="qt.png"> <transform> - <AxisRotation axis.startX="30" axis.endX="30" axis.endY="60" angle="72"/> + <Rotation3D axis.startX="30" axis.endX="30" axis.endY="60" angle="72"/> </transform> </Image> </HorizontalLayout> @@ -211,58 +211,58 @@ void QFxAxis::setEndZ(qreal z) \image axisrotation.png */ -QML_DEFINE_TYPE(QFxRotation,AxisRotation); +QML_DEFINE_TYPE(QFxRotation3D,Rotation3D); -QFxRotation::QFxRotation(QObject *parent) -: QFxTransform(parent), _angle(0), _distanceToPlane(1024.), _dirty(true) +QFxRotation3D::QFxRotation3D(QObject *parent) +: QFxTransform(parent), _angle(0), _dirty(true) { connect(&_axis, SIGNAL(updated()), this, SLOT(update())); } -QFxRotation::~QFxRotation() +QFxRotation3D::~QFxRotation3D() { } /*! - \qmlproperty real AxisRotation::axis.startX - \qmlproperty real AxisRotation::axis.startY - \qmlproperty real AxisRotation::axis.endX - \qmlproperty real AxisRotation::axis.endY - \qmlproperty real AxisRotation::axis.endZ + \qmlproperty real Rotation3D::axis.startX + \qmlproperty real Rotation3D::axis.startY + \qmlproperty real Rotation3D::axis.endX + \qmlproperty real Rotation3D::axis.endY + \qmlproperty real Rotation3D::axis.endZ A rotation axis is specified by 2 points in 3D space: a start point and an end point. The z-position of the start point is assumed to be 0, and cannot be changed. */ -QFxAxis *QFxRotation::axis() +QFxAxis *QFxRotation3D::axis() { return &_axis; } /*! - \qmlproperty real AxisRotation::angle + \qmlproperty real Rotation3D::angle The angle, in degrees, to rotate around the specified axis. */ -qreal QFxRotation::angle() const +qreal QFxRotation3D::angle() const { return _angle; } -void QFxRotation::setAngle(qreal angle) +void QFxRotation3D::setAngle(qreal angle) { _angle = angle; update(); } -bool QFxRotation::isIdentity() const +bool QFxRotation3D::isIdentity() const { return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX()); } #if defined(QFX_RENDER_QPAINTER) const qreal inv_dist_to_plane = 1. / 1024.; -QTransform QFxRotation::transform() const +QTransform QFxRotation3D::transform() const { if (_dirty) { _transform = QTransform(); @@ -282,10 +282,6 @@ QTransform QFxRotation::transform() const qreal y = _axis.endY() - _axis.startY(); qreal z = _axis.endZ(); - qreal idtp = inv_dist_to_plane; - if (distanceToPlane() != 1024.) - idtp = 1. / distanceToPlane(); - qreal len = x * x + y * y + z * z; if (len != 1.) { len = ::sqrt(len); @@ -294,8 +290,8 @@ QTransform QFxRotation::transform() const z /= len; } - QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*idtp, - y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*idtp, + QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*inv_dist_to_plane, + y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*inv_dist_to_plane, 0, 0, 1); _transform *= rotTrans; @@ -310,7 +306,7 @@ QTransform QFxRotation::transform() const return _transform; } #elif defined(QFX_RENDER_OPENGL) -QMatrix4x4 QFxRotation::transform() const +QMatrix4x4 QFxRotation3D::transform() const { if (_dirty) { _dirty = false; @@ -333,21 +329,7 @@ QMatrix4x4 QFxRotation::transform() const } #endif -/*! - \qmlproperty real AxisRotation::distanceToPlane -*/ -qreal QFxRotation::distanceToPlane() const -{ - return _distanceToPlane; -} - -void QFxRotation::setDistanceToPlane(qreal d) -{ - _distanceToPlane = d; - update(); -} - -void QFxRotation::update() +void QFxRotation3D::update() { _dirty = true; QFxItem *item = qobject_cast<QFxItem *>(parent()); @@ -356,77 +338,77 @@ void QFxRotation::update() } /*! - \qmlclass AxisTranslation - \brief The AxisTranslation element provides a way to move an Item along an axis. + \qmlclass Translation3D + \brief The Translation3D element provides a way to move an Item along an axis. The following example translates the image to 10, 3. \code <Image src="logo.png"> <transform> - <AxisTranslation axis.startX="0" axis.startY="0" axis.endX="1" axis.endY=".3" distance="10"/> + <Translation3D axis.startX="0" axis.startY="0" axis.endX="1" axis.endY=".3" distance="10"/> </transform> </Image> \endcode */ -QML_DEFINE_TYPE(QFxTranslation,AxisTranslation); +QML_DEFINE_TYPE(QFxTranslation3D,Translation3D); -QFxTranslation::QFxTranslation(QObject *parent) +QFxTranslation3D::QFxTranslation3D(QObject *parent) : QFxTransform(parent), _distance(0), _dirty(true) { connect(&_axis, SIGNAL(updated()), this, SLOT(update())); } -QFxTranslation::~QFxTranslation() +QFxTranslation3D::~QFxTranslation3D() { } /*! - \qmlproperty real AxisTranslation::axis.startX - \qmlproperty real AxisTranslation::axis.startY - \qmlproperty real AxisTranslation::axis.endX - \qmlproperty real AxisTranslation::axis.endY - \qmlproperty real AxisTranslation::axis.endZ + \qmlproperty real Translation3D::axis.startX + \qmlproperty real Translation3D::axis.startY + \qmlproperty real Translation3D::axis.endX + \qmlproperty real Translation3D::axis.endY + \qmlproperty real Translation3D::axis.endZ A translation axis is specified by 2 points in 3D space: a start point and an end point. The z-position of the start point is assumed to be 0, and cannot be changed. Changing the z-position of the end point is only valid when running under OpenGL. */ -QFxAxis *QFxTranslation::axis() +QFxAxis *QFxTranslation3D::axis() { return &_axis; } /*! - \qmlproperty real AxisTranslation::distance + \qmlproperty real Translation3D::distance The distance to translate along the specified axis. distance is a multiplier; in the example below, a distance of 1 would translate to 100, 50, while a distance of 0.5 would translate to 50, 25. \code - <AxisTranslation axis.startX="0" axis.startY="0" axis.endX="100" axis.endY="50"/> + <Translation3D axis.startX="0" axis.startY="0" axis.endX="100" axis.endY="50"/> \endcode */ -qreal QFxTranslation::distance() const +qreal QFxTranslation3D::distance() const { return _distance; } -void QFxTranslation::setDistance(qreal distance) +void QFxTranslation3D::setDistance(qreal distance) { _distance = distance; update(); } -bool QFxTranslation::isIdentity() const +bool QFxTranslation3D::isIdentity() const { return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX()); } #if defined(QFX_RENDER_QPAINTER) -QTransform QFxTranslation::transform() const +QTransform QFxTranslation3D::transform() const { if (_dirty) { _transform = QTransform(); @@ -446,7 +428,7 @@ QTransform QFxTranslation::transform() const return _transform; } #elif defined(QFX_RENDER_OPENGL) -QMatrix4x4 QFxRotation::transform() const +QMatrix4x4 QFxTranslation3D::transform() const { if (_dirty) { _dirty = false; @@ -465,7 +447,7 @@ QMatrix4x4 QFxRotation::transform() const } #endif -void QFxTranslation::update() +void QFxTranslation3D::update() { _dirty = true; @@ -541,8 +523,62 @@ QMatrix4x4 QFxPerspective::transform() const \qmlclass Squish \brief The Squish element allows you to distort an items appearance by 'squishing' it. - A Squish transform only affects an item when running under OpenGL; when running under software - rasterization it has no effect. + Here is an example of various \l Image squishes. + \code + Rect { + id: Screen + width: 360; height: 80 + color: "white" + + HorizontalLayout { + margin: 10 + spacing: 10 + Image { src: "qt.png" } + Image { + src: "qt.png" + transform: Squish { + x:0; y:0; width:60; height:60 + topLeftX:0; topLeftY:0 + topRightX:50; topRightY:10 + bottomLeftX:0; bottomLeftY:60 + bottomRightX: 60; bottomRightY:60 + } + } + Image { + src: "qt.png" + transform: Squish { + x:0; y:0; width:60; height:60 + topLeftX:0; topLeftY:0 + topRightX:50; topRightY:0 + bottomLeftX:10; bottomLeftY:50 + bottomRightX: 60; bottomRightY:60 + } + } + Image { + src: "qt.png" + transform: Squish { + x:0; y:0; width:60; height:60 + topLeftX:0; topLeftY:10 + topRightX:60; topRightY:10 + bottomLeftX:0; bottomLeftY:50 + bottomRightX: 60; bottomRightY:50 + } + } + Image { + src: "qt.png" + transform: Squish { + x:0; y:0; width:60; height:60 + topLeftX:10; topLeftY:0 + topRightX:50; topRightY:0 + bottomLeftX:10; bottomLeftY:60 + bottomRightX: 50; bottomRightY:60 + } + } + } + } + \endcode + + \image squish.png */ QML_DEFINE_TYPE(QFxSquish,Squish); @@ -557,6 +593,11 @@ QFxSquish::~QFxSquish() /*! \qmlproperty real Squish::x + \qmlproperty real Squish::y + \qmlproperty real Squish::width + \qmlproperty real Squish::height + + This is usually set to the original geometry of the item being squished. */ qreal QFxSquish::x() const { @@ -569,9 +610,6 @@ void QFxSquish::setX(qreal v) update(); } -/*! - \qmlproperty real Squish::y -*/ qreal QFxSquish::y() const { return p.y(); @@ -583,9 +621,6 @@ void QFxSquish::setY(qreal v) update(); } -/*! - \qmlproperty real Squish::width -*/ qreal QFxSquish::width() const { return s.width(); @@ -597,9 +632,6 @@ void QFxSquish::setWidth(qreal v) update(); } -/*! - \qmlproperty real Squish::height -*/ qreal QFxSquish::height() const { return s.height(); @@ -614,6 +646,8 @@ void QFxSquish::setHeight(qreal v) /*! \qmlproperty real Squish::topLeftX \qmlproperty real Squish::topLeftY + + The top left point for the squish. */ qreal QFxSquish::topLeft_x() const { @@ -640,6 +674,8 @@ void QFxSquish::settopLeft_y(qreal v) /*! \qmlproperty real Squish::topRightX \qmlproperty real Squish::topRightY + + The top right point for the squish. */ qreal QFxSquish::topRight_x() const { @@ -666,6 +702,8 @@ void QFxSquish::settopRight_y(qreal v) /*! \qmlproperty real Squish::bottomLeftX \qmlproperty real Squish::bottomLeftY + + The bottom left point for the squish. */ qreal QFxSquish::bottomLeft_x() const { @@ -692,6 +730,8 @@ void QFxSquish::setbottomLeft_y(qreal v) /*! \qmlproperty real Squish::bottomRightX \qmlproperty real Squish::bottomRightY + + The bottom right point for the squish. */ qreal QFxSquish::bottomRight_x() const { @@ -722,12 +762,24 @@ void QFxSquish::update() item->updateTransform(); } -#if defined(QFX_RENDER_OPENGL) bool QFxSquish::isIdentity() const { return false; } +#if defined(QFX_RENDER_QPAINTER) +QTransform QFxSquish::transform() const +{ + QPolygonF poly; + poly << p << QPointF(p.x() + s.width(), p.y()) << QPointF(p.x() + s.width(), p.y() + s.height()) << QPointF(p.x(), p.y() + s.height()); + QPolygonF poly2; + poly2 << p1 << p2 << p4 << p3; + + QTransform t; + QTransform::quadToQuad(poly, poly2, t); + return t; +} +#elif defined(QFX_RENDER_OPENGL) QMatrix4x4 QFxSquish::transform() const { QPolygonF poly; diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h index 8a4eab1..14bce9b 100644 --- a/src/declarative/fx/qfxtransform.h +++ b/src/declarative/fx/qfxtransform.h @@ -109,16 +109,15 @@ private: }; QML_DECLARE_TYPE(QFxAxis); -class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform +class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform { Q_OBJECT Q_PROPERTY(QFxAxis *axis READ axis) Q_PROPERTY(qreal angle READ angle WRITE setAngle) - Q_PROPERTY(qreal distanceToPlane READ distanceToPlane WRITE setDistanceToPlane) public: - QFxRotation(QObject *parent=0); - ~QFxRotation(); + QFxRotation3D(QObject *parent=0); + ~QFxRotation3D(); QFxAxis *axis(); @@ -136,22 +135,21 @@ private Q_SLOTS: private: QFxAxis _axis; qreal _angle; - qreal _distanceToPlane; mutable bool _dirty; mutable QSimpleCanvas::Matrix _transform; }; -QML_DECLARE_TYPE(QFxRotation); +QML_DECLARE_TYPE(QFxRotation3D); -class Q_DECLARATIVE_EXPORT QFxTranslation : public QFxTransform +class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform { Q_OBJECT Q_PROPERTY(QFxAxis *axis READ axis) Q_PROPERTY(qreal distance READ distance WRITE setDistance) public: - QFxTranslation(QObject *parent=0); - ~QFxTranslation(); + QFxTranslation3D(QObject *parent=0); + ~QFxTranslation3D(); QFxAxis *axis(); @@ -170,7 +168,7 @@ private: mutable bool _dirty; mutable QSimpleCanvas::Matrix _transform; }; -QML_DECLARE_TYPE(QFxTranslation); +QML_DECLARE_TYPE(QFxTranslation3D); class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform { @@ -269,10 +267,8 @@ public: qreal bottomRight_x() const; void setbottomRight_x(qreal); -#if defined(QFX_RENDER_OPENGL) virtual bool isIdentity() const; - virtual QMatrix4x4 transform() const; -#endif + virtual QSimpleCanvas::Matrix transform() const; private: void update(); diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 40b854f..9067039 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -32,8 +32,8 @@ HEADERS += qml/qmlparser_p.h \ qml/qmlmetaproperty.h \ qml/qmlcomponent.h \ qml/qmlcomponent_p.h \ - qml/qmlcustomparser.h \ qml/qmlcustomparser_p.h \ + qml/qmlcustomparser_p_p.h \ qml/qmlpropertyvaluesource.h \ qml/qmlboundsignal_p.h \ qml/qmlxmlparser_p.h \ diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 4433286..c9bdfec 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -59,7 +59,7 @@ #include <qmlcontext.h> #include <qmlmetatype.h> #include <QtCore/qdebug.h> -#include "private/qmlcustomparser_p.h" +#include "private/qmlcustomparser_p_p.h" #include "qmlscriptparser_p.h" diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp index fe0c3a8..544c469 100644 --- a/src/declarative/qml/qmlcustomparser.cpp +++ b/src/declarative/qml/qmlcustomparser.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qmlcustomparser.h" #include "qmlcustomparser_p.h" +#include "qmlcustomparser_p_p.h" #include "qmlparser_p.h" QT_BEGIN_NAMESPACE @@ -50,6 +50,7 @@ using namespace QmlParser; /*! \class QmlCustomParser \brief The QmlCustomParser class allows you to add new arbitrary types to QML. + \internal By subclassing QmlCustomParser, you can add an XML parser for building a particular type. diff --git a/src/declarative/qml/qmlcustomparser.h b/src/declarative/qml/qmlcustomparser.h deleted file mode 100644 index 0e6a619..0000000 --- a/src/declarative/qml/qmlcustomparser.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLCUSTOMPARSER_H -#define QMLCUSTOMPARSER_H - -#include <QtCore/qbytearray.h> -#include <QtCore/qxmlstream.h> -#include <QtDeclarative/qfxglobal.h> -#include <QtDeclarative/qmlmetatype.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlCustomParserPropertyPrivate; -class Q_DECLARATIVE_EXPORT QmlCustomParserProperty -{ -public: - QmlCustomParserProperty(); - QmlCustomParserProperty(const QmlCustomParserProperty &); - QmlCustomParserProperty &operator=(const QmlCustomParserProperty &); - ~QmlCustomParserProperty(); - - QByteArray name() const; - - bool isList() const; - QList<QVariant> assignedValues() const; - -private: - friend class QmlCustomParserNodePrivate; - friend class QmlCustomParserPropertyPrivate; - QmlCustomParserPropertyPrivate *d; -}; -Q_DECLARE_METATYPE(QmlCustomParserProperty); - -class QmlCustomParserNodePrivate; -class Q_DECLARATIVE_EXPORT QmlCustomParserNode -{ -public: - QmlCustomParserNode(); - QmlCustomParserNode(const QmlCustomParserNode &); - QmlCustomParserNode &operator=(const QmlCustomParserNode &); - ~QmlCustomParserNode(); - - QByteArray name() const; - - QList<QmlCustomParserProperty> properties() const; - -private: - friend class QmlCustomParserNodePrivate; - QmlCustomParserNodePrivate *d; -}; -Q_DECLARE_METATYPE(QmlCustomParserNode); - -class Q_DECLARATIVE_EXPORT QmlCustomParser -{ -public: - virtual ~QmlCustomParser() {} - - virtual QByteArray compile(QXmlStreamReader&, bool *ok)=0; - virtual QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok); - virtual QVariant create(const QByteArray &)=0; - virtual void setCustomData(QObject *, const QByteArray &); - - struct Register { - Register(const char *name, QmlCustomParser *parser) { - qmlRegisterCustomParser(name, parser); - } - }; - template<typename T> - struct Define { - static Register instance; - }; -}; -#define QML_DEFINE_CUSTOM_PARSER(name, parserClass) \ - template<> QmlCustomParser::Register QmlCustomParser::Define<parserClass>::instance(# name, new parserClass); -#define QML_DEFINE_CUSTOM_PARSER_NS(namespacestring, name, parserClass) \ - template<> QmlCustomParser::Register QmlCustomParser::Define<parserClass>::instance(namespacestring "/" # name, new parserClass); - -#define QML_DEFINE_CUSTOM_TYPE(TYPE, NAME, CUSTOMTYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterCustomType<TYPE>(#NAME, #TYPE, new CUSTOMTYPE)); - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 63d148c..0e6a619 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -39,41 +39,90 @@ ** ****************************************************************************/ -#ifndef QMLCUSTOMPARSER_P_H -#define QMLCUSTOMPARSER_P_H +#ifndef QMLCUSTOMPARSER_H +#define QMLCUSTOMPARSER_H -#include <QtCore/qglobal.h> -#include "qmlcustomparser.h" +#include <QtCore/qbytearray.h> +#include <QtCore/qxmlstream.h> +#include <QtDeclarative/qfxglobal.h> +#include <QtDeclarative/qmlmetatype.h> + +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -namespace QmlParser +QT_MODULE(Declarative) + +class QmlCustomParserPropertyPrivate; +class Q_DECLARATIVE_EXPORT QmlCustomParserProperty { - class Object; - class Property; +public: + QmlCustomParserProperty(); + QmlCustomParserProperty(const QmlCustomParserProperty &); + QmlCustomParserProperty &operator=(const QmlCustomParserProperty &); + ~QmlCustomParserProperty(); + + QByteArray name() const; + + bool isList() const; + QList<QVariant> assignedValues() const; + +private: + friend class QmlCustomParserNodePrivate; + friend class QmlCustomParserPropertyPrivate; + QmlCustomParserPropertyPrivate *d; }; +Q_DECLARE_METATYPE(QmlCustomParserProperty); -class QmlCustomParserNodePrivate +class QmlCustomParserNodePrivate; +class Q_DECLARATIVE_EXPORT QmlCustomParserNode { public: - QByteArray name; - QList<QmlCustomParserProperty> properties; + QmlCustomParserNode(); + QmlCustomParserNode(const QmlCustomParserNode &); + QmlCustomParserNode &operator=(const QmlCustomParserNode &); + ~QmlCustomParserNode(); - static QmlCustomParserNode fromObject(QmlParser::Object *); - static QmlCustomParserProperty fromProperty(QmlParser::Property *); + QByteArray name() const; + + QList<QmlCustomParserProperty> properties() const; + +private: + friend class QmlCustomParserNodePrivate; + QmlCustomParserNodePrivate *d; }; +Q_DECLARE_METATYPE(QmlCustomParserNode); -class QmlCustomParserPropertyPrivate +class Q_DECLARATIVE_EXPORT QmlCustomParser { public: - QmlCustomParserPropertyPrivate() - : isList(false) {} + virtual ~QmlCustomParser() {} + + virtual QByteArray compile(QXmlStreamReader&, bool *ok)=0; + virtual QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok); + virtual QVariant create(const QByteArray &)=0; + virtual void setCustomData(QObject *, const QByteArray &); - QByteArray name; - bool isList; - QList<QVariant> values; + struct Register { + Register(const char *name, QmlCustomParser *parser) { + qmlRegisterCustomParser(name, parser); + } + }; + template<typename T> + struct Define { + static Register instance; + }; }; +#define QML_DEFINE_CUSTOM_PARSER(name, parserClass) \ + template<> QmlCustomParser::Register QmlCustomParser::Define<parserClass>::instance(# name, new parserClass); +#define QML_DEFINE_CUSTOM_PARSER_NS(namespacestring, name, parserClass) \ + template<> QmlCustomParser::Register QmlCustomParser::Define<parserClass>::instance(namespacestring "/" # name, new parserClass); + +#define QML_DEFINE_CUSTOM_TYPE(TYPE, NAME, CUSTOMTYPE) \ + template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterCustomType<TYPE>(#NAME, #TYPE, new CUSTOMTYPE)); QT_END_NAMESPACE -#endif // QMLCUSTOMPARSER_P_H +QT_END_HEADER + +#endif diff --git a/src/declarative/qml/qmlcustomparser_p_p.h b/src/declarative/qml/qmlcustomparser_p_p.h new file mode 100644 index 0000000..96e9b32 --- /dev/null +++ b/src/declarative/qml/qmlcustomparser_p_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLCUSTOMPARSER_P_H +#define QMLCUSTOMPARSER_P_H + +#include <QtCore/qglobal.h> +#include "qmlcustomparser_p.h" + +QT_BEGIN_NAMESPACE + +namespace QmlParser +{ + class Object; + class Property; +}; + +class QmlCustomParserNodePrivate +{ +public: + QByteArray name; + QList<QmlCustomParserProperty> properties; + + static QmlCustomParserNode fromObject(QmlParser::Object *); + static QmlCustomParserProperty fromProperty(QmlParser::Property *); +}; + +class QmlCustomParserPropertyPrivate +{ +public: + QmlCustomParserPropertyPrivate() + : isList(false) {} + + QByteArray name; + bool isList; + QList<QVariant> values; +}; + +QT_END_NAMESPACE + +#endif // QMLCUSTOMPARSER_P_H diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index fbfeca0..63e5c58 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -57,7 +57,7 @@ #include <qvector.h> #include <qlocale.h> #include <QtCore/qcryptographichash.h> -#include <qmlcustomparser.h> +#include <private/qmlcustomparser_p.h> QT_BEGIN_NAMESPACE #ifdef QT_BOOTSTRAPPED diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 7b3291e..e6235e4 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -45,7 +45,7 @@ #include <private/qmlstringconverters_p.h> #include "private/qmetaobjectbuilder_p.h" #include <qml.h> -#include <qmlcustomparser.h> +#include <private/qmlcustomparser_p.h> #include <qperformancelog.h> #include <QStack> #include <private/qmlcompiledcomponent_p.h> diff --git a/src/declarative/qml/qmlxmlparser.cpp b/src/declarative/qml/qmlxmlparser.cpp index b3565a0..35d2c0e 100644 --- a/src/declarative/qml/qmlxmlparser.cpp +++ b/src/declarative/qml/qmlxmlparser.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qmlxmlparser_p.h" -#include "qmlcustomparser.h" +#include "qmlcustomparser_p.h" #include <qfxperf.h> #include <QXmlStreamReader> #include <QStack> diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 968e17b..4837180 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -42,7 +42,7 @@ #include <QtCore/qdebug.h> #include <QtCore/qstack.h> #include <QXmlStreamReader> -#include "qmlcustomparser.h" +#include <private/qmlcustomparser_p.h> #include "qmlopenmetaobject.h" #include <qmlcontext.h> #include <qmlbindablevalue.h> diff --git a/tools/duiviewer/main.cpp b/tools/qmlviewer/main.cpp index cb4ba05..c5676ab 100644 --- a/tools/duiviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -12,7 +12,7 @@ ****************************************************************************/ #include "qml.h" -#include "qfxviewer.h" +#include "qmlviewer.h" #include <QWidget> #include <QDir> #include "qfxtestengine.h" @@ -21,7 +21,7 @@ void usage() { - qWarning("Usage: duiviewer [options] <filename>"); + qWarning("Usage: qmlviewer [options] <filename>"); qWarning(" "); qWarning(" options:"); qWarning(" -v, -version ............................. display version"); @@ -116,9 +116,9 @@ int main(int argc, char ** argv) if (fileName.isEmpty()) usage(); - QFxViewer viewer(testMode, testDir, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget); + QmlViewer viewer(testMode, testDir, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget); viewer.setCacheEnabled(cache); - viewer.openXml(fileName); + viewer.openQml(fileName); if (period>0) viewer.setRecordPeriod(period); if (autorecord_to) diff --git a/tools/duiviewer/qfxviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index b15a8bf..87bebfa 100644 --- a/tools/duiviewer/qfxviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -14,7 +14,7 @@ #include <qfxview.h> #include "qmlbindablevalue.h" -#include "qfxviewer.h" +#include "qmlviewer.h" #include <QtDeclarative/qmlcontext.h> #include <QtDeclarative/qmlengine.h> #include "qml.h" @@ -34,7 +34,7 @@ #include <QProcess> #include <QMenu> -QFxViewer::QFxViewer(QFxTestEngine::TestMode testMode, const QString &testDir, QWidget *parent, Qt::WindowFlags flags) +QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags) { testEngine = 0; @@ -58,12 +58,12 @@ QFxViewer::QFxViewer(QFxTestEngine::TestMode testMode, const QString &testDir, Q resize(width, height); } -void QFxViewer::reload() +void QmlViewer::reload() { - openXml(currentFileName); + openQml(currentFileName); } -void QFxViewer::openXml(const QString& fileName) +void QmlViewer::openQml(const QString& fileName) { setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(fileName)); @@ -180,7 +180,7 @@ void PreviewDeviceSkin::populateContextMenu(QMenu *menu) } -void QFxViewer::setSkin(const QString& skinDirectory) +void QmlViewer::setSkin(const QString& skinDirectory) { DeviceSkinParameters parameters; QString err; @@ -199,7 +199,7 @@ void QFxViewer::setSkin(const QString& skinDirectory) } } -void QFxViewer::setAutoRecord(int from, int to) +void QmlViewer::setAutoRecord(int from, int to) { record_autotime = to-from; if (from) { @@ -210,12 +210,12 @@ void QFxViewer::setAutoRecord(int from, int to) } } -void QFxViewer::setRecordPeriod(int ms) +void QmlViewer::setRecordPeriod(int ms) { record_period = ms; } -void QFxViewer::sceneResized(QSize size) +void QmlViewer::sceneResized(QSize size) { if (size.width() > 0 && size.height() > 0) { canvas->setFixedSize(size.width(), size.height()); @@ -226,13 +226,13 @@ void QFxViewer::sceneResized(QSize size) } } -void QFxViewer::resizeEvent(QResizeEvent *) +void QmlViewer::resizeEvent(QResizeEvent *) { if (!skin) canvas->setFixedSize(width(),height()); } -void QFxViewer::keyPressEvent(QKeyEvent *event) +void QmlViewer::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_0 && devicemode) exit(0); @@ -250,7 +250,6 @@ void QFxViewer::keyPressEvent(QKeyEvent *event) } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) { setRecording(!recordTimer.isActive()); } else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) { - setRecording(!recordTimer.isActive()); canvas->asImage().save("snapshot.png"); qDebug() << "Wrote snapshot.png"; } else if (event->key() == Qt::Key_F4 || (event->key() == Qt::Key_4 && devicemode)) { @@ -274,7 +273,7 @@ void QFxViewer::keyPressEvent(QKeyEvent *event) QWidget::keyPressEvent(event); } -void QFxViewer::setRecording(bool on) +void QmlViewer::setRecording(bool on) { if (on == recordTimer.isActive()) return; @@ -328,7 +327,7 @@ void QFxViewer::setRecording(bool on) qDebug() << "Recording: " << (recordTimer.isActive()?"ON":"OFF"); } -void QFxViewer::timerEvent(QTimerEvent *event) +void QmlViewer::timerEvent(QTimerEvent *event) { if (event->timerId() == recordTimer.timerId()) { frames.append(new QImage(canvas->asImage())); @@ -343,12 +342,12 @@ void QFxViewer::timerEvent(QTimerEvent *event) } } -void QFxViewer::setDeviceKeys(bool on) +void QmlViewer::setDeviceKeys(bool on) { devicemode = on; } -void QFxViewer::setCacheEnabled(bool on) +void QmlViewer::setCacheEnabled(bool on) { QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); if (on == !!nam->cache()) @@ -364,4 +363,4 @@ void QFxViewer::setCacheEnabled(bool on) } } -#include "qfxviewer.moc" +#include "qmlviewer.moc" diff --git a/tools/duiviewer/qfxviewer.h b/tools/qmlviewer/qmlviewer.h index 7a190c5..0fa879d 100644 --- a/tools/duiviewer/qfxviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -11,8 +11,8 @@ ** ****************************************************************************/ -#ifndef QFXVIEWER_H -#define QFXVIEWER_H +#ifndef QMLVIEWER_H +#define QMLVIEWER_H #include <QWidget> #include <QBasicTimer> @@ -25,11 +25,11 @@ class QFxView; class PreviewDeviceSkin; class QFxTestEngine; -class QFxViewer : public QWidget +class QmlViewer : public QWidget { Q_OBJECT public: - QFxViewer(QFxTestEngine::TestMode = QFxTestEngine::NoTest, const QString &testDir = QString(), QWidget *parent=0, Qt::WindowFlags flags=0); + QmlViewer(QFxTestEngine::TestMode = QFxTestEngine::NoTest, const QString &testDir = QString(), QWidget *parent=0, Qt::WindowFlags flags=0); void setRecordDither(const QString& s) { record_dither = s; } void setRecordPeriod(int ms); @@ -43,7 +43,7 @@ public: public slots: void sceneResized(QSize size); - void openXml(const QString& fileName); + void openQml(const QString& fileName); void reload(); protected: diff --git a/tools/duiviewer/duiviewer.pro b/tools/qmlviewer/qmlviewer.pro index eae313e..08d2d2b 100644 --- a/tools/duiviewer/duiviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -1,8 +1,8 @@ DESTDIR = ../../bin QT += declarative script network sql # Input -HEADERS += qfxviewer.h -SOURCES += main.cpp qfxviewer.cpp +HEADERS += qmlviewer.h +SOURCES += main.cpp qmlviewer.cpp include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri) diff --git a/tools/tools.pro b/tools/tools.pro index 12da18c..2c83580 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -24,7 +24,7 @@ mac { SUBDIRS += kmap2qmap -contains(QT_CONFIG, declarative):SUBDIRS += duiviewer qmlconv +contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer qmlconv contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns embedded: SUBDIRS += makeqpf |