source: image
- MouseArea {
+ MouseArea {
anchors.fill: parent
onPressed: Code.startDrag(mouse);
id: rootItem
property bool created: false
- property string image
+ property string image
- property double scaledBottom: y + (height + height*scale) / 2
+ property double scaledBottom: y + (height + height*scale) / 2
property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset)
source: image
source: image
onCreatedChanged: {
if (created) {
- sun.z = 1; // above the sky but below the ground layer
+ sun.z = 1; // above the sky but below the ground layer
window.activeSuns++;
// once item is created, start moving offscreen
dropYAnim.duration = (window.height + window.centerOffset - sun.y) * 16;
itemComponent = Qt.createComponent(paletteItem.componentFile);
if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately
component.statusChanged.connect(createItem);
- else
+ else
createItem();
}
TEMPLATE = app
QT += qml quick network
-SOURCES += main.cpp
+SOURCES += main.cpp
RESOURCES += networkaccessmanagerfactory.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/qml/networkaccessmanagerfactory
QT += qml
SOURCES += main.cpp \
- person.cpp
+ person.cpp
HEADERS += person.h
RESOURCES += adding.qrc
SOURCES += main.cpp \
person.cpp \
- birthdayparty.cpp
+ birthdayparty.cpp
HEADERS += person.h \
birthdayparty.h
RESOURCES += attached.qrc
SOURCES += main.cpp \
person.cpp \
birthdayparty.cpp \
- happybirthdaysong.cpp
+ happybirthdaysong.cpp
HEADERS += person.h \
birthdayparty.h \
happybirthdaysong.h
m_lyrics << "Happy birthday dear " + m_name + ",";
m_lyrics << "Happy birthday to you!";
m_lyrics << "";
-
+
emit nameChanged();
}
-
+
void HappyBirthdaySong::advance()
{
m_line = (m_line + 1) % m_lyrics.count();
Person *guest = party->guest(ii);
QDate rsvpDate;
- QObject *attached =
+ QObject *attached =
qmlAttachedPropertiesObject<BirthdayParty>(guest, false);
if (attached)
rsvpDate = attached->property("rsvp").toDate();
SOURCES += main.cpp \
person.cpp \
- birthdayparty.cpp
+ birthdayparty.cpp
HEADERS += person.h \
birthdayparty.h
RESOURCES += coercion.qrc
SOURCES += main.cpp \
person.cpp \
- birthdayparty.cpp
+ birthdayparty.cpp
HEADERS += person.h \
birthdayparty.h
RESOURCES += default.qrc
QT += qml widgets
SOURCES += main.cpp \
- lineedit.cpp
+ lineedit.cpp
HEADERS += lineedit.h
RESOURCES += extended.qrc
return r;
}
-void LineEditExtension::setRightMargin(int m)
+void LineEditExtension::setRightMargin(int m)
{
int l, r, t, b;
m_lineedit->getTextMargins(&l, &t, &r, &b);
return t;
}
-void LineEditExtension::setTopMargin(int m)
+void LineEditExtension::setTopMargin(int m)
{
int l, r, t, b;
m_lineedit->getTextMargins(&l, &t, &r, &b);
return b;
}
-void LineEditExtension::setBottomMargin(int m)
+void LineEditExtension::setBottomMargin(int m)
{
int l, r, t, b;
m_lineedit->getTextMargins(&l, &t, &r, &b);
SOURCES += main.cpp \
person.cpp \
- birthdayparty.cpp
+ birthdayparty.cpp
HEADERS += person.h \
birthdayparty.h
RESOURCES += grouped.qrc
SOURCES += main.cpp \
person.cpp \
- birthdayparty.cpp
+ birthdayparty.cpp
HEADERS += person.h \
birthdayparty.h
RESOURCES += methods.qrc
SOURCES += main.cpp \
person.cpp \
- birthdayparty.cpp
+ birthdayparty.cpp
HEADERS += person.h \
birthdayparty.h
RESOURCES += properties.qrc
Person *guest = party->guest(ii);
QDate rsvpDate;
- QObject *attached =
+ QObject *attached =
qmlAttachedPropertiesObject<BirthdayParty>(guest, false);
if (attached)
rsvpDate = attached->property("rsvp").toDate();
SOURCES += main.cpp \
person.cpp \
- birthdayparty.cpp
+ birthdayparty.cpp
HEADERS += person.h \
birthdayparty.h
RESOURCES += signal.qrc
shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
}
- Boy {
- name: "Leo Hodges"
+ Boy {
+ name: "Leo Hodges"
BirthdayParty.rsvp: "2009-07-06"
shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 }
}
- Boy {
- name: "Jack Smith"
+ Boy {
+ name: "Jack Smith"
shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 }
}
- Girl {
- name: "Anne Brown"
+ Girl {
+ name: "Anne Brown"
BirthdayParty.rsvp: "2009-07-01"
shoe.size: 7
shoe.color: "red"
shoe.brand: "Marc Jacobs"
- shoe.price: 699.99
+ shoe.price: 699.99
}
// ![1]
m_lyrics << "Happy birthday to you!";
m_lyrics << "";
}
-
+
void HappyBirthdaySong::advance()
{
m_line = (m_line + 1) % m_lyrics.count();
Person *guest = party->guest(ii);
QDate rsvpDate;
- QObject *attached =
+ QObject *attached =
qmlAttachedPropertiesObject<BirthdayParty>(guest, false);
if (attached)
rsvpDate = attached->property("rsvp").toDate();
SOURCES += main.cpp \
person.cpp \
birthdayparty.cpp \
- happybirthdaysong.cpp
+ happybirthdaysong.cpp
HEADERS += person.h \
birthdayparty.h \
happybirthdaysong.h
anchors.centerIn: parent
width: 100; height: 100
- pieSlice: PieSlice {
+ pieSlice: PieSlice {
anchors.fill: parent
- color: "red"
+ color: "red"
}
}
QT += qml quick
HEADERS += piechart.h \
- pieslice.h
+ pieslice.h
SOURCES += piechart.cpp \
pieslice.cpp \
main.cpp
width: 100; height: 100
slices: [
- PieSlice {
+ PieSlice {
anchors.fill: parent
color: "red"
- fromAngle: 0; angleSpan: 110
+ fromAngle: 0; angleSpan: 110
},
- PieSlice {
+ PieSlice {
anchors.fill: parent
color: "black"
- fromAngle: 110; angleSpan: 50
+ fromAngle: 110; angleSpan: 50
},
- PieSlice {
+ PieSlice {
anchors.fill: parent
color: "blue"
fromAngle: 160; angleSpan: 100
QT += qml quick
HEADERS += piechart.h \
- pieslice.h
+ pieslice.h
SOURCES += piechart.cpp \
pieslice.cpp \
main.cpp
width: 100; height: 100
slices: [
- PieSlice {
+ PieSlice {
anchors.fill: parent
color: "red"
- fromAngle: 0; angleSpan: 110
+ fromAngle: 0; angleSpan: 110
},
- PieSlice {
+ PieSlice {
anchors.fill: parent
color: "black"
- fromAngle: 110; angleSpan: 50
+ fromAngle: 110; angleSpan: 50
},
- PieSlice {
+ PieSlice {
anchors.fill: parent
color: "blue"
fromAngle: 160; angleSpan: 100
chapter3-bindings \
chapter4-customPropertyTypes \
chapter5-listproperties \
- chapter6-plugins
+ chapter6-plugins
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.0
import QtTest 1.0
TestCase {
anchors.fill: parent
hoverEnabled: true
onEntered: {
- focusRect.x = myRect.x;
- focusRect.y = myRect.y;
+ focusRect.x = myRect.x;
+ focusRect.y = myRect.y;
focusRect.text = myRect.text;
}
}
PropertyAction { target: ball; property: "direction"; value: "right" }
}
- // Make y move with a velocity of 200
+ // Make y move with a velocity of 200
Behavior on y { SpringAnimation{ velocity: 200; }
}
width: 640; height: 480
color: "#343434"
- Image {
+ Image {
id: userIcon
x: topLeftRect.x; y: topLeftRect.y
source: "qt-logo.png"
/*
This is exactly the same as states.qml, except that we have appended
- a set of transitions to apply animations when the item changes
+ a set of transitions to apply animations when the item changes
between each state.
*/
width: 640; height: 480
color: "#343434"
- Image {
+ Image {
id: userIcon
x: topLeftRect.x; y: topLeftRect.y
source: "qt-logo.png"
property int yAxis: 0
property int angle: 0
- width: front.width; height: front.height
+ width: front.width; height: front.height
front: Image { id: frontImage }
back: Image { source: "back.png" }
Rectangle {
id: window
-
+
width: 480; height: 320
color: "darkgreen"
font.italic: true
}
- MouseArea {
+ MouseArea {
anchors.fill: parent
onClicked: { focusScope.focus = true; Qt.inputMethod.show(); }
}
source: "images/clear.png"
opacity: 0
- MouseArea {
+ MouseArea {
anchors.fill: parent
onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); }
}
function toggle() {
if (toggleswitch.state == "on")
toggleswitch.state = "off";
- else
+ else
toggleswitch.state = "on";
}
//![2]
width: cur.width
height: cur.height
- onFrontChanged: resync();
+ onFrontChanged: resync();
onBackChanged: resync();
function resync() {//TODO: Are the items ever actually visible?
sourceItem: back
hideSource: effect.visible
}
-
+
fragmentShader: "
uniform lowp float qt_Opacity;
uniform sampler2D sourceA;
clip: true // only makes a difference if mode is PreserveAspectCrop
}
- Text {
+ Text {
id: captionItem
anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom
}
if (size)
*size = QSize(width, height);
QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width,
- requestedSize.height() > 0 ? requestedSize.height() : height);
+ requestedSize.height() > 0 ? requestedSize.height() : height);
pixmap.fill(QColor(id).rgba());
//![0]
focus: true
Keys.onRightPressed: mainView.focus = true
- Text {
+ Text {
anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 }
color: "black"
font.pixelSize: 14
property alias interactive: gridView.interactive
onActiveFocusChanged: {
- if (activeFocus)
+ if (activeFocus)
mainView.state = "showGridViews"
}
clip: true
onActiveFocusChanged: {
- if (activeFocus)
+ if (activeFocus)
mainView.state = "showListViews"
}
FocusScope {
onActiveFocusChanged: {
- if (activeFocus)
+ if (activeFocus)
mainView.state = "showTabViews"
}
Rectangle {
id: window
-
+
width: 800; height: 640
color: "#3E606F"
activeFocusOnTab: true
}
- Rectangle {
+ Rectangle {
id: shade
anchors.fill: parent
color: "black"
- opacity: 0
+ opacity: 0
}
states: [
#include <QStringList>
//![0]
-class Animal
+class Animal
{
public:
Animal(const QString &type, const QString &size);
QT += qml quick
-SOURCES += main.cpp
+SOURCES += main.cpp
RESOURCES += stringlistmodel.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/quick/models/stringlistmodel
Item {
id: circle
- x: root.width / 1.2
+ x: root.width / 1.2
y: root.height / 1.7
property real percent: 0
}
ImageParticle {
- z:0
+ z:0
system: sys
groups: ["exhaust"]
source: "qrc:///particleresources/fuzzydot.png"
lifeSpan: 500
y: holder.y
- x: holder.x
+ x: holder.x
velocity: PointDirection { xVariation: 40; yVariation: 40; }
velocityFromMovement: 16
}
//! [0]
- Wander {
+ Wander {
id: wanderer
system: particles
anchors.fill: parent
}
CustomParticle {
- system: sys
+ system: sys
//! [vertex]
vertexShader:"
uniform lowp float qt_Opacity;
varying lowp float fFade;
varying lowp float fBlur;
- void main() {
+ void main() {
defaultMain();
highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
highp float fadeIn = min(t * 10., 1.);
varying lowp float fFade;
varying highp vec2 fPos;
- void main() {
+ void main() {
qt_TexCoord0 = qt_ParticleTex;
highp float size = qt_ParticleData.z;
highp float endSize = qt_ParticleData.w;
varying lowp float fFade;
uniform lowp float qt_Opacity;
- void main() {
+ void main() {
fTex2 = vec2(qt_ParticlePos.x, qt_ParticlePos.y);
//Uncomment this next line for each particle to use full texture, instead of the solid color at the center of the particle.
width: 640
height: 480
ParticleSystem {
- id: sys
+ id: sys
}
ImageParticle {
//![0]
Package {
Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' }
- Item { id: particleDelegate; width: w; height: h; Package.name: 'particles'
+ Item { id: particleDelegate; width: w; height: h; Package.name: 'particles'
Rectangle {
id: wrapper
width: background.width - recipeImage.width - 20; height: recipeImage.height
spacing: 5
- Text {
+ Text {
text: title
font.bold: true; font.pointSize: 16
}
}
transitions: Transition {
- //The only strictly necessary particle specific lines
+ //The only strictly necessary particle specific lines
to: "Details"
reversible: true
ScriptAction {script: {
anchors.centerIn: parent
antialiasing: true;
source: "http://" + Script.getImagePath(content); cache: true
- fillMode: Image.PreserveAspectFit;
+ fillMode: Image.PreserveAspectFit;
width: parent.width-4; height: parent.height-4
onStatusChanged: if (img.status == Image.Ready) {
loading.opacity = 0;
width: 100; height: 50
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
width: 100; height: 50
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
width: 50; height: 100
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
width: 50; height: 50
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
width: 50; height: 50
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
width: 50; height: 50
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
width: 60; height: 50
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
width: 60; height: 50
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
- Rectangle {
+ Rectangle {
id: blueF3
visible: opacity != 0
width: 40; height: 50
color: "lightsteelblue"
border.color: "black"
- radius: 15
+ radius: 15
Behavior on opacity { NumberAnimation {} }
opacity: effectiveOpacity
}
Text { anchors.centerIn: parent; text: "Cut" }
- MouseArea {
+ MouseArea {
anchors.fill: parent
- onClicked: { edit.cut(); editor.state = "" }
+ onClicked: { edit.cut(); editor.state = "" }
}
}
Text { anchors.centerIn: parent; text: "Copy" }
- MouseArea {
+ MouseArea {
anchors.fill: parent
- onClicked: { edit.copy(); editor.state = "selection" }
+ onClicked: { edit.copy(); editor.state = "selection" }
}
}
Text { anchors.centerIn: parent; text: "Paste" }
- MouseArea {
+ MouseArea {
anchors.fill: parent
- onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" }
+ onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" }
}
}
Text { anchors.centerIn: parent; text: "Deselect" }
- MouseArea {
+ MouseArea {
anchors.fill: parent
- onClicked: {
+ onClicked: {
edit.cursorPosition = edit.selectionEnd;
edit.deselect();
- editor.state = ""
- }
+ editor.state = ""
+ }
}
}
}
ListElement {
name: "Panel One"
- notes: [
+ notes: [
ListElement { noteText: "Tap to edit" },
ListElement { noteText: "Drag to move" },
ListElement { noteText: "Flick to scroll" }
]
}
-
+
ListElement {
name: "Panel Two"
notes: [
Button {
anchors { left: parent.left; verticalCenter: parent.verticalCenter }
- text: "New Game"
+ text: "New Game"
onClicked: console.log("This doesn't do anything yet...")
}
source: {
if (type == 0)
return "../shared/pics/redStone.png";
- else if (type == 1)
+ else if (type == 1)
return "../shared/pics/blueStone.png";
else
return "../shared/pics/greenStone.png";
}
//![2]
-//only floods up and right, to see if it can find adjacent same-typed blocks
+//only floods up and right, to see if it can find adjacent same-typed blocks
function floodMoveCheck(column, row, type) {
if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return false;
}
//![4]
-//only floods up and right, to see if it can find adjacent same-typed blocks
+//only floods up and right, to see if it can find adjacent same-typed blocks
function floodMoveCheck(column, row, type) {
if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return false;
$time = $_POST["time"];
if($name == "")
$name = "Anonymous";
- $file = fopen("score_data.xml", "a");
- $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ $file = fopen("score_data.xml", "a");
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
. $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
. $time . "</seconds></record>\n");
echo "Your score has been recorded. Thanks for playing!";
}else{#Read high score list
#Now uses XSLT to display. So just print the file. With XML cruft added.
#Note that firefox at least won't apply the XSLT on a php file. So redirecting
- $file = fopen("scores.xml", "w");
+ $file = fopen("scores.xml", "w");
$ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
. '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
. "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
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>
+ 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.
+ 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>
</html>"
}
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>
+ 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>
+ 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>
+ 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>
+ 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>
+ 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>
+ 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>"
}
}
anchors { left: parent.left; bottom: parent.bottom; margins: 20 }
spacing: 10
- TextButton {
+ TextButton {
text: "Add an item"
onClicked: {
fruitModel.append({
}
}
- TextButton {
- text: "Remove all items"
+ TextButton {
+ text: "Remove all items"
onClicked: fruitModel.clear()
}
}
width: background.width - recipeImage.width - 20; height: recipeImage.height
spacing: 5
- Text {
+ Text {
text: title
font.bold: true; font.pointSize: 16
}
PropertyChanges { target: wrapper; x: 20 }
}
transitions: Transition {
- NumberAnimation { properties: "x"; duration: 200 }
+ NumberAnimation { properties: "x"; duration: 200 }
}
MouseArea {
anchors.fill: parent
width: 320; height: 480
- // This example shows the same model in three different ListView items,
- // with different highlight ranges. The highlight ranges are set by the
+ // This example shows the same model in three different ListView items,
+ // with different highlight ranges. The highlight ranges are set by the
// preferredHighlightBegin and preferredHighlightEnd properties in ListView.
//
// The first ListView does not set a highlight range, so its currentItem
//! [0]
// The delegate for each section header
- Component {
+ Component {
id: sectionHeading
Rectangle {
width: container.width
Loader {
anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter }
width: 300; height: 400
- clip: true;
+ clip: true;
source: "../../demos/samegame/samegame.qml"
}
}
/*!
Returns the maximum packet size allowed. By default this is
2,147,483,647 bytes.
-
+
If a packet claiming to be larger than the maximum packet size is received,
the QPacketProtocol::invalidPacket() signal is emitted.
struct instr_ret {
MOTH_INSTR_HEADER
Param result;
- };
+ };
struct instr_loadRuntimeString {
MOTH_INSTR_HEADER
int stringId;
};
struct instr_jump {
MOTH_INSTR_HEADER
- ptrdiff_t offset;
+ ptrdiff_t offset;
};
struct instr_cjump {
MOTH_INSTR_HEADER
typedef Instr::instr_##FMT DataType; \
static const DataType &data(const Instr &instr) { return instr.FMT; } \
static void setData(Instr &instr, const DataType &v) { instr.FMT = v; } \
- };
+ };
FOR_EACH_MOTH_INSTR(MOTH_INSTR_META_TEMPLATE);
#undef MOTH_INSTR_META_TEMPLATE
}
Expr *BasicBlock::CONST(Type type, double value)
-{
+{
Const *e = function->New<Const>();
if (type == NumberType) {
int ival = (int)value;
}
Name *BasicBlock::NAME(const QString &id, quint32 line, quint32 column)
-{
+{
Name *e = function->New<Name>();
e->init(function->newString(id), line, column);
return e;
}
Expr *BasicBlock::UNOP(AluOp op, Expr *expr)
-{
+{
Unop *e = function->New<Unop>();
e->init(op, expr);
return e;
}
Expr *BasicBlock::CALL(Expr *base, ExprList *args)
-{
+{
Call *e = function->New<Call>();
e->init(base, args);
int argc = 0;
}
Stmt *BasicBlock::EXP(Expr *expr)
-{
+{
if (isTerminated())
return 0;
}
Stmt *BasicBlock::MOVE(Expr *target, Expr *source)
-{
+{
if (isTerminated())
return 0;
return s;
}
-Stmt *BasicBlock::JUMP(BasicBlock *target)
+Stmt *BasicBlock::JUMP(BasicBlock *target)
{
if (isTerminated())
return 0;
return s;
}
-Stmt *BasicBlock::CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
+Stmt *BasicBlock::CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
{
if (isTerminated())
return 0;
delete m_statesDelegate;
}
-QDataStream &operator<<(QDataStream &ds,
+QDataStream &operator<<(QDataStream &ds,
const QQmlEngineDebugService::QQmlObjectData &data)
{
ds << data.url << data.lineNumber << data.columnNumber << data.idString
return ds;
}
-QDataStream &operator>>(QDataStream &ds,
+QDataStream &operator>>(QDataStream &ds,
QQmlEngineDebugService::QQmlObjectData &data)
{
ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
return ds;
}
-QDataStream &operator<<(QDataStream &ds,
+QDataStream &operator<<(QDataStream &ds,
const QQmlEngineDebugService::QQmlObjectProperty &data)
{
ds << (int)data.type << data.name << data.value << data.valueTypeName
return ds;
}
-QDataStream &operator>>(QDataStream &ds,
+QDataStream &operator>>(QDataStream &ds,
QQmlEngineDebugService::QQmlObjectProperty &data)
{
int type;
return QString(QStringLiteral("<unknown value>"));
}
-void QQmlEngineDebugService::buildObjectDump(QDataStream &message,
+void QQmlEngineDebugService::buildObjectDump(QDataStream &message,
QObject *object, bool recur, bool dumpProperties)
{
message << objectData(object);
QObjectList children = object->children();
-
+
int childrenCount = children.count();
for (int ii = 0; ii < children.count(); ++ii) {
if (qobject_cast<QQmlContext*>(children[ii]))
MouseArea {
anchors.fill: parent
onClicked: {
- if (model.hasModelChildren)
+ if (model.hasModelChildren)
view.model.rootIndex = view.model.modelIndex(index)
}
}
width: 80; height: 80
color: "red"
- NumberAnimation on opacity {
+ NumberAnimation on opacity {
to: 0
- duration: 1000
+ duration: 1000
onRunningChanged: {
if (!running) {
width: 100
height: 100
-
+
function createIt() {
//![0]
var newObject = Qt.createQmlObject('import QtQuick 2.0; Rectangle {color: "red"; width: 20; height: 20}',
Text { text: "Attributes:" }
Repeater {
model: attributes
- Text { text: description }
+ Text { text: description }
}
}
}
import QtQuick 2.0
Rectangle {
- width: 240; height: 320;
+ width: 240; height: 320;
ListView {
anchors.fill: parent
text: modelData.firstName + " " + modelData.lastName
}
}
- }
+ }
}
//! [document]
import QtQuick 2.0
Rectangle {
- width: 240; height: 320;
+ width: 240; height: 320;
ListView {
anchors.fill: parent
delegate: Text {
text: modelData.firstName + " " + modelData.lastName
}
- }
+ }
}
//! [document]
import QtQuick 2.0
Rectangle {
- width: 240; height: 320;
+ width: 240; height: 320;
resources: [
Component {
anchors.fill: parent
model: contactModel
delegate: contactDelegate
- }
+ }
}
//! [document]
property alias text: textItem.text
width: 100; height: 30
- border.width: 1
+ border.width: 1
radius: 5
antialiasing: true
import QtQuick 2.0
Item {
- QtObject {
+ QtObject {
id: attributes
property string name
property int size
QVariant redirect = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (redirect.isValid()) {
m_url = m_url.resolved(redirect.toUrl());
- delete m_reply;
-
+ delete m_reply;
+
QNetworkRequest request;
request.setUrl(m_url);
callbackFunction);
result = i->result();
- } else {
+ } else {
QFile f(localFile);
return args[0].toValue(engine);
} else if (returnType != QMetaType::Void) {
-
+
CallArgument arg;
arg.initAsType(returnType);
}
/*!
- Returns the match score for converting \a actual to be of type \a conversionType. A
+ Returns the match score for converting \a actual to be of type \a conversionType. A
zero score means "perfect match" whereas a higher score is worse.
The conversion table is copied out of the \l QScript::callQtMethod() function.
QMetaMethod method = mo->method(current->overrideIndex);
dummy.load(method);
-
+
// Look for overloaded methods
QByteArray methodName = method.name();
for (int ii = current->overrideIndex - 1; ii >= methodOffset; --ii) {
int *args = 0;
QVarLengthArray<int, 9> dummy;
- args = QQmlPropertyCache::methodParameterTypes(object, data.coreIndex, dummy,
+ args = QQmlPropertyCache::methodParameterTypes(object, data.coreIndex, dummy,
&unknownTypeError);
if (!args) {
/*!
Resolve the overloaded method to call. The algorithm works conceptually like this:
1. Resolve the set of overloads it is *possible* to call.
- Impossible overloads include those that have too many parameters or have parameters
- of unknown type.
- 2. Filter the set of overloads to only contain those with the closest number of
+ Impossible overloads include those that have too many parameters or have parameters
+ of unknown type.
+ 2. Filter the set of overloads to only contain those with the closest number of
parameters.
For example, if we are called with 3 parameters and there are 2 overloads that
take 2 parameters and one that takes 3, eliminate the 2 parameter overloads.
- 3. Find the best remaining overload based on its match score.
+ 3. Find the best remaining overload based on its match score.
If two or more overloads have the same match score, call the last one. The match
score is constructed by adding the matchScore() result for each of the parameters.
*/
continue; // We already have a better option
int methodMatchScore = 0;
- for (int ii = 0; ii < methodArgumentCount; ++ii)
+ for (int ii = 0; ii < methodArgumentCount; ++ii)
methodMatchScore += MatchScore((v = callArgs->args[ii]), methodArgTypes[ii]);
if (bestParameterScore > methodParameterScore || bestMatchScore > methodMatchScore) {
QString error = QLatin1String("Unable to determine callable overload. Candidates are:");
const QQmlPropertyData *candidate = &data;
while (candidate) {
- error += QLatin1String("\n ") +
+ error += QLatin1String("\n ") +
QString::fromUtf8(object->metaObject()->method(candidate->coreIndex).methodSignature().constData());
candidate = RelatedMethod(object, candidate, dummy);
}
jsonObjectPtr->~QJsonObject();
} else if (type == QMetaType::QJsonValue) {
jsonValuePtr->~QJsonValue();
- }
+ }
}
void *CallArgument::dataPtr()
using namespace QV4;
-// We allow the following JavaScript types to be passed between the main and
+// We allow the following JavaScript types to be passed between the main and
// the secondary thread:
// + undefined
// + null
// + Boolean
// + String
-// + Function
+// + Function
// + Array
// + "Simple" Objects
// + Number
return rv;
}
-// XXX TODO: Check that worker script is exception safe in the case of
+// XXX TODO: Check that worker script is exception safe in the case of
// serialization/deserialization failures
#define ALIGN(size) (((size) + 3) & ~3)
reserve(data, utf16size + sizeof(quint32));
push(data, valueheader(WorkerString, length));
-
+
int offset = data.size();
data.resize(data.size() + utf16size);
char *buffer = data.data() + offset;
_validTokenText = true;
_tokenText.resize(0);
startCode--;
- while (startCode != _codePtr - 1)
+ while (startCode != _codePtr - 1)
_tokenText += *startCode++;
while (_codePtr <= _endPtr) {
QBitField::QBitField(const QBitField &other)
: bits(other.bits), ownData(other.ownData), data(other.data)
{
- if (ownData)
+ if (ownData)
++(*ownData);
}
QBitField::~QBitField()
{
- if (ownData)
+ if (ownData)
if(0 == --(*ownData)) delete [] ownData;
}
if (other.data == data)
return *this;
- if (ownData)
+ if (ownData)
if(0 == --(*ownData)) delete [] ownData;
bits = other.bits;
ownData = other.ownData;
data = other.data;
- if (ownData)
+ if (ownData)
++(*ownData);
return *this;
// QFieldList is a simple linked list, that can append and prepend and also
// maintains a count
template<class N, N *N::*nextMember>
-class QFieldList
+class QFieldList
{
public:
inline QFieldList();
}
value->*nextMember = 0;
--_count;
- }
+ }
return value;
}
template<typename T>
QFiniteStack<T>::QFiniteStack()
-: _array(0), _alloc(0), _size(0)
+: _array(0), _alloc(0), _size(0)
{
}
return _array[_size];
}
}
-
+
template<typename T>
int QFiniteStack<T>::count() const
{
}
template<typename T>
-void QFiniteStack<T>::allocate(int size)
+void QFiniteStack<T>::allocate(int size)
{
Q_ASSERT(_array == 0);
Q_ASSERT(_alloc == 0);
{
if (QTypeInfo<T>::isComplex) {
T *i = _array + _size;
- while (i != _array)
+ while (i != _array)
(--i)->~T();
}
QHashedStringRef QHashedStringRef::mid(int offset, int length) const
{
Q_ASSERT(offset < m_length);
- return QHashedStringRef(m_data + offset,
+ return QHashedStringRef(m_data + offset,
(length == -1 || (offset + length) > m_length)?(m_length - offset):length);
}
bool QHashedStringRef::endsWith(const QString &s) const
{
- return s.length() < m_length &&
+ return s.length() < m_length &&
QHashedString::compare(s.constData(), m_data + m_length - s.length(), s.length());
}
bool QHashedStringRef::startsWith(const QString &s) const
{
- return s.length() < m_length &&
+ return s.length() < m_length &&
QHashedString::compare(s.constData(), m_data, s.length());
}
};
class QHashedCStringRef;
-class Q_AUTOTEST_EXPORT QHashedStringRef
+class Q_AUTOTEST_EXPORT QHashedStringRef
{
public:
inline QHashedStringRef();
}
inline bool equals(const QHashedStringRef &string) const {
- return length == string.length() &&
- hash == string.hash() &&
+ return length == string.length() &&
+ hash == string.hash() &&
(isQString()?QHashedString::compare(string.constData(), (QChar *)utf16Data(), length):
QHashedString::compare(string.constData(), cStrData(), length));
}
inline bool equals(const QHashedCStringRef &string) const {
- return length == string.length() &&
- hash == string.hash() &&
+ return length == string.length() &&
+ hash == string.hash() &&
(isQString()?QHashedString::compare((QChar *)utf16Data(), string.constData(), length):
QHashedString::compare(string.constData(), cStrData(), length));
}
class Q_AUTOTEST_EXPORT QStringHashData
{
public:
- QStringHashData()
+ QStringHashData()
: buckets(0), numBuckets(0), size(0), numBits(0)
#ifdef QSTRINGHASH_LINK_DEBUG
, linkCount(0)
return ConstIterator();
}
-inline uint qHash(const QHashedString &string)
-{
- return uint(string.hash());
+inline uint qHash(const QHashedString &string)
+{
+ return uint(string.hash());
}
-inline uint qHash(const QHashedStringRef &string)
-{
- return uint(string.hash());
+inline uint qHash(const QHashedStringRef &string)
+{
+ return uint(string.hash());
}
-QHashedString::QHashedString()
-: QString(), m_hash(0)
+QHashedString::QHashedString()
+: QString(), m_hash(0)
{
}
-QHashedString::QHashedString(const QString &string)
-: QString(string), m_hash(0)
+QHashedString::QHashedString(const QString &string)
+: QString(string), m_hash(0)
{
}
-QHashedString::QHashedString(const QString &string, quint32 hash)
-: QString(string), m_hash(hash)
+QHashedString::QHashedString(const QString &string, quint32 hash)
+: QString(string), m_hash(hash)
{
}
-QHashedString::QHashedString(const QHashedString &string)
-: QString(string), m_hash(string.m_hash)
+QHashedString::QHashedString(const QHashedString &string)
+: QString(string), m_hash(string.m_hash)
{
}
bool QHashedString::operator==(const QHashedString &string) const
{
- return (string.m_hash == m_hash || !string.m_hash || !m_hash) &&
+ return (string.m_hash == m_hash || !string.m_hash || !m_hash) &&
static_cast<const QString &>(*this) == static_cast<const QString &>(string);
}
bool QHashedString::operator==(const QHashedStringRef &string) const
{
return length() == string.m_length &&
- (string.m_hash == m_hash || !string.m_hash || !m_hash) &&
+ (string.m_hash == m_hash || !string.m_hash || !m_hash) &&
QHashedString::compare(constData(), string.m_data, string.m_length);
}
quint32 QHashedString::hash() const
-{
+{
if (!m_hash) computeHash();
return m_hash;
}
quint32 QHashedString::existingHash() const
-{
+{
return m_hash;
}
-QHashedStringRef::QHashedStringRef()
+QHashedStringRef::QHashedStringRef()
: m_data(0), m_length(0), m_hash(0)
{
}
bool QHashedStringRef::operator==(const QHashedString &string) const
{
- return m_length == string.length() &&
+ return m_length == string.length() &&
(m_hash == string.m_hash || !m_hash || !string.m_hash) &&
QHashedString::compare(string.constData(), m_data, m_length);
}
bool QHashedStringRef::operator==(const QHashedStringRef &string) const
{
- return m_length == string.m_length &&
+ return m_length == string.m_length &&
(m_hash == string.m_hash || !m_hash || !string.m_hash) &&
QHashedString::compare(string.m_data, m_data, m_length);
}
bool QHashedStringRef::operator==(const QHashedCStringRef &string) const
{
- return m_length == string.m_length &&
+ return m_length == string.m_length &&
(m_hash == string.m_hash || !m_hash || !string.m_hash) &&
QHashedString::compare(m_data, string.m_data, m_length);
}
bool QHashedStringRef::operator!=(const QHashedString &string) const
{
- return m_length != string.length() ||
+ return m_length != string.length() ||
(m_hash != string.m_hash && m_hash && string.m_hash) ||
!QHashedString::compare(string.constData(), m_data, m_length);
}
}
quint32 QHashedStringRef::hash() const
-{
+{
if (!m_hash) computeHash();
return m_hash;
}
{
int l = m_length;
const char *d = m_data;
- while (l--)
+ while (l--)
*output++ = *d++;
}
-bool QHashedString::compare(const QChar *lhs, const char *rhs, int length)
+bool QHashedString::compare(const QChar *lhs, const char *rhs, int length)
{
Q_ASSERT(lhs && rhs);
const quint16 *l = (const quint16*)lhs;
- while (length--)
+ while (length--)
if (*l++ != *rhs++) return false;
return true;
}
-bool QHashedString::compare(const char *lhs, const char *rhs, int length)
+bool QHashedString::compare(const char *lhs, const char *rhs, int length)
{
Q_ASSERT(lhs && rhs);
return 0 == ::memcmp(lhs, rhs, length);
// example where you would write:
// QSet<QString> strings;
// for (int ii = 0; ii < mystrings.count(); ++ii) {
-// if (strings.contains(mystrings.at(ii)))
+// if (strings.contains(mystrings.at(ii)))
// qFatal("Duplication!");
// strings.insert(mystrings);
// }
// if (strings.testAndSet(qHash(mystrings.at(ii)))) {
// // The string *might* be duplicated
// for (int jj = 0; jj < ii; ++jj) {
-// if (mystrings.at(ii) == mystrings.at(jj))
+// if (mystrings.at(ii) == mystrings.at(jj))
// qFatal("Duplication!");
// }
// }
\brief The QIntrusiveList class is a template class that provides a list of objects using static storage.
\internal
-QIntrusiveList creates a linked list of objects. Adding and removing objects from the
+QIntrusiveList creates a linked list of objects. Adding and removing objects from the
QIntrusiveList is a constant time operation and is very quick. The list performs no memory
allocations, but does require the objects being added to the list to contain a QIntrusiveListNode
instance for the list's use. Even so, for small lists QIntrusiveList uses less memory than Qt's
/*!
\fn void QIntrusiveList::insert(N *object);
-Insert \a object into the list. If \a object is a member of this, or another list, it will be
+Insert \a object into the list. If \a object is a member of this, or another list, it will be
removed and inserted at the head of this list.
*/
inline iterator &operator++();
inline iterator &erase();
-
+
private:
N *_value;
};
};
template<class N, QIntrusiveListNode N::*member>
-QIntrusiveList<N, member>::iterator::iterator()
-: _value(0)
+QIntrusiveList<N, member>::iterator::iterator()
+: _value(0)
{
}
template<class N, QIntrusiveListNode N::*member>
-QIntrusiveList<N, member>::iterator::iterator(N *value)
-: _value(value)
+QIntrusiveList<N, member>::iterator::iterator(N *value)
+: _value(value)
{
}
template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::iterator::operator*() const
-{
- return _value;
+N *QIntrusiveList<N, member>::iterator::operator*() const
+{
+ return _value;
}
template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::iterator::operator->() const
-{
- return _value;
+N *QIntrusiveList<N, member>::iterator::operator->() const
+{
+ return _value;
}
template<class N, QIntrusiveListNode N::*member>
-bool QIntrusiveList<N, member>::iterator::operator==(const iterator &other) const
-{
- return other._value == _value;
+bool QIntrusiveList<N, member>::iterator::operator==(const iterator &other) const
+{
+ return other._value == _value;
}
template<class N, QIntrusiveListNode N::*member>
-bool QIntrusiveList<N, member>::iterator::operator!=(const iterator &other) const
-{
- return other._value != _value;
+bool QIntrusiveList<N, member>::iterator::operator!=(const iterator &other) const
+{
+ return other._value != _value;
}
template<class N, QIntrusiveListNode N::*member>
-typename QIntrusiveList<N, member>::iterator &QIntrusiveList<N, member>::iterator::operator++()
-{
- _value = QIntrusiveList<N, member>::next(_value);
- return *this;
+typename QIntrusiveList<N, member>::iterator &QIntrusiveList<N, member>::iterator::operator++()
+{
+ _value = QIntrusiveList<N, member>::next(_value);
+ return *this;
}
template<class N, QIntrusiveListNode N::*member>
-typename QIntrusiveList<N, member>::iterator &QIntrusiveList<N, member>::iterator::erase()
-{
- N *old = _value;
- _value = QIntrusiveList<N, member>::next(_value);
- (old->*member).remove();
+typename QIntrusiveList<N, member>::iterator &QIntrusiveList<N, member>::iterator::erase()
+{
+ N *old = _value;
+ _value = QIntrusiveList<N, member>::next(_value);
+ (old->*member).remove();
return *this;
}
-
+
template<class N, QIntrusiveListNode N::*member>
-QIntrusiveList<N, member>::QIntrusiveList()
-: __first(0)
+QIntrusiveList<N, member>::QIntrusiveList()
+: __first(0)
{
}
}
template<class N, QIntrusiveListNode N::*member>
-void QIntrusiveList<N, member>::insert(N *n)
+void QIntrusiveList<N, member>::insert(N *n)
{
QIntrusiveListNode *nnode = &(n->*member);
nnode->remove();
}
template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::first() const
-{
- return __first?nodeToN(__first):0;
+N *QIntrusiveList<N, member>::first() const
+{
+ return __first?nodeToN(__first):0;
}
template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::next(N *current)
+N *QIntrusiveList<N, member>::next(N *current)
{
QIntrusiveListNode *nextnode = (current->*member)._next;
N *nextstruct = nextnode?nodeToN(nextnode):0;
}
template<class N, QIntrusiveListNode N::*member>
-typename QIntrusiveList<N, member>::iterator QIntrusiveList<N, member>::begin()
-{
- return __first?iterator(nodeToN(__first)):iterator();
+typename QIntrusiveList<N, member>::iterator QIntrusiveList<N, member>::begin()
+{
+ return __first?iterator(nodeToN(__first)):iterator();
}
template<class N, QIntrusiveListNode N::*member>
-typename QIntrusiveList<N, member>::iterator QIntrusiveList<N, member>::end()
-{
- return iterator();
+typename QIntrusiveList<N, member>::iterator QIntrusiveList<N, member>::end()
+{
+ return iterator();
}
template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::nodeToN(QIntrusiveListNode *node)
+N *QIntrusiveList<N, member>::nodeToN(QIntrusiveListNode *node)
{
return (N *)((char *)node - ((char *)&(((N *)0)->*member) - (char *)0));
}
{
public:
// The class has a destructor that needs to be called
- class Class {
+ class Class {
public:
inline QQmlPool *pool() const;
class POD {
public:
inline QQmlPool *pool() const;
-
+
private:
void *operator new(size_t);
void *operator new(size_t, void *m) { return m; }
int count() const {
return m_length;
}
- int length() const {
- return m_length;
+ int length() const {
+ return m_length;
}
- const T &at(int index) const {
- Q_ASSERT(index < m_length);
- return m_data[index];
+ const T &at(int index) const {
+ Q_ASSERT(index < m_length);
+ return m_data[index];
};
T &operator[](int index) {
- Q_ASSERT(index < m_length);
- return m_data[index];
+ Q_ASSERT(index < m_length);
+ return m_data[index];
};
const T *data() const { return m_data; }
private:
inline QQmlRefPointer<T> &operator=(const QQmlRefPointer<T> &o);
inline QQmlRefPointer<T> &operator=(T *);
-
+
inline bool isNull() const { return !o; }
inline T* operator->() const { return o; }
T *o;
};
-QQmlRefCount::QQmlRefCount()
-: refCount(1)
+QQmlRefCount::QQmlRefCount()
+: refCount(1)
{
}
-QQmlRefCount::~QQmlRefCount()
+QQmlRefCount::~QQmlRefCount()
{
Q_ASSERT(refCount.load() == 0);
}
-void QQmlRefCount::addref()
-{
+void QQmlRefCount::addref()
+{
Q_ASSERT(refCount.load() > 0);
- refCount.ref();
+ refCount.ref();
}
-void QQmlRefCount::release()
-{
+void QQmlRefCount::release()
+{
Q_ASSERT(refCount.load() > 0);
- if (!refCount.deref())
- destroy();
+ if (!refCount.deref())
+ destroy();
}
int QQmlRefCount::count() const
return refCount.load();
}
-void QQmlRefCount::destroy()
-{
- delete this;
+void QQmlRefCount::destroy()
+{
+ delete this;
}
template<class T>
QQmlRefPointer<T>::QQmlRefPointer()
-: o(0)
+: o(0)
{
}
template<class T>
QQmlRefPointer<T>::QQmlRefPointer(T *o)
-: o(o)
+: o(o)
{
if (o) o->addref();
}
void threadEvent();
protected:
- virtual bool event(QEvent *);
+ virtual bool event(QEvent *);
private:
- struct MainObject : public QObject {
+ struct MainObject : public QObject {
MainObject(QQmlThreadPrivate *p);
virtual bool event(QEvent *e);
QQmlThreadPrivate *p;
QWaitCondition _wait;
};
-QQmlThreadPrivate::MainObject::MainObject(QQmlThreadPrivate *p)
-: p(p)
+QQmlThreadPrivate::MainObject::MainObject(QQmlThreadPrivate *p)
+: p(p)
{
}
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
-bool QQmlThreadPrivate::MainObject::event(QEvent *e)
+bool QQmlThreadPrivate::MainObject::event(QEvent *e)
{
- if (e->type() == QEvent::User)
+ if (e->type() == QEvent::User)
p->mainEvent();
return QObject::event(e);
}
-
+
QQmlThreadPrivate::QQmlThreadPrivate(QQmlThread *q)
-: q(q), m_threadProcessing(false), m_mainProcessing(false), m_shutdown(false),
+: q(q), m_threadProcessing(false), m_mainProcessing(false), m_shutdown(false),
m_mainThreadWaiting(false), mainSync(0), m_mainObject(this)
{
}
bool QQmlThreadPrivate::event(QEvent *e)
{
- if (e->type() == QEvent::User)
+ if (e->type() == QEvent::User)
threadEvent();
return QThread::event(e);
}
unlock();
}
-void QQmlThreadPrivate::threadEvent()
+void QQmlThreadPrivate::threadEvent()
{
lock();
class QThread;
class QQmlThreadPrivate;
-class QQmlThread
+class QQmlThread
{
public:
QQmlThread();
};
QRecursionNode::QRecursionNode()
-: _r(0)
+: _r(0)
{
}
#define QML_DECLARE_TYPE(TYPE) \
Q_DECLARE_METATYPE(TYPE *) \
- Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
+ Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \
- Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
+ Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
#define QML_DECLARE_INTERFACE(INTERFACE) \
QML_DECLARE_TYPE(INTERFACE)
QML_GETTYPENAMES
QQmlPrivate::RegisterType type = {
- 0,
+ 0,
qRegisterNormalizedMetaType<T *>(pointerName.constData()),
qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
- QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
QML_GETTYPENAMES
QQmlPrivate::RegisterType type = {
- 0,
+ 0,
qRegisterNormalizedMetaType<T *>(pointerName.constData()),
qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
- QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
QML_GETTYPENAMES
QQmlPrivate::RegisterType type = {
- 0,
+ 0,
qRegisterNormalizedMetaType<T *>(pointerName.constData()),
qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
- QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
}
template<typename T, typename E>
-int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
+int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
const char *qmlName)
{
QML_GETTYPENAMES
QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
- const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
+ const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
if (!attached) {
attached = QQmlPrivate::attachedPropertiesFunc<T>();
attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<T>();
}
QQmlPrivate::RegisterType type = {
- 0,
+ 0,
qRegisterNormalizedMetaType<T *>(pointerName.constData()),
qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
attached,
attachedMetaObject,
- QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
}
template<typename T>
-int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
+int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
const char *qmlName, QQmlCustomParser *parser)
{
QML_GETTYPENAMES
QQmlPrivate::RegisterType type = {
- 0,
+ 0,
qRegisterNormalizedMetaType<T *>(pointerName.constData()),
qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
- QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
- if (url.isRelative()) {
+ if (url.isRelative()) {
// User input check must go here, because QQmlPrivate::qmlregister is also used internally for composite types
qWarning("qmlRegisterType requires absolute URLs.");
return 0;
/*!
\internal
\class QQmlCleanup
-\brief The QQmlCleanup provides a callback when a QQmlEngine is deleted.
+\brief The QQmlCleanup provides a callback when a QQmlEngine is deleted.
Any object that needs cleanup to occur before the QQmlEngine's V8 engine is
destroyed should inherit from QQmlCleanup. The clear() virtual method will be
if (prev) *prev = next;
if (next) next->prev = prev;
- prev = 0;
+ prev = 0;
next = 0;
}
#include <private/qtqmlglobal_p.h>
-//
+//
// W A R N I N G
// -------------
//
qDeleteAll(resolvedTypes);
resolvedTypes.clear();
- for (int ii = 0; ii < propertyCaches.count(); ++ii)
+ for (int ii = 0; ii < propertyCaches.count(); ++ii)
if (propertyCaches.at(ii))
propertyCaches.at(ii)->release();
/*!
Returns the property cache, creating one if it doesn't already exist. The cache is not referenced.
*/
-QQmlPropertyCache *QQmlCompiledData::TypeReference::createPropertyCache(QQmlEngine *engine)
+QQmlPropertyCache *QQmlCompiledData::TypeReference::createPropertyCache(QQmlEngine *engine)
{
if (typePropertyCache) {
return typePropertyCache;
return ptrOffset;
}
-int QQmlCompiledData::nextInstructionIndex()
-{
+int QQmlCompiledData::nextInstructionIndex()
+{
return bytecode.size();
}
-QQmlInstruction *QQmlCompiledData::instruction(int index)
-{
+QQmlInstruction *QQmlCompiledData::instruction(int index)
+{
return (QQmlInstruction *)(bytecode.constData() + index);
}
: compileState(0), pool(pool), output(0), engine(0), enginePrivate(0), unitRoot(0), unit(0), cachedComponentTypeRef(-1),
cachedTranslationContextIndex(-1), componentStats(0)
{
- if (compilerStatDump())
+ if (compilerStatDump())
componentStats = pool->New<ComponentStats>();
}
if (tr.type && obj->metatype->metaObject() == &QQmlComponent::staticMetaObject) {
COMPILE_CHECK(buildComponent(obj, ctxt));
return true;
- }
+ }
if (tr.component) {
- typedef QQmlInstruction I;
+ typedef QQmlInstruction I;
const I *init = ((const I *)tr.component->bytecode.constData());
Q_ASSERT(init && tr.component->instructionType(init) == QQmlInstruction::Init);
-
+
// Adjust stack depths to include nested components
compileState->objectDepth.pushPop(init->init.objectStackSize);
compileState->listDepth.pushPop(init->init.listStackSize);
BindingContext objCtxt(obj);
// Create the synthesized meta object, ignoring aliases
- COMPILE_CHECK(checkDynamicMeta(obj));
+ COMPILE_CHECK(checkDynamicMeta(obj));
COMPILE_CHECK(mergeDynamicMetaProperties(obj));
COMPILE_CHECK(buildDynamicMeta(obj, Normal));
}
}
- // Merge
+ // Merge
Property *defaultProperty = 0;
Property *skipProperty = 0;
if (obj->defaultProperty) {
}
defaultProperty->values.insertAfter(insertPos, explicitProperty->values);
- }
+ }
}
QQmlCustomParser *cp = 0;
Instruction::DeferInit dinit;
// XXX - these are now massive over allocations
dinit.bindingsSize = compileState->totalBindingsCount;
- dinit.parserStatusSize = compileState->parserStatusCount;
- dinit.objectStackSize = compileState->objectDepth.maxDepth();
- dinit.listStackSize = compileState->listDepth.maxDepth();
+ dinit.parserStatusSize = compileState->parserStatusCount;
+ dinit.objectStackSize = compileState->objectDepth.maxDepth();
+ dinit.listStackSize = compileState->listDepth.maxDepth();
output->addInstruction(dinit);
for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
}
for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- if (prop->isDeferred)
+ if (prop->isDeferred)
continue;
if (prop->isAlias)
genValueProperty(prop, obj);
Instruction::Done done;
output->addInstruction(done);
- output->instruction(createInstruction)->createComponent.count =
+ output->instruction(createInstruction)->createComponent.count =
output->nextInstructionIndex() - nextInstructionIndex;
compileState = oldCompileState;
if (obj->properties.isMany() ||
(obj->properties.isOne() && obj->properties.first()->name() != id_string))
COMPILE_EXCEPTION(obj->properties.first(), tr("Component elements may not contain properties other than id"));
-
+
if (!obj->properties.isEmpty())
idProp = obj->properties.first();
if (idProp) {
- if (idProp->value || idProp->values.isMany() || idProp->values.first()->object)
+ if (idProp->value || idProp->values.isMany() || idProp->values.first()->object)
COMPILE_EXCEPTION(idProp, tr("Invalid component id specification"));
COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()))
QQmlScript::Object *obj,
const BindingContext &ctxt)
{
- if (prop->isEmpty())
+ if (prop->isEmpty())
COMPILE_EXCEPTION(prop, tr("Empty property assignment"));
if (isAttachedPropertyName(prop->name())) {
unit->imports().resolveType(prop->name(), &type, 0, 0, &typeNamespace);
if (typeNamespace) {
- COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj,
+ COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj,
ctxt));
return true;
} else if (!type || !type->attachedPropertiesType()) {
// We can't error here as the "id" property does not require a
// successful index resolution
- if (prop->index != -1)
+ if (prop->index != -1)
prop->type = prop->core.propType;
// Check if this is an alias
- if (prop->index != -1 &&
- prop->parent &&
- prop->parent->type != -1 &&
+ if (prop->index != -1 &&
+ prop->parent &&
+ prop->parent->type != -1 &&
output->types.at(prop->parent->type).component) {
QQmlPropertyCache *cache = output->types.at(prop->parent->type).component->rootPropertyCache;
prop->isAlias = true;
}
- if (prop->index != -1 && !prop->values.isEmpty())
+ if (prop->index != -1 && !prop->values.isEmpty())
prop->parent->setBindingBit(prop->index);
}
QQmlType *type = 0;
unit->imports().resolveType(ns, prop->name(), &type, 0, 0);
- if (!type || !type->attachedPropertiesType())
+ if (!type || !type->attachedPropertiesType())
COMPILE_EXCEPTION(prop, tr("Non-existent attached object"));
if (!prop->value)
compileState->root->componentCompileState = compileState;
- if (componentStats)
+ if (componentStats)
componentStats->savedComponentStats.append(componentStats->componentStat);
}
if (!prop->value->metatype)
COMPILE_EXCEPTION(prop, tr("Invalid grouped property access"));
- if (!prop->values.isEmpty())
+ if (!prop->values.isEmpty())
COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign a value directly to a grouped property"));
obj->addGroupedProperty(prop);
for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
QQmlPropertyData *d = property(obj, prop->name());
- if (d == 0)
+ if (d == 0)
COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString()));
prop->index = d->coreIndex;
for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
Q_ASSERT(v->object);
- COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt));
+ COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt));
}
obj->addValueProperty(prop);
}
// Build assignments to QML lists. QML lists are properties of type
-// QQmlListProperty<T>. List properties can accept a list of
+// QQmlListProperty<T>. List properties can accept a list of
// objects, or a single binding.
bool QQmlCompiler::buildListProperty(QQmlScript::Property *prop,
QQmlScript::Object *obj,
}
if (propNames.testAndSet(prop.name.hash())) {
- for (Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p;
+ for (Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p;
p2 = obj->dynamicProperties.next(p2)) {
if (p2->name == prop.name) {
COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line,
property = obj->getDefaultProperty();
} else {
property = obj->getProperty(p->name);
- if (!property->values.isEmpty())
+ if (!property->values.isEmpty())
COMPILE_EXCEPTION(property, tr("Property value set multiple times"));
}
}
QQmlPropertyData
-QQmlCompiler::genValueTypeData(QQmlScript::Property *valueTypeProp,
+QQmlCompiler::genValueTypeData(QQmlScript::Property *valueTypeProp,
QQmlScript::Property *prop)
{
QQmlValueType *vt = QQmlValueTypeFactory::valueType(prop->type);
if (componentStats)
componentStats->componentStat.ids = compileState->ids.count();
- for (Object *aliasObject = compileState->aliasingObjects.first(); aliasObject;
- aliasObject = compileState->aliasingObjects.next(aliasObject))
+ for (Object *aliasObject = compileState->aliasingObjects.first(); aliasObject;
+ aliasObject = compileState->aliasingObjects.next(aliasObject))
COMPILE_CHECK(buildDynamicMetaAliases(aliasObject));
const QQmlScript::Parser &parser = unit->parser();
QHashedStringRef propName = name.mid(0, name.length() - Changed_string.length());
d = property(object, propName, notInRevision);
- if (d)
+ if (d)
return cache->signal(d->notifyIndex);
}
}
// This code must match the semantics of QQmlPropertyPrivate::findSignalByName
-int QQmlCompiler::indexOfSignal(QQmlScript::Object *object, const QString &name,
+int QQmlCompiler::indexOfSignal(QQmlScript::Object *object, const QString &name,
bool *notInRevision)
{
QQmlPropertyData *d = signal(object, QStringRef(&name), notInRevision);
return d?d->coreIndex:-1;
}
-int QQmlCompiler::indexOfProperty(QQmlScript::Object *object, const QString &name,
+int QQmlCompiler::indexOfProperty(QQmlScript::Object *object, const QString &name,
bool *notInRevision)
{
return indexOfProperty(object, QStringRef(&name), notInRevision);
}
-int QQmlCompiler::indexOfProperty(QQmlScript::Object *object, const QHashedStringRef &name,
+int QQmlCompiler::indexOfProperty(QQmlScript::Object *object, const QHashedStringRef &name,
bool *notInRevision)
{
QQmlPropertyData *d = property(object, name, notInRevision);
int listMetaTypeId;
bool isRegisteredWithEngine;
- struct TypeReference
+ struct TypeReference
{
TypeReference()
: type(0), typePropertyCache(0), component(0)
};
namespace QQmlCompilerTypes {
- struct BindingContext
+ struct BindingContext
{
BindingContext()
: stack(0), owner(0), object(0) {}
int n;
};
- struct IdList : public QFieldList<QQmlScript::Object,
+ struct IdList : public QFieldList<QQmlScript::Object,
&QQmlScript::Object::nextIdObject>
{
QQmlScript::Object *value(const QString &id) const {
// more than one of these for each compile
struct ComponentCompileState : public QQmlPool::Class
{
- ComponentCompileState()
- : parserStatusCount(0), totalBindingsCount(0), pushedProperties(0), nested(false),
+ ComponentCompileState()
+ : parserStatusCount(0), totalBindingsCount(0), pushedProperties(0), nested(false),
root(0) {}
IdList ids;
bool buildObject(QQmlScript::Object *obj, const QQmlCompilerTypes::BindingContext &);
bool buildComponent(QQmlScript::Object *obj, const QQmlCompilerTypes::BindingContext &);
bool buildSubObject(QQmlScript::Object *obj, const QQmlCompilerTypes::BindingContext &);
- bool buildSignal(QQmlScript::Property *prop, QQmlScript::Object *obj,
+ bool buildSignal(QQmlScript::Property *prop, QQmlScript::Object *obj,
const QQmlCompilerTypes::BindingContext &);
- bool buildProperty(QQmlScript::Property *prop, QQmlScript::Object *obj,
+ bool buildProperty(QQmlScript::Property *prop, QQmlScript::Object *obj,
const QQmlCompilerTypes::BindingContext &);
bool buildPropertyInNamespace(QQmlImportNamespace *ns,
- QQmlScript::Property *prop,
- QQmlScript::Object *obj,
+ QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
const QQmlCompilerTypes::BindingContext &);
bool buildIdProperty(QQmlScript::Property *prop, QQmlScript::Object *obj);
- bool buildAttachedProperty(QQmlScript::Property *prop,
+ bool buildAttachedProperty(QQmlScript::Property *prop,
QQmlScript::Object *obj,
const QQmlCompilerTypes::BindingContext &ctxt);
bool buildGroupedProperty(QQmlScript::Property *prop,
QQmlScript::Object *obj,
const QQmlCompilerTypes::BindingContext &ctxt);
- bool buildValueTypeProperty(QObject *type,
- QQmlScript::Object *obj,
+ bool buildValueTypeProperty(QObject *type,
+ QQmlScript::Object *obj,
QQmlScript::Object *baseObj,
const QQmlCompilerTypes::BindingContext &ctxt);
bool buildListProperty(QQmlScript::Property *prop,
void genComponent(QQmlScript::Object *obj);
void genValueProperty(QQmlScript::Property *prop, QQmlScript::Object *obj);
void genListProperty(QQmlScript::Property *prop, QQmlScript::Object *obj);
- void genPropertyAssignment(QQmlScript::Property *prop,
+ void genPropertyAssignment(QQmlScript::Property *prop,
QQmlScript::Object *obj,
QQmlScript::Property *valueTypeProperty = 0);
void genLiteralAssignment(QQmlScript::Property *prop,
QQmlScript::Value *value);
- void genBindingAssignment(QQmlScript::Value *binding,
- QQmlScript::Property *prop,
+ void genBindingAssignment(QQmlScript::Value *binding,
+ QQmlScript::Property *prop,
QQmlScript::Object *obj,
QQmlScript::Property *valueTypeProperty = 0);
int genContextCache();
class Q_QML_PRIVATE_EXPORT QQmlComponentPrivate : public QObjectPrivate, public QQmlTypeData::TypeDataCallback
{
Q_DECLARE_PUBLIC(QQmlComponent)
-
+
public:
QQmlComponentPrivate()
: typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0), depthIncreased(false) {}
QQmlTypeData *typeData;
virtual void typeDataReady(QQmlTypeData *);
virtual void typeDataProgress(QQmlTypeData *, qreal);
-
+
void fromTypeData(QQmlTypeData *data);
QUrl url;
};
ConstructionState state;
- static void beginDeferred(QQmlEnginePrivate *enginePriv, QObject *object,
+ static void beginDeferred(QQmlEnginePrivate *enginePriv, QObject *object,
ConstructionState *state);
static void complete(QQmlEnginePrivate *enginePriv, ConstructionState *state);
}
/*!
-Returns the name of \a object in this context, or an empty string if \a object
+Returns the name of \a object in this context, or an empty string if \a object
is not named in the context. Objects are named by setContextProperty(), or by ids in
the case of QML created contexts.
QQmlContextData::QQmlContextData()
-: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false),
+: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false),
isPragmaLibraryContext(false), unresolvedNames(false), hasEmittedDestruction(false), isRootObjectInCreation(false),
publicContext(0), activeVMEData(0),
contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
}
QQmlContextData::QQmlContextData(QQmlContext *ctxt)
-: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false),
+: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false),
isPragmaLibraryContext(false), unresolvedNames(false), hasEmittedDestruction(false), isRootObjectInCreation(false),
publicContext(ctxt), activeVMEData(0),
contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
QUrl resolvedUrl(const QUrl &);
- // My containing QQmlContext. If isInternal is true this owns publicContext.
+ // My containing QQmlContext. If isInternal is true this owns publicContext.
// If internal is false publicContext owns this.
QQmlContext *asQQmlContext();
QQmlContextPrivate *asQQmlContextPrivate();
The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE.
*/
-QQmlCustomParserNode
+QQmlCustomParserNode
QQmlCustomParserNodePrivate::fromObject(QQmlScript::Object *root)
{
QQmlCustomParserNode rootNode;
return rootNode;
}
-QQmlCustomParserProperty
+QQmlCustomParserProperty
QQmlCustomParserNodePrivate::fromProperty(QQmlScript::Property *p)
{
QQmlCustomParserProperty prop;
QQmlScript::Location location() const;
bool isList() const;
- // Will be one of QQmlScript::Variant, QQmlCustomParserProperty or
+ // Will be one of QQmlScript::Variant, QQmlCustomParserProperty or
// QQmlCustomParserNode
QList<QVariant> assignedValues() const;
void layout(QQmlNotifierEndpoint*);
};
NotifyList *notifyList;
-
+
inline QQmlNotifierEndpoint *notify(int index);
void addNotify(int index, QQmlNotifierEndpoint *);
int endpointCount(int index);
void disconnectNotifiers();
// The context that created the C++ object
- QQmlContextData *context;
+ QQmlContextData *context;
// The outermost context in which this object lives
QQmlContextData *outerContext;
QQmlData**prevContextObject;
int bindingBitsSize;
- quint32 *bindingBits;
+ quint32 *bindingBits;
inline bool hasBindingBit(int) const;
void clearBindingBit(int);
#include <qlibrary.h>
#include <windows.h>
-#define CSIDL_APPDATA 0x001a // <username>\Application Data
+#define CSIDL_APPDATA 0x001a // <username>\Application Data
#endif
Q_DECLARE_METATYPE(QQmlProperty)
mutable QMutex mutex;
private:
- // Locker locks the QQmlEnginePrivate data structures for read and write, if necessary.
- // Currently, locking is only necessary if the threaded loader is running concurrently. If it is
+ // Locker locks the QQmlEnginePrivate data structures for read and write, if necessary.
+ // Currently, locking is only necessary if the threaded loader is running concurrently. If it is
// either idle, or is running with the main thread blocked, no locking is necessary. This way
// we only pay for locking when we have to.
- // Consequently, this class should only be used to protect simple accesses or modifications of the
+ // Consequently, this class should only be used to protect simple accesses or modifications of the
// QQmlEnginePrivate structures or operations that can be guaranteed not to start activity
// on the loader thread.
- // The Locker API is identical to QMutexLocker. Locker reuses the QQmlEnginePrivate::mutex
+ // The Locker API is identical to QMutexLocker. Locker reuses the QQmlEnginePrivate::mutex
// QMutex instance and multiple Lockers are recursive in the same thread.
- class Locker
+ class Locker
{
public:
inline Locker(const QQmlEngine *);
void QQmlEnginePrivate::Locker::unlock()
{
- if (m_locked) {
+ if (m_locked) {
m_ep->mutex.unlock();
m_locked = false;
}
This method should be used for *any* type that has resources that need to
be freed in the engine thread. This is generally types that use V8 handles.
As there is some small overhead in checking the current thread, it is best
-practice to check if any V8 handles actually need to be freed and delete
+practice to check if any V8 handles actually need to be freed and delete
the instance directly if not.
*/
template<typename T>
Q_ASSERT(value);
if (isEngineThread()) {
delete value;
- } else {
+ } else {
struct I : public Deletable {
I(T *value) : value(value) {}
~I() { delete value; }
The returned cache is not referenced, so if it is to be stored, call addref().
XXX thread There is a potential future race condition in this and all the cache()
-functions. As the QQmlPropertyCache is returned unreferenced, when called
-from the loader thread, it is possible that the cache will have been dereferenced
+functions. As the QQmlPropertyCache is returned unreferenced, when called
+from the loader thread, it is possible that the cache will have been dereferenced
and deleted before the loader thread has a chance to use or reference it. This
-can't currently happen as the cache holds a reference to the
+can't currently happen as the cache holds a reference to the
QQmlPropertyCache until the QQmlEngine is destroyed.
*/
QQmlPropertyCache *QQmlEnginePrivate::cache(QObject *obj)
return rv;
}
-QV8Engine *QQmlEnginePrivate::getV8Engine(QQmlEngine *e)
-{
+QV8Engine *QQmlEnginePrivate::getV8Engine(QQmlEngine *e)
+{
Q_ASSERT(e);
return e->d_func()->v8engine();
return e->d_func()->v4engine();
}
-QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlEngine *e)
-{
+QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlEngine *e)
+{
Q_ASSERT(e);
return e->d_func();
}
-const QQmlEnginePrivate *QQmlEnginePrivate::get(const QQmlEngine *e)
-{
+const QQmlEnginePrivate *QQmlEnginePrivate::get(const QQmlEngine *e)
+{
Q_ASSERT(e);
return e->d_func();
}
-QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContext *c)
-{
- return (c && c->engine()) ? QQmlEnginePrivate::get(c->engine()) : 0;
+QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContext *c)
+{
+ return (c && c->engine()) ? QQmlEnginePrivate::get(c->engine()) : 0;
}
-QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContextData *c)
-{
- return (c && c->engine) ? QQmlEnginePrivate::get(c->engine) : 0;
+QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContextData *c)
+{
+ return (c && c->engine) ? QQmlEnginePrivate::get(c->engine) : 0;
}
-QQmlEngine *QQmlEnginePrivate::get(QQmlEnginePrivate *p)
-{
+QQmlEngine *QQmlEnginePrivate::get(QQmlEnginePrivate *p)
+{
Q_ASSERT(p);
return p->q_func();
}
/*!
- \internal
+ \internal
*/
QQmlError::~QQmlError()
{
if(error.column() > 0) {
int column = qMax(0, error.column() - 1);
- column = qMin(column, line.length());
+ column = qMin(column, line.length());
QByteArray ind;
ind.reserve(column);
};
/*!
- Returns true if the case of \a fileName is equivalent to the file case of
+ Returns true if the case of \a fileName is equivalent to the file case of
\a fileName on disk, and false otherwise.
- This is used to ensure that the behavior of QML on a case-insensitive file
- system is the same as on a case-sensitive file system. This function
- performs a "best effort" attempt to determine the real case of the file.
+ This is used to ensure that the behavior of QML on a case-insensitive file
+ system is the same as on a case-sensitive file system. This function
+ performs a "best effort" attempt to determine the real case of the file.
It may have false positives (say the case is correct when it isn't), but it
- should never have a false negative (say the case is incorrect when it is
+ should never have a false negative (say the case is incorrect when it is
correct).
Length specifies specifies the number of characters to be checked from
QT_BEGIN_NAMESPACE
-class QQmlGuardImpl
+class QQmlGuardImpl
{
public:
inline QQmlGuardImpl();
inline T *object() const;
inline void setObject(T *g);
-
+
inline bool isNull() const
{ return !o; }
{
Q_ASSERT(!prev);
- if (QObjectPrivate::get(o)->wasDeleted)
+ if (QObjectPrivate::get(o)->wasDeleted)
return;
QQmlData *data = QQmlData::get(o, true);
}
template<class T>
-T *QQmlGuard<T>::object() const
-{
- return static_cast<T *>(o);
+T *QQmlGuard<T>::object() const
+{
+ return static_cast<T *>(o);
}
template<class T>
-void QQmlGuard<T>::setObject(T *g)
+void QQmlGuard<T>::setObject(T *g)
{
if (g != o) {
if (prev) remGuard();
\brief The QQmlImports class encapsulates one QML document's import statements.
\internal
*/
-QQmlImports::QQmlImports(const QQmlImports ©)
+QQmlImports::QQmlImports(const QQmlImports ©)
: d(copy.d)
{
++d->ref;
}
if (qmlImportTrace())
- qDebug() << "QQmlImportDatabase::resolvePlugin: Could not resolve plugin" << baseName
+ qDebug() << "QQmlImportDatabase::resolvePlugin: Could not resolve plugin" << baseName
<< "in" << qmldirPath;
return QString();
#include "qqmlmemoryprofiler_p.h"
#include "qqmlobjectcreator_p.h"
-// XXX TODO
-// - check that the Component.onCompleted behavior is the same as 4.8 in the synchronous and
+// XXX TODO
+// - check that the Component.onCompleted behavior is the same as 4.8 in the synchronous and
// async if nested cases
void QQmlEnginePrivate::incubate(QQmlIncubator &i, QQmlContextData *forContext)
{
}
/*!
-Sets the engine's incubation \a controller. The engine can only have one active controller
+Sets the engine's incubation \a controller. The engine can only have one active controller
and it does not take ownership of it.
\sa incubationController()
application's idle time. QQmlIncubationController allows the application to control
exactly when, how often and for how long this processing occurs.
-A QQmlIncubationController derived instance should be created and set on a
+A QQmlIncubationController derived instance should be created and set on a
QQmlEngine by calling the QQmlEngine::setIncubationController() method.
Processing is then controlled by calling the QQmlIncubationController::incubateFor()
or QQmlIncubationController::incubateWhile() methods as dictated by the application's
of 5 milliseconds out of every 16 milliseconds.
\code
-class PeriodicIncubationController : public QObject,
- public QQmlIncubationController
+class PeriodicIncubationController : public QObject,
+ public QQmlIncubationController
{
public:
- PeriodicIncubationController() {
- startTimer(16);
+ PeriodicIncubationController() {
+ startTimer(16);
}
protected:
Although the previous example would work, it is not optimal. Real world incubation
controllers should try and maximize the amount of idle time they consume - rather
-than a static amount like 5 milliseconds - while not disturbing the application.
+than a static amount like 5 milliseconds - while not disturbing the application.
*/
/*!
}
/*!
-Called when the number of incubating objects changes. \a incubatingObjectCount is the
+Called when the number of incubating objects changes. \a incubatingObjectCount is the
new number of incubating objects.
The default implementation does nothing.
return;
result = tresult;
- if (errors.isEmpty() && result == 0)
+ if (errors.isEmpty() && result == 0)
goto finishIncubate;
if (result) {
synchronously which, depending on the complexity of the object, can cause noticeable pauses or
stutters in the application.
-The use of QQmlIncubator gives more control over the creation of a QML object,
-including allowing it to be created asynchronously using application idle time. The following
+The use of QQmlIncubator gives more control over the creation of a QML object,
+including allowing it to be created asynchronously using application idle time. The following
example shows a simple use of QQmlIncubator.
\code
QObject *object = incubator.object();
\endcode
-Asynchronous incubators are controlled by a QQmlIncubationController that is
+Asynchronous incubators are controlled by a QQmlIncubationController that is
set on the QQmlEngine, which lets the engine know when the application is idle and
incubating objects should be processed. If an incubation controller is not set on the
QQmlEngine, QQmlIncubator creates objects synchronously regardless of the
-specified IncubationMode.
+specified IncubationMode.
QQmlIncubator supports three incubation modes:
\list
\li Synchronous The creation occurs synchronously. That is, once the
QQmlComponent::create() call returns, the incubator will already be in either the
Error or Ready state. A synchronous incubator has no real advantage compared to using
-the synchronous creation methods on QQmlComponent directly, but it may simplify an
-application's implementation to use the same API for both synchronous and asynchronous
+the synchronous creation methods on QQmlComponent directly, but it may simplify an
+application's implementation to use the same API for both synchronous and asynchronous
creations.
\li Asynchronous (default) The creation occurs asynchronously, assuming a
-QQmlIncubatorController is set on the QQmlEngine.
+QQmlIncubatorController is set on the QQmlEngine.
-The incubator will remain in the Loading state until either the creation is complete or an error
+The incubator will remain in the Loading state until either the creation is complete or an error
occurs. The statusChanged() callback can be used to be notified of status changes.
Applications should use the Asynchronous incubation mode to create objects that are not needed
to complete the creation process synchronously.
\li AsynchronousIfNested The creation will occur asynchronously if part of a nested asynchronous
-creation, or synchronously if not.
+creation, or synchronously if not.
In most scenarios where a QML component wants the appearance of a synchronous
-instantiation, it should use this mode.
+instantiation, it should use this mode.
This mode is best explained with an example. When the ListView type is first created, it needs
-to populate itself with an initial set of delegates to show. If the ListView was 400 pixels high,
+to populate itself with an initial set of delegates to show. If the ListView was 400 pixels high,
and each delegate was 100 pixels high, it would need to create four initial delegate instances. If
the ListView used the Asynchronous incubation mode, the ListView would always be created empty and
then, sometime later, the four initial items would appear.
-Conversely, if the ListView was to use the Synchronous incubation mode it would behave correctly
-but it may introduce stutters into the application. As QML would have to stop and instantiate the
-ListView's delegates synchronously, if the ListView was part of a QML component that was being
+Conversely, if the ListView was to use the Synchronous incubation mode it would behave correctly
+but it may introduce stutters into the application. As QML would have to stop and instantiate the
+ListView's delegates synchronously, if the ListView was part of a QML component that was being
instantiated asynchronously this would undo much of the benefit of asynchronous instantiation.
The AsynchronousIfNested mode reconciles this problem. By using AsynchronousIfNested, the ListView
delegates are instantiated asynchronously if the ListView itself is already part of an asynchronous
instantiation, and synchronously otherwise. In the case of a nested asynchronous instantiation, the
outer asynchronous instantiation will not complete until after all the nested instantiations have also
-completed. This ensures that by the time the outer asynchronous instantitation completes, inner
+completed. This ensures that by the time the outer asynchronous instantitation completes, inner
items like ListView have already completed loading their initial delegates.
It is almost always incorrect to use the Synchronous incubation mode - elements or components that
-want the appearance of synchronous instantiation, but without the downsides of introducing freezes
+want the appearance of synchronous instantiation, but without the downsides of introducing freezes
or stutters into the application, should use the AsynchronousIfNested incubation mode.
\endlist
*/
/*!
\enum QQmlIncubator::IncubationMode
-Specifies the mode the incubator operates in. Regardless of the incubation mode, a
+Specifies the mode the incubator operates in. Regardless of the incubation mode, a
QQmlIncubator will behave synchronously if the QQmlEngine does not have
a QQmlIncubationController set.
\value Asynchronous The object will be created asynchronously.
\value AsynchronousIfNested If the object is being created in a context that is already part
-of an asynchronous creation, this incubator will join that existing incubation and execute
-asynchronously. The existing incubation will not become Ready until both it and this
+of an asynchronous creation, this incubator will join that existing incubation and execute
+asynchronously. The existing incubation will not become Ready until both it and this
incubation have completed. Otherwise, the incubation will execute synchronously.
\value Synchronous The object will be created synchronously.
*/
*/
/*!
-Clears the incubator. Any in-progress incubation is aborted. If the incubator is in the
+Clears the incubator. Any in-progress incubation is aborted. If the incubator is in the
Ready state, the created object is \b not deleted.
*/
void QQmlIncubator::clear()
void QQmlIncubatorPrivate::changeStatus(QQmlIncubator::Status s)
{
- if (s == status)
+ if (s == status)
return;
status = s;
QQmlIncubator::Status QQmlIncubatorPrivate::calculateStatus() const
{
- if (!errors.isEmpty())
+ if (!errors.isEmpty())
return QQmlIncubator::Error;
else if (result && progress == QQmlIncubatorPrivate::Completed && waitingFor.isEmpty())
return QQmlIncubator::Ready;
else if (compiledData)
return QQmlIncubator::Loading;
- else
+ else
return QQmlIncubator::Null;
}
AsynchronousIfNested,
Synchronous
};
- enum Status {
- Null,
- Ready,
- Loading,
- Error
+ enum Status {
+ Null,
+ Ready,
+ Loading,
+ Error
};
QQmlIncubator(IncubationMode = Asynchronous);
When QML types display warning messages, it improves traceability
if they include the QML file and line number on which the
particular instance was instantiated.
-
+
To include the file and line number, an object must be passed. If
the file and line number is not available for that instance
(either it was not instantiated by the QML engine or location
information is disabled), "unknown location" will be used instead.
- For example,
+ For example,
\code
qmlInfo(object) << tr("component property is a write-once property");
F(Defer, defer) \
F(PopFetchedObject, common) \
F(FetchValueType, fetchValue) \
- F(PopValueType, fetchValue)
+ F(PopValueType, fetchValue)
#ifndef QT_NO_TRANSLATION
#define F_TRANSLATION(F, I, FMT) F(I, FMT)
class QQmlCompiledData;
union QQmlInstruction
{
- enum Type {
+ enum Type {
FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
};
struct instr_completeQml {
QML_INSTR_HEADER
ushort column;
- ushort line;
+ ushort line;
bool isRoot;
};
struct instr_create {
int type;
int data;
ushort column;
- ushort line;
+ ushort line;
bool isRoot:1;
bool parentToSuper:1;
};
int typeSize;
int type;
ushort column;
- ushort line;
+ ushort line;
bool parentToSuper;
};
struct instr_storeMeta {
struct instr_begin {
QML_INSTR_HEADER
int castValue;
- };
+ };
struct instr_storeFloat {
QML_INSTR_HEADER
int propertyIndex;
double numberValue;
bool isStringLiteral:1;
bool isNumberLiteral:1;
- };
+ };
struct instr_storeScript {
QML_INSTR_HEADER
int value;
struct instr_assignSignalObject {
QML_INSTR_HEADER
int signal;
- ushort line;
+ ushort line;
};
struct instr_createComponent {
QML_INSTR_HEADER
the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported.
Attempting to add objects of the incorrect type to a list property will fail.
-Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure
+Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure
that it does not request an out of range element using the count() method before calling at().
The \l {Qt Quick 1} version of this class is named QDeclarativeListReference.
/*!
Constructs a QQmlListReference for \a object's \a property. If \a property is not a list
-property, an invalid QQmlListReference is created. If \a object is destroyed after
+property, an invalid QQmlListReference is created. If \a object is destroyed after
the reference is constructed, it will automatically become invalid. That is, it is safe to hold
QQmlListReference instances even after \a object is deleted.
}
/*!
-Returns true if the list property can be queried for its element count, otherwise false.
+Returns true if the list property can be queried for its element count, otherwise false.
Returns false if the reference is invalid.
\sa count()
\class QQmlListProperty
\since 5.0
\inmodule QtQml
-\brief The QQmlListProperty class allows applications to expose list-like
+\brief The QQmlListProperty class allows applications to expose list-like
properties to QML.
QML has many list properties, where more than one object value can be assigned.
\code
FruitBasket {
- fruit: [
+ fruit: [
Apple {},
Orange{},
Banana{}
The QQmlListProperty encapsulates a group of function pointers that represet the
set of actions QML can perform on the list - adding items, retrieving items and
-clearing the list. In the future, additional operations may be supported. All
+clearing the list. In the future, additional operations may be supported. All
list properties must implement the append operation, but the rest are optional.
-To provide a list property, a C++ class must implement the operation callbacks,
+To provide a list property, a C++ class must implement the operation callbacks,
and then return an appropriate QQmlListProperty value from the property getter.
List properties should have no setter. In the example above, the Q_PROPERTY()
declarative will look like this:
Q_PROPERTY(QQmlListProperty<Fruit> fruit READ fruit);
\endcode
-QML list properties are typesafe - in this case \c {Fruit} is a QObject type that
+QML list properties are typesafe - in this case \c {Fruit} is a QObject type that
\c {Apple}, \c {Orange} and \c {Banana} all derive from.
The \l {Qt Quick 1} version of this class is named QDeclarativeListProperty.
*/
/*!
-\fn QQmlListProperty::QQmlListProperty()
+\fn QQmlListProperty::QQmlListProperty()
\internal
*/
QList \a list. The \a list reference must remain valid for as long as \a object
exists. \a object must be provided.
-Generally this constructor should not be used in production code, as a
+Generally this constructor should not be used in production code, as a
writable QList violates QML's memory management rules. However, this constructor
can very useful while prototyping.
*/
*/
/*!
-\fn QQmlListProperty::QQmlListProperty(QObject *object, void *data, AppendFunction append,
+\fn QQmlListProperty::QQmlListProperty(QObject *object, void *data, AppendFunction append,
CountFunction count, AtFunction at,
ClearFunction clear)
Construct a QQmlListProperty from a set of operation functions. An opaque \a data handle
-may be passed which can be accessed from within the operation functions. The list property
+may be passed which can be accessed from within the operation functions. The list property
remains valid while \a object exists.
Null pointers can be passed for any function. If any null pointers are passed in, the list
*/
/*!
-\fn bool QQmlListProperty::operator==(const QQmlListProperty &other) const
+\fn bool QQmlListProperty::operator==(const QQmlListProperty &other) const
Returns true if this QQmlListProperty is equal to \a other, otherwise false.
*/
class QQmlTypeModulePrivate
{
public:
- QQmlTypeModulePrivate()
+ QQmlTypeModulePrivate()
: minMinorVersion(INT_MAX), maxMinorVersion(0), locked(false) {}
static QQmlTypeModulePrivate* get(QQmlTypeModule* q) { return q->d; }
return d->superType;
}
-static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
+static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
{
// Set classname
int otherIndex = ignoreEnd->indexOfClassInfo(info.name());
if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) {
- // Skip
+ // Skip
} else {
builder.addClassInfo(info.name(), info.value());
}
int otherIndex = ignoreEnd->indexOfProperty(property.name());
if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) {
builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void"));
- // Skip
+ // Skip
} else {
builder.addProperty(property);
}
bool found = false;
- for (int ii = ignoreStart->methodOffset() + ignoreStart->methodCount();
+ for (int ii = ignoreStart->methodOffset() + ignoreStart->methodCount();
!found && ii < ignoreEnd->methodOffset() + ignoreEnd->methodCount();
++ii) {
int otherIndex = ignoreEnd->indexOfEnumerator(enumerator.name());
if (otherIndex >= ignoreStart->enumeratorOffset() + ignoreStart->enumeratorCount()) {
- // Skip
+ // Skip
} else {
builder.addEnumerator(enumerator);
}
/*
This is the id passed to qmlAttachedPropertiesById(). This is different from the index
-for the case that a single class is registered under two or more names (eg. Item in
+for the case that a single class is registered under two or more names (eg. Item in
Qt 4.7 and QtQuick 1.0).
*/
int QQmlType::attachedPropertiesId() const
int registerInterface(const QQmlPrivate::RegisterInterface &interface)
{
- if (interface.version > 0)
+ if (interface.version > 0)
qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
QWriteLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
// first, check Types
- QQmlTypeModule *tm =
+ QQmlTypeModule *tm =
data->uriToModule.value(QQmlMetaTypeData::VersionedUri(module, versionMajor));
if (tm && tm->minimumMinorVersion() <= versionMinor && tm->maximumMinorVersion() >= versionMinor)
return true;
}
/*!
- Returns the type (if any) that corresponds to the QVariant::Type \a userType.
+ Returns the type (if any) that corresponds to the QVariant::Type \a userType.
Returns null if no type is registered.
*/
QQmlType *QQmlMetaType::qmlType(int userType)
enum TypeCategory { Unknown, Object, List };
static TypeCategory typeCategory(int);
-
+
static bool isInterface(int);
static const char *interfaceIId(int);
static bool isList(int);
QQmlTypeModulePrivate *d;
};
-class QQmlTypeModuleVersion
+class QQmlTypeModuleVersion
{
public:
QQmlTypeModuleVersion();
// End of notifying, restore values
endpoint->senderPtr = originalSenderPtr;
}
- }
+ }
}
/*! \internal
}
QQmlNotifier::~QQmlNotifier()
-{
+{
QQmlNotifierEndpoint *endpoint = endpoints;
while (endpoint) {
QQmlNotifierEndpoint *n = endpoint;
/*!
Cancel any notifies that are in progress.
*/
-void QQmlNotifierEndpoint::cancelNotify()
+void QQmlNotifierEndpoint::cancelNotify()
{
if (isNotifying()) {
qintptr sp = *((qintptr *)(senderPtr & ~0x1));
QT_BEGIN_NAMESPACE
template<typename T>
-struct QQmlNullableValue
+struct QQmlNullableValue
{
QQmlNullableValue()
: isNull(true), value(T()) {}
propertyWritten(propId);
activate(d->object, d->type->d->signalOffset + propId, 0);
}
- }
+ }
return -1;
} else {
if (d->parent)
/*!
\fn void QQmlParserStatus::componentComplete()
- Invoked after the root component that caused this instantiation has
+ Invoked after the root component that caused this instantiation has
completed construction. At this point all static values and binding values
have been assigned to the class.
*/
class QQmlElement : public T
{
public:
- virtual ~QQmlElement() {
- QQmlPrivate::qdeclarativeelement_destructor(this);
+ virtual ~QQmlElement() {
+ QQmlPrivate::qdeclarativeelement_destructor(this);
}
};
};
template <typename T, bool hasMember>
- class has_attachedPropertiesMethod
+ class has_attachedPropertiesMethod
{
public:
typedef int yes_type;
static no_type check(...);
static bool const value = sizeof(check(&T::qmlAttachedProperties)) == sizeof(yes_type);
- };
+ };
template <typename T>
class has_attachedPropertiesMethod<T, false>
return rv;
}
-bool QQmlPropertyPrivate::write(QObject *object,
+bool QQmlPropertyPrivate::write(QObject *object,
const QQmlPropertyData &property,
const QVariant &value, QQmlContextData *context,
WriteFlags flags)
Normal
};
- enum Type {
+ enum Type {
Invalid,
Property,
SignalProperty
bool writeValueProperty(const QVariant &, WriteFlags);
static QQmlMetaObject rawMetaObjectForType(QQmlEnginePrivate *, int);
- static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
+ static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
const QVariant &value, int flags);
static bool writeValueProperty(QObject *,
const QQmlPropertyData &,
- const QVariant &, QQmlContextData *,
+ const QVariant &, QQmlContextData *,
WriteFlags flags = 0);
static bool write(QObject *, const QQmlPropertyData &, const QVariant &,
QQmlContextData *, WriteFlags flags = 0);
if (id >= data.propertyOffset) {
if (!proxies) {
proxies = new QObject*[metaObjects->count()];
- ::memset(proxies, 0,
+ ::memset(proxies, 0,
sizeof(QObject *) * metaObjects->count());
}
// ### - Can this be done more optimally?
for (int jj = 0; jj < methods; ++jj) {
- QMetaMethod method =
+ QMetaMethod method =
metaObject->method(jj + methodOffset);
if (method.methodType() == QMetaMethod::Signal)
QQmlPropertyPrivate::connect(proxy, methodOffset + jj, object, localOffset + jj);
using namespace QQmlJS;
using namespace QQmlScript;
-//
+//
// Parser IR classes
//
QQmlScript::Object::Object()
{
}
-QQmlScript::Object::~Object()
-{
+QQmlScript::Object::~Object()
+{
if (synthCache) synthCache->release();
}
}
QQmlScript::Property::Property()
-: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false),
+: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false),
isValueTypeSubProperty(false), isAlias(false), isReadOnlyDeclaration(false),
scriptStringScope(-1), nextMainProperty(0), nextProperty(0)
{
QString QQmlScript::Variant::asScript() const
{
- switch(type()) {
+ switch (type()) {
default:
case Invalid:
return QString();
case Number:
if (asWritten.isEmpty())
return QString::number(d);
- else
+ else
return asWritten.toString();
case String:
return escapedString(asString());
} else {
// Class
- QQmlScript::Object *obj = _parser->_pool.New<QQmlScript::Object>();
+ QQmlScript::Object *obj = _parser->_pool.New<QQmlScript::Object>();
obj->type = _parser->findOrCreateTypeId(objectType, obj);
obj->typeReference = _parser->_refTypes.at(obj->type);
bool typeFound = false;
Object::DynamicProperty::Type type;
- if ((unsigned)memberType.length() == strlen("alias") &&
+ if ((unsigned)memberType.length() == strlen("alias") &&
QHashedString::compare(memberType.constData(), "alias", int(strlen("alias")))) {
type = Object::DynamicProperty::Alias;
typeFound = true;
- }
+ }
for(int ii = 0; !typeFound && ii < propTypeNameToTypesCount; ++ii) {
const TypeNameToType *t = propTypeNameToTypes + ii;
if (typeModifier.isEmpty()) {
type = Object::DynamicProperty::Custom;
- } else if((unsigned)typeModifier.length() == strlen("list") &&
+ } else if ((unsigned)typeModifier.length() == strlen("list") &&
QHashedString::compare(typeModifier.constData(), "list", int(strlen("list")))) {
type = Object::DynamicProperty::CustomList;
} else {
return _errors;
}
-static void replaceWithSpace(QString &str, int idx, int n)
+static void replaceWithSpace(QString &str, int idx, int n)
{
QChar *data = str.data() + idx;
const QChar space(QLatin1Char(' '));
#define CHECK_TOKEN(t) if (token != QQmlJSGrammar:: t) return rv;
static const int uriTokens[] = {
- QQmlJSGrammar::T_IDENTIFIER,
- QQmlJSGrammar::T_PROPERTY,
- QQmlJSGrammar::T_SIGNAL,
- QQmlJSGrammar::T_READONLY,
- QQmlJSGrammar::T_ON,
- QQmlJSGrammar::T_BREAK,
- QQmlJSGrammar::T_CASE,
- QQmlJSGrammar::T_CATCH,
- QQmlJSGrammar::T_CONTINUE,
- QQmlJSGrammar::T_DEFAULT,
- QQmlJSGrammar::T_DELETE,
- QQmlJSGrammar::T_DO,
- QQmlJSGrammar::T_ELSE,
- QQmlJSGrammar::T_FALSE,
- QQmlJSGrammar::T_FINALLY,
- QQmlJSGrammar::T_FOR,
- QQmlJSGrammar::T_FUNCTION,
- QQmlJSGrammar::T_IF,
- QQmlJSGrammar::T_IN,
- QQmlJSGrammar::T_INSTANCEOF,
- QQmlJSGrammar::T_NEW,
- QQmlJSGrammar::T_NULL,
- QQmlJSGrammar::T_RETURN,
- QQmlJSGrammar::T_SWITCH,
- QQmlJSGrammar::T_THIS,
- QQmlJSGrammar::T_THROW,
- QQmlJSGrammar::T_TRUE,
- QQmlJSGrammar::T_TRY,
- QQmlJSGrammar::T_TYPEOF,
- QQmlJSGrammar::T_VAR,
- QQmlJSGrammar::T_VOID,
- QQmlJSGrammar::T_WHILE,
- QQmlJSGrammar::T_CONST,
- QQmlJSGrammar::T_DEBUGGER,
- QQmlJSGrammar::T_RESERVED_WORD,
- QQmlJSGrammar::T_WITH,
+ QQmlJSGrammar::T_IDENTIFIER,
+ QQmlJSGrammar::T_PROPERTY,
+ QQmlJSGrammar::T_SIGNAL,
+ QQmlJSGrammar::T_READONLY,
+ QQmlJSGrammar::T_ON,
+ QQmlJSGrammar::T_BREAK,
+ QQmlJSGrammar::T_CASE,
+ QQmlJSGrammar::T_CATCH,
+ QQmlJSGrammar::T_CONTINUE,
+ QQmlJSGrammar::T_DEFAULT,
+ QQmlJSGrammar::T_DELETE,
+ QQmlJSGrammar::T_DO,
+ QQmlJSGrammar::T_ELSE,
+ QQmlJSGrammar::T_FALSE,
+ QQmlJSGrammar::T_FINALLY,
+ QQmlJSGrammar::T_FOR,
+ QQmlJSGrammar::T_FUNCTION,
+ QQmlJSGrammar::T_IF,
+ QQmlJSGrammar::T_IN,
+ QQmlJSGrammar::T_INSTANCEOF,
+ QQmlJSGrammar::T_NEW,
+ QQmlJSGrammar::T_NULL,
+ QQmlJSGrammar::T_RETURN,
+ QQmlJSGrammar::T_SWITCH,
+ QQmlJSGrammar::T_THIS,
+ QQmlJSGrammar::T_THROW,
+ QQmlJSGrammar::T_TRUE,
+ QQmlJSGrammar::T_TRY,
+ QQmlJSGrammar::T_TYPEOF,
+ QQmlJSGrammar::T_VAR,
+ QQmlJSGrammar::T_VOID,
+ QQmlJSGrammar::T_WHILE,
+ QQmlJSGrammar::T_CONST,
+ QQmlJSGrammar::T_DEBUGGER,
+ QQmlJSGrammar::T_RESERVED_WORD,
+ QQmlJSGrammar::T_WITH,
QQmlJSGrammar::EOF_SYMBOL
};
namespace QQmlScript {
-struct Location
+struct Location
{
Location() : line(0), column(0) {}
quint16 line;
quint16 column;
inline bool operator<(const Location &other) {
- return line < other.line ||
+ return line < other.line ||
(line == other.line && column < other.column);
}
};
void addValue(Value *v);
void addOnValue(Value *v);
- // The QVariant::Type of the property, or 0 (QVariant::Invalid) if
+ // The QVariant::Type of the property, or 0 (QVariant::Invalid) if
// unknown.
int type;
// The metaobject index of this property, or -1 if unknown.
int index;
- // The core data in the case of a regular property.
+ // The core data in the case of a regular property.
// XXX This has to be a value now as the synthCache may change during
// compilation which invalidates pointers. We should fix this.
QQmlPropertyData core;
const QHashedStringRef &name() const { return _name; }
void setName(const QString &n) { _name = QHashedStringRef(pool()->NewString(n)); }
void setName(const QHashedStringRef &n) { _name = n; }
- // True if this property was accessed as the default property.
+ // True if this property was accessed as the default property.
bool isDefault;
// True if the setting of this property will be deferred. Set by the
// QQmlCompiler
bool isDeferred;
// True if this property is a value-type pseudo-property
bool isValueTypeSubProperty;
- // True if this property is a property alias. Set by the
+ // True if this property is a property alias. Set by the
// QQmlCompiler
bool isAlias;
// True if this is a readonly property declaration
{
public:
Object();
- virtual ~Object();
+ virtual ~Object();
- // Type of the object. The integer is an index into the
+ // Type of the object. The integer is an index into the
// QQmlCompiledData::types array, or -1 if the object is a property
// group.
int type;
// Custom parsed data
QByteArray custom;
// Bit mask of the properties assigned bindings
- QByteArray bindingBitmask;
+ QByteArray bindingBitmask;
void setBindingBit(int);
QQmlPropertyCache *metatype;
// Script blocks that were nested under this object
struct ScriptBlock {
- enum Pragma {
+ enum Pragma {
None = 0x00000000,
Shared = 0x00000001
};
Pragmas pragmas;
};
- // The bytes to cast instances by to get to the QQmlParserStatus
+ // The bytes to cast instances by to get to the QQmlParserStatus
// interface. -1 indicates the type doesn't support this interface.
// Set by the QQmlCompiler.
int parserStatusCast;
LocationSpan location;
- struct DynamicProperty : public QQmlPool::POD
+ struct DynamicProperty : public QQmlPool::POD
{
DynamicProperty();
class JavaScriptMetaData {
public:
- JavaScriptMetaData()
+ JavaScriptMetaData()
: pragmas(QQmlScript::Object::ScriptBlock::None) {}
QQmlScript::Object::ScriptBlock::Pragmas pragmas;
class QQmlContext;
class QQmlScriptStringPrivate;
class QmlObjectCreator;
-class Q_QML_EXPORT QQmlScriptString
+class Q_QML_EXPORT QQmlScriptString
{
public:
QQmlScriptString();
#else
-#define ASSERT_MAINTHREAD()
+#define ASSERT_MAINTHREAD()
#define ASSERT_LOADTHREAD()
#define ASSERT_CALLBACK()
}
// This is a lame object that we need to ensure that slots connected to
-// QNetworkReply get called in the correct thread (the loader thread).
+// QNetworkReply get called in the correct thread (the loader thread).
// As QQmlDataLoader lives in the main thread, and we can't use
-// Qt::DirectConnection connections from a QNetworkReply (because then
+// Qt::DirectConnection connections from a QNetworkReply (because then
// sender() wont work), we need to insert this object in the middle.
class QQmlDataLoaderNetworkReplyProxy : public QObject
{
};
-QQmlDataLoaderNetworkReplyProxy::QQmlDataLoaderNetworkReplyProxy(QQmlDataLoader *l)
-: l(l)
+QQmlDataLoaderNetworkReplyProxy::QQmlDataLoaderNetworkReplyProxy(QQmlDataLoader *l)
+: l(l)
{
}
Create a new QQmlDataBlob for \a url and of the provided \a type.
*/
QQmlDataBlob::QQmlDataBlob(const QUrl &url, Type type)
-: m_type(type), m_url(url), m_finalUrl(url), m_manager(0), m_redirectCount(0),
+: m_type(type), m_url(url), m_finalUrl(url), m_manager(0), m_redirectCount(0),
m_inCallback(false), m_isDone(false)
{
}
/*!
Mark this blob as having \a errors.
-All outstanding dependencies will be cancelled. Requests to add new dependencies
+All outstanding dependencies will be cancelled. Requests to add new dependencies
will be ignored. Entry into the Error state is irreversable.
The setError() method may only be called from within a QQmlDataBlob callback.
tryDone();
}
-/*!
-Wait for \a blob to become complete or to error. If \a blob is already
+/*!
+Wait for \a blob to become complete or to error. If \a blob is already
complete or in error, or this blob is already complete, this has no effect.
The setError() method may only be called from within a QQmlDataBlob callback.
if (!blob ||
blob->status() == Error || blob->status() == Complete ||
- status() == Error || status() == Complete || m_isDone ||
+ status() == Error || status() == Complete || m_isDone ||
m_waitingFor.contains(blob))
return;
*/
/*!
-Invoked once data has either been received or a network error occurred, and all
+Invoked once data has either been received or a network error occurred, and all
dependencies are complete.
You can set an error in this method, but you cannot add new dependencies. Implementors
setError(error);
}
-/*!
+/*!
Called if \a blob, which was previously waited for, has an error.
The default implementation does nothing.
Q_UNUSED(blob);
}
-/*!
-Called when all blobs waited for have completed. This occurs regardless of
-whether they are in error, or complete state.
+/*!
+Called when all blobs waited for have completed. This occurs regardless of
+whether they are in error, or complete state.
The default implementation does nothing.
*/
Called when the download progress of this blob changes. \a progress goes
from 0 to 1.
-This callback is only invoked if an asynchronous load for this blob is
+This callback is only invoked if an asynchronous load for this blob is
made. An asynchronous load is one in which the Asynchronous mode is
-specified explicitly, or one that is implicitly delayed due to a network
+specified explicitly, or one that is implicitly delayed due to a network
operation.
The default implementation does nothing.
Invoked on the main thread sometime after done() was called on the load thread.
You cannot modify the blobs state at all in this callback and cannot depend on the
-order or timeliness of these callbacks. Implementors should use this callback to notify
+order or timeliness of these callbacks. Implementors should use this callback to notify
dependencies on the main thread that the blob is done and not a lot else.
-This callback is only invoked if an asynchronous load for this blob is
+This callback is only invoked if an asynchronous load for this blob is
made. An asynchronous load is one in which the Asynchronous mode is
-specified explicitly, or one that is implicitly delayed due to a network
+specified explicitly, or one that is implicitly delayed due to a network
operation.
The default implementation does nothing.
blob->release();
- if (!isError() && m_waitingFor.isEmpty())
+ if (!isError() && m_waitingFor.isEmpty())
allDependenciesDone();
m_inCallback = false;
return m_networkReplyProxy;
}
-void QQmlDataLoaderThread::load(QQmlDataBlob *b)
-{
+void QQmlDataLoaderThread::load(QQmlDataBlob *b)
+{
b->addref();
- callMethodInThread(&This::loadThread, b);
+ callMethodInThread(&This::loadThread, b);
}
void QQmlDataLoaderThread::loadAsync(QQmlDataBlob *b)
postMethodToThread(&This::loadWithStaticDataThread, b, d);
}
-void QQmlDataLoaderThread::callCompleted(QQmlDataBlob *b)
-{
- b->addref();
- postMethodToMain(&This::callCompletedMain, b);
+void QQmlDataLoaderThread::callCompleted(QQmlDataBlob *b)
+{
+ b->addref();
+ postMethodToMain(&This::callCompletedMain, b);
}
-void QQmlDataLoaderThread::callDownloadProgressChanged(QQmlDataBlob *b, qreal p)
-{
- b->addref();
- postMethodToMain(&This::callDownloadProgressChangedMain, b, p);
+void QQmlDataLoaderThread::callDownloadProgressChanged(QQmlDataBlob *b, qreal p)
+{
+ b->addref();
+ postMethodToMain(&This::callDownloadProgressChangedMain, b, p);
}
-void QQmlDataLoaderThread::initializeEngine(QQmlExtensionInterface *iface,
+void QQmlDataLoaderThread::initializeEngine(QQmlExtensionInterface *iface,
const char *uri)
{
callMethodInMain(&This::initializeEngineMain, iface, uri);
m_networkReplyProxy = 0;
}
-void QQmlDataLoaderThread::loadThread(QQmlDataBlob *b)
-{
- m_loader->loadThread(b);
+void QQmlDataLoaderThread::loadThread(QQmlDataBlob *b)
+{
+ m_loader->loadThread(b);
b->release();
}
b->release();
}
-void QQmlDataLoaderThread::callCompletedMain(QQmlDataBlob *b)
-{
+void QQmlDataLoaderThread::callCompletedMain(QQmlDataBlob *b)
+{
QML_MEMORY_SCOPE_URL(b->url());
#ifdef DATABLOB_DEBUG
- qWarning("QQmlDataLoaderThread: %s completed() callback", qPrintable(b->url().toString()));
+ qWarning("QQmlDataLoaderThread: %s completed() callback", qPrintable(b->url().toString()));
#endif
- b->completed();
- b->release();
+ b->completed();
+ b->release();
}
-void QQmlDataLoaderThread::callDownloadProgressChangedMain(QQmlDataBlob *b, qreal p)
-{
+void QQmlDataLoaderThread::callDownloadProgressChangedMain(QQmlDataBlob *b, qreal p)
+{
#ifdef DATABLOB_DEBUG
- qWarning("QQmlDataLoaderThread: %s downloadProgressChanged(%f) callback",
- qPrintable(b->url().toString()), p);
+ qWarning("QQmlDataLoaderThread: %s downloadProgressChanged(%f) callback",
+ qPrintable(b->url().toString()), p);
#endif
- b->downloadProgressChanged(p);
- b->release();
+ b->downloadProgressChanged(p);
+ b->release();
}
-void QQmlDataLoaderThread::initializeEngineMain(QQmlExtensionInterface *iface,
+void QQmlDataLoaderThread::initializeEngineMain(QQmlExtensionInterface *iface,
const char *uri)
{
Q_ASSERT(m_loader->engine()->thread() == QThread::currentThread());
QQmlDataBlob is an abstract class, so should always be specialized.
Once data is received, the QQmlDataBlob::dataReceived() method is invoked on the blob. The
-derived class should use this callback to process the received data. Processing of the data can
+derived class should use this callback to process the received data. Processing of the data can
result in an error being set (QQmlDataBlob::setError()), or one or more dependencies being
created (QQmlDataBlob::addDependency()). Dependencies are other QQmlDataBlob's that
are required before processing can fully complete.
/*! \internal */
QQmlDataLoader::~QQmlDataLoader()
{
- for (NetworkReplies::Iterator iter = m_networkReplies.begin(); iter != m_networkReplies.end(); ++iter)
+ for (NetworkReplies::Iterator iter = m_networkReplies.begin(); iter != m_networkReplies.end(); ++iter)
(*iter)->release();
shutdownThread();
void QQmlDataLoader::load(QQmlDataBlob *blob, Mode mode)
{
#ifdef DATABLOB_DEBUG
- qWarning("QQmlDataLoader::load(%s): %s thread", qPrintable(blob->m_url.toString()),
+ qWarning("QQmlDataLoader::load(%s): %s thread", qPrintable(blob->m_url.toString()),
m_thread->isThisThread()?"Compile":"Engine");
#endif
blob->startLoading(this);
void QQmlDataLoader::loadWithStaticData(QQmlDataBlob *blob, const QByteArray &data, Mode mode)
{
#ifdef DATABLOB_DEBUG
- qWarning("QQmlDataLoader::loadWithStaticData(%s, data): %s thread", qPrintable(blob->m_url.toString()),
+ qWarning("QQmlDataLoader::loadWithStaticData(%s, data): %s thread", qPrintable(blob->m_url.toString()),
m_thread->isThisThread()?"Compile":"Engine");
#endif
Call the initializeEngine() method on \a iface. Used by QQmlImportDatabase to ensure it
gets called in the correct thread.
*/
-void QQmlDataLoader::initializeEngine(QQmlExtensionInterface *iface,
+void QQmlDataLoader::initializeEngine(QQmlExtensionInterface *iface,
const char *uri)
{
Q_ASSERT(m_thread->isThisThread() || engine()->thread() == QThread::currentThread());
if (!blob->isError() && !blob->isWaiting())
blob->allDependenciesDone();
- if (blob->status() != QQmlDataBlob::Error)
+ if (blob->status() != QQmlDataBlob::Error)
blob->m_data.setStatus(QQmlDataBlob::WaitingForDependencies);
blob->m_inCallback = false;
*/
QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode)
{
- Q_ASSERT(!url.isRelative() &&
+ Q_ASSERT(!url.isRelative() &&
(QQmlFile::urlToLocalFileOrQrc(url).isEmpty() ||
!QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url))));
LockHolder<QQmlTypeLoader> holder(this);
-
+
QQmlTypeData *typeData = m_typeCache.value(url);
if (!typeData) {
}
/*!
-Returns a QQmlTypeData for the given \a data with the provided base \a url. The
+Returns a QQmlTypeData for the given \a data with the provided base \a url. The
QQmlTypeData will not be cached.
*/
QQmlTypeData *QQmlTypeLoader::getType(const QByteArray &data, const QUrl &url)
*/
QQmlScriptBlob *QQmlTypeLoader::getScript(const QUrl &url)
{
- Q_ASSERT(!url.isRelative() &&
+ Q_ASSERT(!url.isRelative() &&
(QQmlFile::urlToLocalFileOrQrc(url).isEmpty() ||
!QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url))));
*/
QQmlQmldirData *QQmlTypeLoader::getQmldir(const QUrl &url)
{
- Q_ASSERT(!url.isRelative() &&
+ Q_ASSERT(!url.isRelative() &&
(QQmlFile::urlToLocalFileOrQrc(url).isEmpty() ||
!QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url))));
{
for (TypeCache::Iterator iter = m_typeCache.begin(); iter != m_typeCache.end(); ++iter)
(*iter)->release();
- for (ScriptCache::Iterator iter = m_scriptCache.begin(); iter != m_scriptCache.end(); ++iter)
+ for (ScriptCache::Iterator iter = m_scriptCache.begin(); iter != m_scriptCache.end(); ++iter)
(*iter)->release();
for (QmldirCache::Iterator iter = m_qmldirCache.begin(); iter != m_qmldirCache.end(); ++iter)
(*iter)->release();
QQmlTypeData::~QQmlTypeData()
{
- for (int ii = 0; ii < m_scripts.count(); ++ii)
+ for (int ii = 0; ii < m_scripts.count(); ++ii)
m_scripts.at(ii).script->release();
- for (int ii = 0; ii < m_types.count(); ++ii)
+ for (int ii = 0; ii < m_types.count(); ++ii)
if (m_types.at(ii).typeData) m_types.at(ii).typeData->release();
if (m_compiledData)
m_compiledData->release();
}
// Compile component
- if (!isError())
+ if (!isError())
compile();
scriptParser.clear();
// m_errors should *always* be written before the status is set to Error.
// We use the status change as a memory fence around m_errors so that locking
- // isn't required. Once the status is set to Error (or Complete), m_errors
+ // isn't required. Once the status is set to Error (or Complete), m_errors
// cannot be changed.
QList<QQmlError> m_errors;
void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &);
void networkReplyFinished(QNetworkReply *);
void networkReplyProgress(QNetworkReply *, qint64, qint64);
-
+
typedef QHash<QNetworkReply *, QQmlDataBlob *> NetworkReplies;
void setData(QQmlDataBlob *, const QByteArray &);
bool loadImplicitImport();
};
-// QQmlScriptData instances are created, uninitialized, by the loader in the
+// QQmlScriptData instances are created, uninitialized, by the loader in the
// load thread. The first time they are used by the VME, they are initialized which
// creates their v8 objects and they are referenced and added to the engine's cleanup
-// list. During QQmlCleanup::clear() all v8 resources are destroyed, and the
+// list. During QQmlCleanup::clear() all v8 resources are destroyed, and the
// reference that was created is released but final deletion only occurs once all the
// references as released. This is all intended to ensure that the v8 resources are
// only created and destroyed in the main thread :)
return result;
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
const void *importNamespace)
{
Q_ASSERT(importNamespace);
if (type && !type->isSingleton() && w->object) {
QObject *object = w->object;
QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
- if (ao)
+ if (ao)
QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, ao, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value);
} else if (type && type->isSingleton()) {
QQmlEngine *e = v8engine->engine();
qreal y() const;
void setX(qreal);
void setY(qreal);
-
+
qreal width() const;
qreal height() const;
void setWidth(qreal);
int y() const;
void setX(int);
void setY(int);
-
+
int width() const;
int height() const;
void setWidth(int);
}
namespace {
-struct ActiveVMERestorer
+struct ActiveVMERestorer
{
- ActiveVMERestorer(QQmlVME *me, QQmlEnginePrivate *ep)
+ ActiveVMERestorer(QQmlVME *me, QQmlEnginePrivate *ep)
: ep(ep), oldVME(ep->activeVME) { ep->activeVME = me; }
~ActiveVMERestorer() { ep->activeVME = oldVME; }
return rv;
}
-inline bool fastHasBinding(QObject *o, int index)
+inline bool fastHasBinding(QObject *o, int index)
{
if (QQmlData *ddata = static_cast<QQmlData *>(QObjectPrivate::get(o)->declarativeData)) {
int coreIndex = index & 0x0000FFFF;
return wrapper->context();
}
-// XXX we probably need some form of "work count" here to prevent us checking this
+// XXX we probably need some form of "work count" here to prevent us checking this
// for every instruction.
#define QML_BEGIN_INSTR_COMMON(I) { \
const QQmlInstructionMeta<(int)QQmlInstruction::I>::DataType &instr = QQmlInstructionMeta<(int)QQmlInstruction::I>::data(*genericInstr); \
CTXT->imports = COMP->importCache;
CTXT->imports->addref();
CTXT->setParent(parentCtxt);
- if (instr.contextCache != -1)
+ if (instr.contextCache != -1)
CTXT->setIdPropertyData(COMP->contextCaches.at(instr.contextCache));
if (states.count() == 1) {
rootContext = CTXT;
rootContext->isRootObjectInCreation = true;
}
if (states.count() == 1 && !creationContext.isNull()) {
- // A component that is logically created within another component instance shares the
+ // A component that is logically created within another component instance shares the
// same instances of script imports. For example:
//
// import QtQuick 2.0
// }
//
// Has the same "Test" instance. To implement this, we simply copy the v8 handles into
- // the inner context. We have to create a fresh persistent handle for each to prevent
+ // the inner context. We have to create a fresh persistent handle for each to prevent
// double dispose. It is possible we could do this more efficiently using some form of
// referencing instead.
CTXT->importedScripts = creationContext->importedScripts;
if (!objects.isEmpty()) {
QObject *parent = objects.at(objects.count() - 1 - (instr.parentToSuper?1:0));
#if 0 // ### refactor
- if (o->isWidgetType() && parent->isWidgetType())
+ if (o->isWidgetType() && parent->isWidgetType())
static_cast<QWidget*>(o)->setParent(static_cast<QWidget*>(parent));
- else
+ else
#endif
QQml_setParent_noEvent(o, parent);
ddata->parentFrozen = true;
QML_BEGIN_INSTR(CreateSimpleObject)
const QQmlCompiledData::TypeReference &ref = TYPES.at(instr.type);
Q_QML_VME_PROFILE(profiler.start(ref.type->qmlTypeName(), CTXT->url, instr.line, instr.column));
- QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QQmlData));
+ QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QQmlData));
::memset(static_cast<void *>(o), 0, instr.typeSize + sizeof(QQmlData));
instr.create(o);
ddata->lineNumber = instr.line;
ddata->columnNumber = instr.column;
- QObjectPrivate::get(o)->declarativeData = ddata;
+ QObjectPrivate::get(o)->declarativeData = ddata;
ddata->context = ddata->outerContext = CTXT;
- ddata->nextContextObject = CTXT->contextObjects;
- if (ddata->nextContextObject)
- ddata->nextContextObject->prevContextObject = &ddata->nextContextObject;
- ddata->prevContextObject = &CTXT->contextObjects;
- CTXT->contextObjects = ddata;
+ ddata->nextContextObject = CTXT->contextObjects;
+ if (ddata->nextContextObject)
+ ddata->nextContextObject->prevContextObject = &ddata->nextContextObject;
+ ddata->prevContextObject = &CTXT->contextObjects;
+ CTXT->contextObjects = ddata;
QObject *parent = objects.at(objects.count() - 1 - (instr.parentToSuper?1:0));
- QQml_setParent_noEvent(o, parent);
+ QQml_setParent_noEvent(o, parent);
ddata->parentFrozen = true;
objects.push(o);
QML_END_INSTR(SetDefault)
QML_BEGIN_INSTR(CreateComponent)
- QQmlComponent *qcomp =
+ QQmlComponent *qcomp =
new QQmlComponent(CTXT->engine, COMP, INSTRUCTIONSTREAM - COMP->bytecode.constData(),
objects.isEmpty() ? 0 : objects.top());
QQmlPropertyCache *propertyCache = PROPERTYCACHES.at(instr.propertyCache);
- const QQmlVMEMetaData *data =
+ const QQmlVMEMetaData *data =
(const QQmlVMEMetaData *)DATAS.at(instr.aliasData).constData();
QV4::ExecutionContext *qmlContext = qmlBindingContext(engine, QV8Engine::getV4(engine), qmlBindingWrappers, CTXT, target, objects.count() - 1);
QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(type);
QVariant v = (*converter)(primitive);
- QMetaProperty prop =
+ QMetaProperty prop =
target->metaObject()->property(instr.propertyIndex);
- if (v.isNull() || ((int)prop.type() != type && prop.userType() != type))
+ if (v.isNull() || ((int)prop.type() != type && prop.userType() != type))
VME_EXCEPTION(tr("Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name())), instr.line);
void *a[] = { (void *)v.data(), 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
instr.propertyIndex, a);
QML_END_INSTR(AssignCustomType)
ss.d.data()->numberValue = instr.numberValue;
void *a[] = { &ss, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
instr.propertyIndex, a);
QML_END_INSTR(StoreScriptString)
QML_END_INSTR(BeginObject)
QML_BEGIN_INSTR(StoreBinding)
- QObject *target =
+ QObject *target =
objects.at(objects.count() - 1 - instr.owner);
- QObject *context =
+ QObject *context =
objects.at(objects.count() - 1 - instr.context);
if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
QObject *obj = objects.pop();
QQmlPropertyValueInterceptor *vi = reinterpret_cast<QQmlPropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.castValue);
QObject *target = obj->parent();
- QQmlProperty prop =
+ QQmlProperty prop =
QQmlPropertyPrivate::restore(target, instr.property, CTXT);
vi->setTarget(prop);
QQmlVMEMetaObject *mo = QQmlVMEMetaObject::get(target);
void *ptr = 0;
const char *iid = QQmlMetaType::interfaceIId(type);
- if (iid)
+ if (iid)
ptr = assign->qt_metacast(iid);
- if (!ptr)
+ if (!ptr)
VME_EXCEPTION(tr("Cannot assign object to list"), instr.line);
if (list.qListProperty.append)
void *ptr = assign->qt_metacast(iid);
if (ptr) {
void *a[] = { &ptr, 0, &status, &flags };
- QMetaObject::metacall(target,
+ QMetaObject::metacall(target,
QMetaObject::WriteProperty,
coreIdx, a);
ok = true;
}
- }
+ }
- if (!ok)
+ if (!ok)
VME_EXCEPTION(tr("Cannot assign object to interface property"), instr.line);
QML_END_INSTR(StoreInterface)
-
+
QML_BEGIN_INSTR(FetchAttached)
QObject *target = objects.top();
void *a[1];
a[0] = (void *)&(lists.top().qListProperty);
- QMetaObject::metacall(target, QMetaObject::ReadProperty,
+ QMetaObject::metacall(target, QMetaObject::ReadProperty,
instr.property, a);
QML_END_INSTR(FetchQList)
QObject *target = objects.top();
QObject *obj = 0;
- // NOTE: This assumes a cast to QObject does not alter the
+ // NOTE: This assumes a cast to QObject does not alter the
// object pointer
void *a[1];
a[0] = &obj;
- QMetaObject::metacall(target, QMetaObject::ReadProperty,
+ QMetaObject::metacall(target, QMetaObject::ReadProperty,
instr.property, a);
if (!obj)
// Possibly need to clear bindings
QQmlData *targetData = QQmlData::get(target);
if (targetData) {
- QQmlAbstractBinding *binding =
+ QQmlAbstractBinding *binding =
QQmlPropertyPrivate::binding(target, instr.property, -1);
if (binding && binding->bindingType() != QQmlAbstractBinding::ValueTypeProxy) {
QQmlPropertyPrivate::setBinding(target, instr.property, -1, 0);
binding->destroy();
} else if (binding) {
- QQmlValueTypeProxyBinding *proxy =
+ QQmlValueTypeProxyBinding *proxy =
static_cast<QQmlValueTypeProxyBinding *>(binding);
proxy->removeBindings(instr.bindingSkipList);
}
QML_END_INSTR(FetchValueType)
QML_BEGIN_INSTR(PopValueType)
- QQmlValueType *valueHandler =
+ QQmlValueType *valueHandler =
static_cast<QQmlValueType *>(objects.pop());
QObject *target = objects.top();
valueHandler->write(target, instr.property, QQmlPropertyPrivate::BypassInterceptor);
QRecursionWatcher<QQmlVME, &QQmlVME::recursion> watcher(this);
if (!objects.isEmpty() && !(states.at(0).flags & State::Deferred))
- delete objects.at(0);
-
- if (!rootContext.isNull())
+ delete objects.at(0);
+
+ if (!rootContext.isNull())
rootContext->activeVMEData = 0;
// Remove the QQmlParserStatus and QQmlAbstractBinding back pointers
QQmlComponentAttached *a = componentAttached;
a->rem();
}
-
+
engine = 0;
objects.deallocate();
lists.deallocate();
void QQmlVMEGuard::guard(QQmlVME *vme)
{
clear();
-
+
m_objectCount = vme->objects.count();
m_objects = new QPointer<QObject>[m_objectCount];
for (int ii = 0; ii < m_objectCount; ++ii)
m_contextCount = (vme->rootContext.isNull()?0:1) + vme->states.count();
m_contexts = new QQmlGuardedContextData[m_contextCount];
- for (int ii = 0; ii < vme->states.count(); ++ii)
+ for (int ii = 0; ii < vme->states.count(); ++ii)
m_contexts[ii] = vme->states.at(ii).context;
if (!vme->rootContext.isNull())
m_contexts[m_contextCount - 1] = vme->rootContext.contextData();
};
// Used to check that a QQmlVME that is interrupted mid-execution
-// is still valid. Checks all the objects and contexts have not been
+// is still valid. Checks all the objects and contexts have not been
// deleted.
class QQmlVMEGuard
{
return &data;
}
-void *QQmlVMEVariant::dataPtr()
+void *QQmlVMEVariant::dataPtr()
{
return &data;
}
return sizeof(data);
}
-QObject *QQmlVMEVariant::asQObject()
+QObject *QQmlVMEVariant::asQObject()
{
if (type != QMetaType::QObjectStar)
setValue((QObject *)0, 0, -1);
return *(QQmlGuard<QObject> *)(dataPtr());
}
-const QVariant &QQmlVMEVariant::asQVariant()
+const QVariant &QQmlVMEVariant::asQVariant()
{
if (type != QMetaType::QVariant)
setValue(QVariant());
return *(QVariant *)(dataPtr());
}
-int QQmlVMEVariant::asInt()
+int QQmlVMEVariant::asInt()
{
if (type != QMetaType::Int)
setValue(int(0));
return *(int *)(dataPtr());
}
-bool QQmlVMEVariant::asBool()
+bool QQmlVMEVariant::asBool()
{
if (type != QMetaType::Bool)
setValue(bool(false));
return *(bool *)(dataPtr());
}
-double QQmlVMEVariant::asDouble()
+double QQmlVMEVariant::asDouble()
{
if (type != QMetaType::Double)
setValue(double(0));
return *(double *)(dataPtr());
}
-const QString &QQmlVMEVariant::asQString()
+const QString &QQmlVMEVariant::asQString()
{
if (type != QMetaType::QString)
setValue(QString());
return *(QString *)(dataPtr());
}
-const QUrl &QQmlVMEVariant::asQUrl()
+const QUrl &QQmlVMEVariant::asQUrl()
{
if (type != QMetaType::QUrl)
setValue(QUrl());
return *(QUrl *)(dataPtr());
}
-const QTime &QQmlVMEVariant::asQTime()
+const QTime &QQmlVMEVariant::asQTime()
{
if (type != QMetaType::QTime)
setValue(QTime());
return *(QTime *)(dataPtr());
}
-const QDate &QQmlVMEVariant::asQDate()
+const QDate &QQmlVMEVariant::asQDate()
{
if (type != QMetaType::QDate)
setValue(QDate());
return *(QDate *)(dataPtr());
}
-const QDateTime &QQmlVMEVariant::asQDateTime()
+const QDateTime &QQmlVMEVariant::asQDateTime()
{
if (type != QMetaType::QDateTime)
setValue(QDateTime());
if (t == qMetaTypeId<QQmlListProperty<QObject> >()) {
int listIndex = data[id].asInt();
const List *list = &listProperties.at(listIndex);
- *reinterpret_cast<QQmlListProperty<QObject> *>(a[0]) =
+ *reinterpret_cast<QQmlListProperty<QObject> *>(a[0]) =
QQmlListProperty<QObject>(object, (void *)list,
- list_append, list_count, list_at,
+ list_append, list_count, list_at,
list_clear);
}
QQmlVMEMetaData::AliasData *d = metaData->aliasData() + id;
- if (d->flags & QML_ALIAS_FLAG_PTR && c == QMetaObject::ReadProperty)
+ if (d->flags & QML_ALIAS_FLAG_PTR && c == QMetaObject::ReadProperty)
*reinterpret_cast<void **>(a[0]) = 0;
if (!ctxt) return -1;
QQmlContextPrivate *ctxtPriv = QQmlContextPrivate::get(context);
QObject *target = ctxtPriv->data->idValues[d->contextIdx].data();
- if (!target)
+ if (!target)
return -1;
connectAlias(id);
if (d->isObjectAlias()) {
*reinterpret_cast<QObject **>(a[0]) = target;
return -1;
- }
-
+ }
+
// Remove binding (if any) on write
if(c == QMetaObject::WriteProperty) {
int flags = *reinterpret_cast<int*>(a[3]);
}
}
}
-
+
if (d->isValueTypeAlias()) {
// Value type property
QQmlValueType *valueType = QQmlValueTypeFactory::valueType(d->valueType());
valueType->read(target, d->propertyIndex());
int rv = QMetaObject::metacall(valueType, c, d->valueTypeIndex(), a);
-
+
if (c == QMetaObject::WriteProperty)
valueType->write(target, d->propertyIndex(), 0x00);
return QV4::Primitive::undefinedValue().asReturnedValue();
}
- if (!v8methods)
+ if (!v8methods)
v8methods = new QV4::PersistentValue[metaData->methodCount];
return v8methods[index].value();
int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
Q_ASSERT(index >= (methodOffset() + plainSignals) && index < (methodOffset() + plainSignals + metaData->methodCount));
- if (!v8methods)
+ if (!v8methods)
v8methods = new QV4::PersistentValue[metaData->methodCount];
int methodIndex = index - methodOffset() - plainSignals;
return (propertyIdx & 0xFFFF0000) ? propType : 0;
}
};
-
+
struct PropertyData {
int propertyType;
};
namespace {
class DocumentImpl;
-class NodeImpl
+class NodeImpl
{
public:
NodeImpl() : type(Element), document(0), parent(0) {}
- virtual ~NodeImpl() {
+ virtual ~NodeImpl() {
for (int ii = 0; ii < children.count(); ++ii)
delete children.at(ii);
for (int ii = 0; ii < attributes.count(); ++ii)
}
// These numbers are copied from the Node IDL definition
- enum Type {
- Attr = 2,
- CDATA = 4,
- Comment = 8,
- Document = 9,
- DocumentFragment = 11,
+ enum Type {
+ Attr = 2,
+ CDATA = 4,
+ Comment = 8,
+ Document = 9,
+ DocumentFragment = 11,
DocumentType = 10,
- Element = 1,
- Entity = 6,
+ Element = 1,
+ Entity = 6,
EntityReference = 5,
- Notation = 12,
- ProcessingInstruction = 7,
+ Notation = 12,
+ ProcessingInstruction = 7,
Text = 3
};
Type type;
}
-void NodeImpl::addref()
+void NodeImpl::addref()
{
document->addref();
}
break;
case QXmlStreamReader::EndDocument:
break;
- case QXmlStreamReader::StartElement:
+ case QXmlStreamReader::StartElement:
{
Q_ASSERT(document);
NodeImpl *node = new NodeImpl;
attr->parent = node;
node->attributes.append(attr);
}
- }
+ }
break;
case QXmlStreamReader::EndElement:
nodeStack.pop();
{
Q_OBJECT
public:
- enum State { Unsent = 0,
+ enum State { Unsent = 0,
Opened = 1, HeadersReceived = 2,
Loading = 3, Done = 4 };
}
request.setHeader(QNetworkRequest::ContentTypeHeader, str);
} else {
- request.setHeader(QNetworkRequest::ContentTypeHeader,
+ request.setHeader(QNetworkRequest::ContentTypeHeader,
QLatin1String("text/plain;charset=UTF-8"));
}
}
if (xhrDump()) {
qWarning().nospace() << "XMLHttpRequest: " << qPrintable(m_method) << ' ' << qPrintable(url.toString());
if (!m_data.isEmpty()) {
- qWarning().nospace() << " "
+ qWarning().nospace() << " "
<< qPrintable(QString::fromUtf8(m_data));
}
}
m_errorFlag = true;
m_request = QNetworkRequest();
- if (!(m_state == Unsent ||
+ if (!(m_state == Unsent ||
(m_state == Opened && !m_sendFlag) ||
m_state == Done)) {
void QQmlXMLHttpRequest::readyRead()
{
- m_status =
+ m_status =
m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
m_statusText =
QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
} else {
m_errorFlag = true;
m_responseEntityBody = QByteArray();
- }
+ }
m_state = Done;
if (xhrDump()) {
qWarning().nospace() << "XMLHttpRequest: RESPONSE " << qPrintable(m_url.toString());
if (!m_responseEntityBody.isEmpty()) {
- qWarning().nospace() << " "
+ qWarning().nospace() << " "
<< qPrintable(QString::fromUtf8(m_responseEntityBody));
}
}
}
}
- if (m_mime.isEmpty() || m_mime == "text/xml" || m_mime == "application/xml" || m_mime.endsWith("+xml"))
+ if (m_mime.isEmpty() || m_mime == "text/xml" || m_mime == "application/xml" || m_mime.endsWith("+xml"))
m_gotXml = true;
}
{
QTextCodec *codec = 0;
- if (!m_charset.isEmpty())
+ if (!m_charset.isEmpty())
codec = QTextCodec::codecForName(m_charset);
if (!codec && m_gotXml) {
codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
}
- if (!codec && m_mime == "text/html")
+ if (!codec && m_mime == "text/html")
codec = QTextCodec::codecForHtml(m_responseEntityBody, 0);
if (!codec)
// Argument 0 - Method
QString method = ctx->callData->args[0].toQStringNoThrow().toUpper();
- if (method != QLatin1String("GET") &&
+ if (method != QLatin1String("GET") &&
method != QLatin1String("PUT") &&
method != QLatin1String("HEAD") &&
method != QLatin1String("POST") &&
// Argument 1 - URL
QUrl url = QUrl(ctx->callData->args[1].toQStringNoThrow());
- if (url.isRelative())
+ if (url.isRelative())
url = engine->callingContext()->resolvedUrl(url);
// Argument 2 - async (optional)
nameUpper == QLatin1String("USER-AGENT") ||
nameUpper == QLatin1String("VIA") ||
nameUpper.startsWith(QLatin1String("PROXY-")) ||
- nameUpper.startsWith(QLatin1String("SEC-")))
+ nameUpper.startsWith(QLatin1String("SEC-")))
return Encode::undefined();
r->addHeader(name, value);
if (r->readyState() != QQmlXMLHttpRequest::Loading &&
r->readyState() != QQmlXMLHttpRequest::Done)
return engine->toString(QString());
- else
+ else
return engine->toString(r->responseBody());
}
// ...
// Q_INVOKABLE void myMethod(QQmlV8Function*);
// };
-// The QQmlV8Function - and consequently the arguments and return value - only remains
+// The QQmlV8Function - and consequently the arguments and return value - only remains
// valid during the call. If the return value isn't set within myMethod(), the will return
// undefined.
class QV8Engine;
void reportScriptException(WorkerScript *, const QQmlError &error);
};
-QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEnginePrivate *parent)
+QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEnginePrivate *parent)
: QV8Engine(0), p(parent), accessManager(0)
{
m_v4Engine->v8Engine = this;
}
-QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine()
-{
- delete accessManager;
+QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine()
+{
+ delete accessManager;
}
void QQuickWorkerScriptEnginePrivate::WorkerEngine::init()
return v.asReturnedValue();
}
-QNetworkAccessManager *QQuickWorkerScriptEnginePrivate::WorkerEngine::networkAccessManager()
+QNetworkAccessManager *QQuickWorkerScriptEnginePrivate::WorkerEngine::networkAccessManager()
{
if (!accessManager) {
if (p->qmlengine && p->qmlengine->networkAccessManagerFactory()) {
}
}
-void QQuickWorkerScriptEnginePrivate::reportScriptException(WorkerScript *script,
+void QQuickWorkerScriptEnginePrivate::reportScriptException(WorkerScript *script,
const QQmlError &error)
{
QQuickWorkerScriptEnginePrivate *p = QQuickWorkerScriptEnginePrivate::get(workerEngine);
AnimatedImage { id: animation; source: "animation.gif" }
- Rectangle {
+ Rectangle {
property int frames: animation.frameCount
width: 4; height: 8
}
model: ContactModel {}
- delegate: contactsDelegate
+ delegate: contactsDelegate
focus: true
}
//![isCurrentItem]
source: "MyItem.qml"
}
- Connections {
+ Connections {
target: myLoader.item
onMessage: console.log(msg)
}
Loader { id: pageLoader }
- MouseArea {
+ MouseArea {
anchors.fill: parent
onClicked: pageLoader.source = "Page1.qml"
}
Item {
width: 200; height: 100
- Rectangle {
+ Rectangle {
id: redRect
width: 100; height: 100
color: "red"
}
- Rectangle {
+ Rectangle {
id: blueRect
x: redRect.width
width: 50; height: 50
Item {
width: 200; height: 100
- Rectangle {
+ Rectangle {
id: redRect
width: 100; height: 100
color: "red"
}
- Rectangle {
+ Rectangle {
id: blueRect
x: redRect.width
width: 50; height: 50
}
//! [single state]
- transitions: Transition {
- PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
+ transitions: Transition {
+ PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
}
}
//![transition]
width: 100; height: 100
color: "red"
- MouseArea {
+ MouseArea {
id: mouseArea
- anchors.fill: parent
+ anchors.fill: parent
}
states: State {
Row {
Repeater {
model: 3
- Rectangle {
+ Rectangle {
width: 100; height: 40
border.width: 1
color: "yellow"
//! [index]
Column {
Repeater {
- model: 10
+ model: 10
Text { text: "I'm item " + index }
}
}
Row {
Rectangle { width: 10; height: 20; color: "red" }
Repeater {
- model: 10
+ model: 10
Rectangle { width: 20; height: 20; radius: 10; color: "green" }
}
Rectangle { width: 10; height: 20; color: "blue" }
color: "red"
antialiasing: true
- states: State {
+ states: State {
name: "rotated"
- PropertyChanges { target: rect; rotation: 180 }
+ PropertyChanges { target: rect; rotation: 180 }
}
transitions: Transition {
Row {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
-
+
spacing: 5
Rectangle { width: 100; height: 100; radius: 20.0
width: 100; height: 100
color: "black"
- MouseArea {
+ MouseArea {
id: mouseArea
- anchors.fill: parent
+ anchors.fill: parent
onClicked: myRect.state == 'clicked' ? myRect.state = "" : myRect.state = 'clicked';
}
PropertyChanges { target: rect; color: "yellow" }
}
- transitions: Transition {
+ transitions: Transition {
ColorAnimation { duration: 1000 }
}
}
}
//! [sequential animations]
- transitions: Transition {
+ transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 1000 }
ColorAnimation { duration: 1000 }
PropertyChanges { target: rect; x: 50; y: 50 }
}
- transitions: Transition {
- NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
+ transitions: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
}
}
//![0]
Image { source: "image://myimageprovider/image.png" }
\endqml
- This specifies that the image should be loaded by the image provider named
- "myimageprovider", and the image to be loaded is named "image.png". The QML engine
+ This specifies that the image should be loaded by the image provider named
+ "myimageprovider", and the image to be loaded is named "image.png". The QML engine
invokes the appropriate image provider according to the providers that have
been registered through QQmlEngine::addImageProvider().
When these images are loaded by QML, it looks for a matching image provider
and calls its requestImage() or requestPixmap() method (depending on its
- imageType()) to load the image. The method is called with the \c id
+ imageType()) to load the image. The method is called with the \c id
parameter set to "yellow" for the first image, and "red" for the second.
- Here is an image provider implementation that can load the images
- requested by the above QML. This implementation dynamically
+ Here is an image provider implementation that can load the images
+ requested by the above QML. This implementation dynamically
generates QPixmap images that are filled with the requested color:
\snippet imageprovider/imageprovider.cpp 0
with a "colors" identifier:
\code
- int main(int argc, char *argv[])
+ int main(int argc, char *argv[])
{
...
\image imageprovider.png
- A complete example is available in Qt's
+ A complete example is available in Qt's
\l {qml/imageprovider}{examples/quick/imageprovider}
directory. Note the example registers the provider via a \l{QQmlExtensionPlugin}{plugin}
instead of registering it in the application \c main() function as shown above.
Image providers that support QImage or Texture loading automatically include support
for asychronous loading of images. To enable asynchronous loading for an
image source, set the \c asynchronous property to \c true for the relevant
- \l Image, \l BorderImage or \l AnimatedImage object. When this is enabled,
+ \l Image, \l BorderImage or \l AnimatedImage object. When this is enabled,
the image request to the provider is run in a low priority thread,
allowing image loading to be executed in the background, and reducing the
performance impact on the user interface.
}
/*!
- Implement this method to return the image with \a id. The default
+ Implement this method to return the image with \a id. The default
implementation returns an empty image.
The \a id is the requested image source, with the "image:" scheme and
{
public:
QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &s, const QString &e)
- : refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Error),
+ : refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Error),
url(u), errorString(e), requestSize(s), textureFactory(0), reply(0), prevUnreferenced(0),
prevUnreferencedPtr(0), nextUnreferenced(0)
{
}
QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &r)
- : refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Loading),
+ : refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Loading),
url(u), requestSize(r), textureFactory(0), reply(0), prevUnreferenced(0), prevUnreferencedPtr(0),
nextUnreferenced(0)
{
uint refCount;
bool inCache:1;
-
+
QQuickPixmap::Status pixmapStatus;
QUrl url;
QString errorString;
return accessManager;
}
-static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize,
+static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize,
const QSize &requestSize)
{
QImageReader imgio(dev);
{
}
-void QQuickPixmapReaderThreadObject::processJobs()
-{
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
+void QQuickPixmapReaderThreadObject::processJobs()
+{
+ QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
-bool QQuickPixmapReaderThreadObject::event(QEvent *e)
+bool QQuickPixmapReaderThreadObject::event(QEvent *e)
{
- if (e->type() == QEvent::User) {
- reader->processJobs();
- return true;
- } else {
+ if (e->type() == QEvent::User) {
+ reader->processJobs();
+ return true;
+ } else {
return QObject::event(e);
}
}
QMutexLocker locker(&mutex);
while (true) {
- if (cancelled.isEmpty() && (jobs.isEmpty() || replies.count() >= IMAGEREQUEST_MAX_REQUEST_COUNT))
+ if (cancelled.isEmpty() && (jobs.isEmpty() || replies.count() >= IMAGEREQUEST_MAX_REQUEST_COUNT))
return; // Nothing else to do
// Clean cancelled jobs
}
}
-void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &url,
+void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &url,
const QSize &requestSize)
{
// fetch
QQuickPixmapReply *reply = new QQuickPixmapReply(data);
reply->engineForReader = engine;
jobs.append(reply);
- // XXX
+ // XXX
if (threadObject) threadObject->processJobs();
mutex.unlock();
return reply;
if (reply->loading) {
cancelled.append(reply);
reply->data = 0;
- // XXX
+ // XXX
if (threadObject) threadObject->processJobs();
} else {
jobs.removeAll(reply);
Q_ASSERT(data->prevUnreferencedPtr);
*data->prevUnreferencedPtr = data->nextUnreferenced;
- if (data->nextUnreferenced) {
+ if (data->nextUnreferenced) {
data->nextUnreferenced->prevUnreferencedPtr = data->prevUnreferencedPtr;
data->nextUnreferenced->prevUnreferenced = data->prevUnreferenced;
}
{
++refCount;
Q_QML_PROFILE(pixmapCountChanged<QQmlProfilerService::PixmapReferenceCountChanged>(url, refCount));
- if (prevUnreferencedPtr)
+ if (prevUnreferencedPtr)
pixmapStore()->referencePixmap(this);
}
}
QString localFile = QQmlFile::urlToLocalFileOrQrc(url);
- if (localFile.isEmpty())
+ if (localFile.isEmpty())
return 0;
QFile f(localFile);
const QSize &QQuickPixmap::implicitSize() const
{
- if (d)
+ if (d)
return d->implicitSize;
else
return nullPixmap()->size;
Q_QML_PROFILE(pixmapStateChanged<QQmlProfilerService::PixmapLoadingError>(url));
return;
}
- }
+ }
if (!engine)
return;
void QQuickPixmap::clear(QObject *obj)
{
if (d) {
- if (d->reply)
+ if (d->reply)
QObject::disconnect(d->reply, 0, obj, 0);
d->declarativePixmaps.remove(this);
d->release();
struct OperationGuard : public QQmlGuard<QQuickStateOperation>
{
- OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) {
+ OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) {
setObject(static_cast<QQuickStateOperation *>(obj));
}
QList<OperationGuard> *list;
Execute
};
Op() {}
- Op(Type t, int l, qreal v, qreal v2, int o,
+ Op(Type t, int l, qreal v, qreal v2, int o,
const QQuickTimeLineCallback &ev = QQuickTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
: type(t), length(l), value(v), value2(v2), order(o), event(ev),
easing(es) {}
: type(o.type), length(o.length), value(o.value), value2(o.value2),
order(o.order), event(o.event), easing(o.easing) {}
Op &operator=(const Op &o) {
- type = o.type; length = o.length; value = o.value;
- value2 = o.value2; order = o.order; event = o.event;
+ type = o.type; length = o.length; value = o.value;
+ value2 = o.value2; order = o.order; event = o.event;
easing = o.easing;
return *this;
}
d->syncPoint = d->length;
}*/
-/*!
- \internal
+/*!
+ \internal
Temporary hack.
*/
d->syncPoint = sp;
}
-/*!
- \internal
-
+/*!
+ \internal
+
Temporary hack.
*/
int QQuickTimeLine::syncPoint() const
TimeLine &tl = *iter;
Op &op = tl.ops.first();
int length = op.length - tl.consumedOpLength;
-
+
if (length < advanceTime) {
advanceTime = length;
if (advanceTime == 0)
}
t -= advanceTime;
- // Process until then. A zero length advance time will only process
+ // Process until then. A zero length advance time will only process
// sets.
QList<QPair<int, Update> > updates;
if (advanceTime == 0 && op.length != 0)
continue;
- if (tl.consumedOpLength == 0 &&
- op.type != Op::Pause &&
+ if (tl.consumedOpLength == 0 &&
+ op.type != Op::Pause &&
op.type != Op::Execute)
tl.base = v->value();
return d->transitionInstance && d->transitionInstance->isRunning();
}
-void QQuickTransitionManager::complete()
+void QQuickTransitionManager::complete()
{
d->applyBindings();
d->completeList.clear();
- if (d->state)
+ if (d->state)
static_cast<QQuickStatePrivate*>(QObjectPrivate::get(d->state))->complete();
finished();
} else {
if (touched.contains(action.property)) {
- if (action.toValue != action.fromValue)
- d->completeList <<
+ if (action.toValue != action.fromValue)
+ d->completeList <<
QQuickSimpleAction(action, QQuickSimpleAction::EndState);
applyList.removeAt(ii);
// Any actions remaining have not been handled by the transition and should
// be applied immediately. We skip applying bindings, as they are all
- // applied at the end in applyBindings() to avoid any nastiness mid
+ // applied at the end in applyBindings() to avoid any nastiness mid
// transition
foreach(const QQuickStateAction &action, applyList) {
if (action.event && !action.event->changesBindings()) {
qWarning() << " No transition for event:" << action.event->type();
else
qWarning() << " No transition for:" << action.property.object()
- << action.property.name() << "From:" << action.fromValue
+ << action.property.name() << "From:" << action.fromValue
<< "To:" << action.toValue;
}
}
class QQuickStatePrivate;
class QQuickTransitionManagerPrivate;
-class Q_AUTOTEST_EXPORT QQuickTransitionManager
+class Q_AUTOTEST_EXPORT QQuickTransitionManager
{
public:
QQuickTransitionManager();
goalState: ""
jump: true
}
-
+
Emitter {
//0,0 position
group: "notdefault"
m_server = new QTcpServer(this);
m_serverConn = 0;
QVERIFY(m_server->listen(QHostAddress("127.0.0.1")));
-
+
m_client = new QTcpSocket(this);
m_client->connectToHost(m_server->serverAddress(), m_server->serverPort());
-
+
QVERIFY(m_client->waitForConnected());
QVERIFY(m_server->waitForNewConnection(10000));
m_serverConn = m_server->nextPendingConnection();
{
}
-QQmlDebugClient::QQmlDebugClient(const QString &name,
+QQmlDebugClient::QQmlDebugClient(const QString &name,
QQmlDebugConnection *parent)
: QObject(parent),
d(new QQmlDebugClientPrivate)
var l;
var funcName = currentFunc();
var prefix = (funcName) ? "[reported from " + funcName + "] ": "";
-
+
for (var i=0; i<lines.length; i++)
print (FAILED + prefix + lines[i]);
}
function toPrinted(value)
{
- if (typeof value == "xml")
+ if (typeof value == "xml")
{
value = value.toXMLString();
- }
- else
+ }
+ else
{
value = String(value);
}
function exitFunc (funcName)
{
var lastFunc = callStack.pop();
-
+
if (funcName)
{
if (!funcName.match(/\(\)$/))
{
var Ydiff = Y[i] - this.Yavg;
var Xdiff = X[i] - this.Xavg;
-
+
SUM_Ydiff2 += Ydiff * Ydiff;
SUM_Xdiff2 += Xdiff * Xdiff;
SUM_XdiffYdiff += Xdiff * Ydiff;
{
deriv.X[i] = (X[i] + X[i+1])/2;
deriv.Y[i] = (Y[i+1] - Y[i])/(X[i+1] - X[i]);
- }
+ }
return deriv;
}
}
function optionsClear() {
-
+
// turn off current settings
var optionNames = options().split(',');
for (var i = 0; i < optionNames.length; i++)
var expected_t = typeof expected;
var actual_t = typeof actual;
var passed = true;
-
+
// because ( NaN == NaN ) always returns false, need to do
// a special compare to see if we got the right result.
- if ( actual != actual )
+ if ( actual != actual )
{
- if ( actual_t == "object" )
+ if ( actual_t == "object" )
{
actual = "NaN object";
- }
- else
+ }
+ else
{
actual = "NaN number";
}
}
- if ( expected != expected )
+ if ( expected != expected )
{
- if ( expected_t == "object" )
+ if ( expected_t == "object" )
{
expected = "NaN object";
- }
- else
+ }
+ else
{
expected = "NaN number";
}
passed = false;
}
}
-
+
return passed;
}
property var i
- Component{
+ Component{
id: component
Item {
property int dummy: 13
property int dummy2: 26
- }
+ }
}
Component.onCompleted: {
Item {
id: root
-
+
property bool test: false
property real testData: 9
id: obj
testProperty: root.value1 * 9
- aliasProperty: root.value2 * 10
+ aliasProperty: root.value2 * 10
}
Component.onCompleted: {
MyQmlObject {
property alias c1: myObject.c1
property int c2: 3
- property int c3: c2
- objectProperty: QtObject {
- id: myObject
+ property int c3: c2
+ objectProperty: QtObject {
+ id: myObject
property int c1
}
}
floatProperty: if(1) 8.5
colorProperty: if(1) "red"
dateProperty: if(1) "1982-11-25"
- timeProperty: if(1) "11:11:32"
+ timeProperty: if(1) "11:11:32"
dateTimeProperty: if(1) "2009-05-12T13:22:01"
pointProperty: if(1) "99,13"
pointFProperty: if(1) "-10.1,12.3"
floatProperty = 8.5
colorProperty = "red"
dateProperty = "1982-11-25"
- timeProperty = "11:11:32"
+ timeProperty = "11:11:32"
dateTimeProperty = "2009-05-12T13:22:01"
pointProperty = "99,13"
pointFProperty = "-10.1,12.3"
import Qt.test 1.0
-MyQmlContainer {
- children : [
- MyQmlObject {
- id: object1
- stringProperty: "hello" + object2.stringProperty
+MyQmlContainer {
+ children : [
+ MyQmlObject {
+ id: object1
+ stringProperty: "hello" + object2.stringProperty
},
- MyQmlObject {
- id: object2
- stringProperty: "hello" + object1.stringProperty
- }
- ]
+ MyQmlObject {
+ id: object2
+ stringProperty: "hello" + object1.stringProperty
+ }
+ ]
}
import Qt.test 1.0
-MyQmlObject {
- stringProperty: trueProperty?'pass':'fail'
+MyQmlObject {
+ stringProperty: trueProperty?'pass':'fail'
}
import Qt.test 1.0
-MyQmlObject {
- stringProperty: falseProperty?'fail':'pass'
+MyQmlObject {
+ stringProperty: falseProperty?'fail':'pass'
}
property alias c1: myConstants.c1
property alias c2: myConstants.c2
- objectProperty: ConstantsOverrideBindings {
+ objectProperty: ConstantsOverrideBindings {
id: myConstants
- c2: 10
+ c2: 10
}
}
property alias c1: myConstants.c1
property alias c3: myConstants.c3
- objectProperty: ConstantsOverrideBindings {
+ objectProperty: ConstantsOverrideBindings {
id: myConstants
c3: 10
}
QtObject {
function calculate() {
- return b * 13;
+ return b * 13;
}
property int a: calculate()
function create() {
objectProperty = c.createObject(root);
}
-
+
function destroy() {
objectProperty.destroy();
}
import QtQuick 2.0
QtObject {
- property bool test1: false;
- property bool test2: false;
- property bool test3: false;
- property bool test4: false;
- property bool test5: false;
+ property bool test1: false;
+ property bool test2: false;
+ property bool test3: false;
+ property bool test4: false;
+ property bool test5: false;
property int a: 7
property int testValue: 99
- Component.onCompleted: {
- IncludeTest.go();
+ Component.onCompleted: {
+ IncludeTest.go();
test0 = IncludeTest.value
test1 = IncludeTest.test1
test2 = IncludeTest.test2
property bool test5: false
property bool test6: false
- Component.onCompleted: {
- IncludeTest.go();
+ Component.onCompleted: {
+ IncludeTest.go();
}
}
function go()
{
- var a = Qt.include("http://127.0.0.1:8111/remote_file.js",
- function(o) {
+ var a = Qt.include("http://127.0.0.1:8111/remote_file.js",
+ function(o) {
test2 = o.status == o.OK
test3 = a.status == a.OK
test4 = myvar == 13
test1 = a.status == a.LOADING
- var b = Qt.include("http://127.0.0.1:8111/exception.js",
- function(o) {
+ var b = Qt.include("http://127.0.0.1:8111/exception.js",
+ function(o) {
test7 = o.status == o.EXCEPTION
test8 = b.status == a.EXCEPTION
test9 = b.exception.toString() == "Whoops!";
function go()
{
- var a = Qt.include("http://127.0.0.1:8111/missing.js",
- function(o) {
+ var a = Qt.include("http://127.0.0.1:8111/missing.js",
+ function(o) {
test2 = o.status == o.NETWORK_ERROR
test3 = a.status == a.NETWORK_ERROR
property bool test3: false
property bool test3_1: false
- Component.onCompleted: {
- IncludeTest.go();
+ Component.onCompleted: {
+ IncludeTest.go();
test0 = IncludeTest.value
test1 = IncludeTest.test1
test2 = IncludeTest.test2
import Qt.test 1.0
-MyQmlObject {
+MyQmlObject {
id: myObject
- onBasicSignal: myObject.methodNoArgs()
+ onBasicSignal: myObject.methodNoArgs()
}
import Qt.test 1.0
-MyQmlObject {
+MyQmlObject {
id: myObject
- onBasicSignal: myObject.method(163)
+ onBasicSignal: myObject.method(163)
}
property alias c2: myConstants.c2
property int c3: 0
- objectProperty: ConstantsOverrideBindings {
- id: myConstants
+ objectProperty: ConstantsOverrideBindings {
+ id: myConstants
c2: obj.c3
}
MyDerivedObject {
property bool test: false
-
+
Component.onCompleted: {
test = intProperty()
}
if (wheelCount != 8) return;
// not bindable, but wheelCount will update because truck itself changed.
- truck = new vehicle(12);
+ truck = new vehicle(12);
if (wheelCount != 12) return;
if (varProperty.a != 10) return;
test = true;
- }
+ }
}
test1 = true;
}
- // Run gc() from C++
+ // Run gc() from C++
function runTest2() {
if (object.dummy != 10) return;
if (varProperty.a != 10) return;
test = true;
- }
+ }
}
// id takes precedence over local, and root properties
- property int test1: a.value
+ property int test1: a.value
property alias test2: nested.test
// properties takes precedence over local, and root methods
import Qt.test 1.0
import QtQuick 2.0
import "scriptConnect.1.js" as Script
-MyQmlObject {
+MyQmlObject {
property bool test: false
id: root
-
+
Component.onCompleted: root.argumentSignal.connect(Script.testFunction);
}
import QtQuick 2.0
import "scriptConnect.2.js" as Script
-MyQmlObject {
+MyQmlObject {
property bool test: false
id: root
-
+
Component.onCompleted: {
var a = new Object;
a.b = 12;
import Qt.test 1.0
import QtQuick 2.0
-MyQmlObject {
+MyQmlObject {
property bool test: false
id: root
-
+
function testFunction() {
test = true;
}
import Qt.test 1.0
import QtQuick 2.0
-MyQmlObject {
+MyQmlObject {
property bool test: false
id: root
import Qt.test 1.0
import QtQuick 2.0
-MyQmlObject {
+MyQmlObject {
property bool test: false
id: root
import QtQuick 2.0
import "scriptConnect.6.js" as Script
-MyQmlObject {
+MyQmlObject {
property int test: 0
id: root
- Component.onCompleted: {
+ Component.onCompleted: {
root.argumentSignal.connect(Script.testFunction);
root.argumentSignal.connect(Script.testFunction);
}
import QtQuick 2.0
import "scriptDisconnect.1.js" as Script
-MyQmlObject {
+MyQmlObject {
property int test: 0
id: root
-
+
Component.onCompleted: root.argumentSignal.connect(Script.testFunction);
onBasicSignal: root.argumentSignal.disconnect(Script.testFunction);
import QtQuick 2.0
import "scriptDisconnect.1.js" as Script
-MyQmlObject {
+MyQmlObject {
property int test: 0
id: root
-
+
Component.onCompleted: root.argumentSignal.connect(root, Script.testFunction);
onBasicSignal: root.argumentSignal.disconnect(root, Script.testFunction);
import QtQuick 2.0
import "scriptDisconnect.1.js" as Script
-MyQmlObject {
+MyQmlObject {
property int test: 0
id: root
-
+
Component.onCompleted: root.argumentSignal.connect(root, Script.testFunction);
onBasicSignal: root.argumentSignal.disconnect(Script.testFunction);
import QtQuick 2.0
import "scriptDisconnect.1.js" as Script
-MyQmlObject {
+MyQmlObject {
property int test: 0
id: root
-
+
Component.onCompleted: root.argumentSignal.connect(Script.testFunction);
onBasicSignal: root.argumentSignal.disconnect(Script.otherFunction);
// Comment
a = 10
-function getValue() { a = 10; return 0; }
+function getValue() { a = 10; return 0; }
MyQmlObject {
// Will trigger deletion on binding assignment, but after component creation
- deleteOnSet: if (triggerDelete) 1; else 0;
+ deleteOnSet: if (triggerDelete) 1; else 0;
}
]
}
import Qt.test 1.0
-MyQmlObject {
- onBasicSignal: setString('pass')
+MyQmlObject {
+ onBasicSignal: setString('pass')
}
import Qt.test 1.0
-MyQmlObject {
+MyQmlObject {
onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c + ' ' + d + ' ' + e)
}
property real test1: base
property real test2: Math.max(0, base)
}
-
+
// Signal with no args
onBasicSignal: base = 200
// Signal with args
}
QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) {
+ void setObjectProperty(QObject *obj) {
if (obj == m_object)
return;
m_object = obj;
int intProperty() const { return m_intProperty; }
void setIntProperty(int i) { m_intProperty = i; emit intChanged(); }
-
+
Q_INVOKABLE MyEnum2 getEnumValue() const { return EnumValue4; }
MyEnum enumPropertyValue;
Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
-
+
Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; }
context.setContextProperty("testObj", &object1);
context.setContextProperty("testObj2", object3);
- {
+ {
MyExpression expr(&context, "testProp + 1");
QCOMPARE(expr.changed, false);
QCOMPARE(expr.evaluate(), QVariant(2));
QCOMPARE(expr.evaluate(), QVariant(3));
}
- {
+ {
MyExpression expr(&context, "testProp + testProp + testProp");
QCOMPARE(expr.changed, false);
QCOMPARE(expr.evaluate(), QVariant(6));
QCOMPARE(expr.evaluate(), QVariant(12));
}
- {
+ {
MyExpression expr(&context, "testObj.stringProperty");
QCOMPARE(expr.changed, false);
QCOMPARE(expr.evaluate(), QVariant("Hello"));
QCOMPARE(expr.evaluate(), QVariant("World"));
}
- {
+ {
MyExpression expr(&context, "testObj.stringProperty /**/");
QCOMPARE(expr.changed, false);
QCOMPARE(expr.evaluate(), QVariant("World"));
QCOMPARE(expr.evaluate(), QVariant("Hello"));
}
- {
+ {
MyExpression expr(&context, "testObj2");
QCOMPARE(expr.changed, false);
QCOMPARE(expr.evaluate(), QVariant::fromValue((QObject *)object3));
object2.setStringProperty(QLatin1String("Dog"));
object3.setStringProperty(QLatin1String("Cat"));
- {
+ {
MyExpression expr(&context, "testObj.stringProperty");
QCOMPARE(expr.changed, false);
QCOMPARE(expr.evaluate(), QVariant("Hello"));
QCOMPARE(expr.evaluate(), QVariant("World"));
}
- {
+ {
MyExpression expr(&context, "testObj.objectProperty.stringProperty");
QCOMPARE(expr.changed, false);
QCOMPARE(expr.evaluate(), QVariant());
void tst_qqmlecmascript::deferredProperties()
{
QQmlComponent component(&engine, testFileUrl("deferredProperties.qml"));
- MyDeferredObject *object =
+ MyDeferredObject *object =
qobject_cast<MyDeferredObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->value(), 0);
qmlExecuteDeferred(object);
QCOMPARE(object->value(), 10);
QVERIFY(object->objectProperty() != 0);
- MyQmlObject *qmlObject =
+ MyQmlObject *qmlObject =
qobject_cast<MyQmlObject *>(object->objectProperty());
QVERIFY(qmlObject != 0);
QCOMPARE(qmlObject->value(), 10);
void tst_qqmlecmascript::deferredPropertiesErrors()
{
QQmlComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml"));
- MyDeferredObject *object =
+ MyDeferredObject *object =
qobject_cast<MyDeferredObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->value(), 0);
void tst_qqmlecmascript::extensionObjects()
{
QQmlComponent component(&engine, testFileUrl("extensionObjects.qml"));
- MyExtendedObject *object =
+ MyExtendedObject *object =
qobject_cast<MyExtendedObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->baseProperty(), 13);
delete obj;
}
-/*
+/*
Tests that writing a constant to a property with a binding on it disables the
binding.
*/
*/
void tst_qqmlecmascript::outerBindingOverridesInnerBinding()
{
- QQmlComponent component(&engine,
+ QQmlComponent component(&engine,
testFileUrl("outerBindingOverridesInnerBinding.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
/*
-Access a non-existent attached object.
+Access a non-existent attached object.
Tests for a regression where this used to crash.
*/
delete object;
}
-
+
/*
Test bindings still work when the reeval is triggered from within
a signal script.
static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, const char *source)
{
- QString functionSource = QLatin1String("(function(object) { return ") +
+ QString functionSource = QLatin1String("(function(object) { return ") +
QLatin1String(source) + QLatin1String(" })");
QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource);
static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o,
const char *source, const QV4::ValueRef result)
{
- QString functionSource = QLatin1String("(function(object) { return ") +
+ QString functionSource = QLatin1String("(function(object) { return ") +
QLatin1String(source) + QLatin1String(" })");
QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource);
static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef o,
const char *source)
{
- QString functionSource = QLatin1String("(function(object) { return ") +
+ QString functionSource = QLatin1String("(function(object) { return ") +
QLatin1String(source) + QLatin1String(" })");
QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->currentContext();
QQmlEngine qmlengine;
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&qmlengine);
-
+
QV8Engine *engine = ep->v8engine();
QV4::Scope scope(QV8Engine::getV4(engine));
QObject *object = component.create();
QVERIFY(object != 0);
- MyQmlAttachedObject *attached =
+ MyQmlAttachedObject *attached =
qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
QVERIFY(attached != 0);
QVERIFY(own.object != 0);
QObject *object = component.create(context);
-
+
engine.collectGarbage();
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QPointer<QObject> value;
};
-// QTBUG-15695.
+// QTBUG-15695.
// Test setObjectOwnership(CppOwnership) works even when there is no QQmlData
void tst_qqmlecmascript::cppOwnershipReturnValue()
{
}
}
-// Test that assigning a null object works
+// Test that assigning a null object works
// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
void tst_qqmlecmascript::nullObjectBinding()
{
// Test bindings assigned to alias properties override a binding on the target (QTBUG-13719)
void tst_qqmlecmascript::aliasBindingsOverrideTarget()
{
- {
+ {
QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
include (../../shared/util.pri)
-SOURCES += tst_qqmlengine.cpp
+SOURCES += tst_qqmlengine.cpp
QT += core-private gui-private qml-private network testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
}
QStringList expect;
- expect
+ expect
<< "Index\tOperation\t\tData1\tData2\tData3\tComments"
<< "-------------------------------------------------------------------------------"
<< "0\t\tINIT\t\t\t0\t3\t-1\t-1"
property alias a: object2.a
o1: QtObject { id: object1 }
- o2: QtObject {
- id: object2
+ o2: QtObject {
+ id: object2
property int a: 1923
}
}
MyQmlObject {
property int a: Math.max(10, 9)
- property int b: 11
+ property int b: 11
Component.onCompleted: console.log("Completed " + a + " " + b);
}
MyQmlObject {
property int a: Math.max(10, 9)
- property int b: 11
+ property int b: 11
Component.onDestruction: console.log("Destruction " + a + " " + b);
}
import Test 1.0
Alias2 {
- enumAlias: MyTypeObject.EnumVal2
+ enumAlias: MyTypeObject.EnumVal2
}
QtObject {
property alias otherAlias: otherObject
- property variant other
+ property variant other
other: MyQmlObject {
id: otherObject
value: 10
floatProperty: 8.5
colorProperty: "red"
dateProperty: "1982-11-25"
- timeProperty: "11:11:32"
+ timeProperty: "11:11:32"
dateTimeProperty: "2009-05-12T13:22:01"
pointProperty: "99,13"
pointFProperty: "-10.1,12.3"
children: [
QtObject {
property int index: 2
- },
+ },
QtObject {
property int index: 3
- }
+ }
]
QtObject {
-import QtQuick 2.0
+import QtQuick 2.0
import QtQuick 2.0 as Qt47
Qt.QtObject {
objectProperty2: QtObject {}
property MyComponent myComponentProperty
- property MyComponent myComponentProperty2
+ property MyComponent myComponentProperty2
myComponentProperty2: MyComponent {}
}
import Test 1.0
MyContainer {
- qlistInterfaces: [
+ qlistInterfaces: [
MyQmlObject {},
MyQmlObject {}
]
-import QtQuick 2.0
+import QtQuick 2.0
QtObject {
property variant o;
-import QtQuick 2.0
+import QtQuick 2.0
QtObject {
property int o;
import Test 1.0
-MyQmlObject {
- something: 1 + 1
+MyQmlObject {
+ something: 1 + 1
}
objectProperty: OnCompletedType {
qmlobjectProperty: MyQmlObject {
id: nestedObject
- property int b: 10
+ property int b: 10
Component.onCompleted: console.log("Completed " + a + " " + nestedObject.b)
}
}
objectProperty: OnDestructionType {
qmlobjectProperty: MyQmlObject {
id: nestedObject
- property int b: 10
+ property int b: 10
Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b)
}
}
QVariant myCustomVariantTypeConverter(const QString &data);
-class MyInterface
+class MyInterface
{
public:
MyInterface() : id(913) {}
QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false;
QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false;
- QTest::newRow("incorrectCase") << "incorrectCase.qml"
+ QTest::newRow("incorrectCase") << "incorrectCase.qml"
#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
- << "incorrectCase.errors.insensitive.txt"
+ << "incorrectCase.errors.insensitive.txt"
#else
- << "incorrectCase.errors.sensitive.txt"
+ << "incorrectCase.errors.sensitive.txt"
#endif
<< false;
QCOMPARE(child->property("y"), QVariant(11));
}
-// Test literal assignment to all the basic types
+// Test literal assignment to all the basic types
void tst_qqmllanguage::assignBasicTypes()
{
QQmlComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->getChildren()->count(), 1);
- MyTypeObject *child =
+ MyTypeObject *child =
qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
QVERIFY(child != 0);
QCOMPARE(child->id(), QString("myObjectId"));
QList<QObject *> valueSources;
QObjectList allChildren = object->findChildren<QObject*>();
foreach (QObject *child, allChildren) {
- if (qobject_cast<QQmlPropertyValueSource *>(child))
+ if (qobject_cast<QQmlPropertyValueSource *>(child))
valueSources.append(child);
}
QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
+ MyPropertyValueSource *valueSource =
qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
QVERIFY(valueSource != 0);
QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
QList<QObject *> valueSources;
QObjectList allChildren = object->findChildren<QObject*>();
foreach (QObject *child, allChildren) {
- if (qobject_cast<QQmlPropertyValueSource *>(child))
+ if (qobject_cast<QQmlPropertyValueSource *>(child))
valueSources.append(child);
}
QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
+ MyPropertyValueSource *valueSource =
qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
QVERIFY(valueSource != 0);
QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
QVERIFY(object != 0);
// Read through alias
- MyQmlObject *v =
+ MyQmlObject *v =
qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
QVERIFY(v != 0);
QCOMPARE(v->value(), 10);
MyQmlObject *v2 = new MyQmlObject();
v2->setParent(object);
object->setProperty("aliasObject", qVariantFromValue(v2));
- MyQmlObject *v3 =
+ MyQmlObject *v3 =
qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
QVERIFY(v3 != 0);
QCOMPARE(v3, v2);
QCOMPARE(object->property("a").toInt(), 1923);
}
- // Ptr Alias Cleanup - check that aliases to ptr types return 0
+ // Ptr Alias Cleanup - check that aliases to ptr types return 0
// if the object aliased to is removed
{
QQmlComponent component(&engine, testFileUrl("alias.7.qml"));
}
}
-// Check that default property assignments are correctly spliced into explicit
+// Check that default property assignments are correctly spliced into explicit
// property assignments
void tst_qqmllanguage::defaultPropertyListOrder()
{
QQmlComponent component(&engine);
component.setData("import QtQuick 2.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml"));
- while (component.isLoading())
+ while (component.isLoading())
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50);
QObject *o = component.create();
ListView {
width: 100
height: 250
- delegate: Rectangle {
+ delegate: Rectangle {
width: 100
height: 50
- color: black ? "black": "white"
+ color: black ? "black": "white"
}
- model: ListModel {
+ model: ListModel {
objectName: "listModel"
ListElement {
black: false
QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1);
QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->parserStatusCast(), -1);
-
+
QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
int cast = QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->parserStatusCast();
QVERIFY(cast != -1);
QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1);
QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueSourceCast(), -1);
-
+
QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
int cast = QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->propertyValueSourceCast();
QVERIFY(cast != -1);
QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1);
QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueInterceptorCast(), -1);
-
+
QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>()) != 0);
int cast = QQmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>())->propertyValueInterceptorCast();
QVERIFY(cast != -1);
property bool test: false
property bool test2: false
- Bar {
+ Bar {
id: bar
}
Item {
property bool test: false
- Bar {
+ Bar {
id: bar
}
QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations.");
QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml")));
foreach (QQmlError err, component.errors())
- qWarning() << err;
+ qWarning() << err;
VERIFY_ERRORS(0);
QObject *object = component.create();
QVERIFY(object != 0);
property int myPixelSize: 12
property int myPixelSize2: 24
-
+
Text {
id: other
font.pixelSize: 6
property int myPixelSize: 12
property int myPixelSize2: 24
-
+
Text {
id: other
font.pixelSize: 6
property int myPixelSize: 12
property int myPixelSize2: 24
-
+
Text {
id: other
font.pixelSize: 6
Component.onCompleted: {
var x = new XMLHttpRequest;
- x.abort();
+ x.abort();
if (x.readyState == XMLHttpRequest.UNSENT)
readyState = true;
x.open("PUT", url);
x.setRequestHeader("Accept-Language", "en-US");
- x.abort();
+ x.abort();
x.open("GET", url);
x.setRequestHeader("Accept-Language", "en-US");
Component.onCompleted: {
var x = new XMLHttpRequest;
- x.abort();
+ x.abort();
if (x.readyState == XMLHttpRequest.UNSENT)
readyState = true;
function checkXML(document)
{
- checkElement(document.documentElement,
- document.documentElement.childNodes[0],
+ checkElement(document.documentElement,
+ document.documentElement.childNodes[0],
document.documentElement.childNodes[1]);
}
Component.onCompleted: {
var x = new XMLHttpRequest;
- try {
- x.getResponseHeader("Test-Header");
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- unsentException = true;
- }
+ try {
+ x.getResponseHeader("Test-Header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ unsentException = true;
+ }
if (x.readyState == XMLHttpRequest.UNSENT)
readyState = true;
if (x.readyState == XMLHttpRequest.OPENED)
openedState = true;
- try {
- x.getResponseHeader("Test-Header");
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- openedException = true;
- }
+ try {
+ x.getResponseHeader("Test-Header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ openedException = true;
+ }
var headers = "connection: close\r\ncontent-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11";
// Test to the end
x.onreadystatechange = function() {
- if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
- headersReceivedState = true;
+ if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ headersReceivedState = true;
- headersReceivedHeader = (x.getAllResponseHeaders() == headers);
- } else if (x.readyState == XMLHttpRequest.DONE) {
- doneState = headersReceivedState && true;
+ headersReceivedHeader = (x.getAllResponseHeaders() == headers);
+ } else if (x.readyState == XMLHttpRequest.DONE) {
+ doneState = headersReceivedState && true;
- doneHeader = (x.getAllResponseHeaders() == headers);
+ doneHeader = (x.getAllResponseHeaders() == headers);
dataOK = (x.responseText == "QML Rocks!\n");
}
}
Component.onCompleted: {
var x = new XMLHttpRequest;
- try {
- x.getResponseHeader("Test-Header");
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- unsentException = true;
- }
+ try {
+ x.getResponseHeader("Test-Header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ unsentException = true;
+ }
if (x.readyState == XMLHttpRequest.UNSENT)
readyState = true;
if (x.readyState == XMLHttpRequest.OPENED)
openedState = true;
- try {
- x.getResponseHeader("Test-Header");
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- openedException = true;
- }
+ try {
+ x.getResponseHeader("Test-Header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ openedException = true;
+ }
// Test to the end
x.onreadystatechange = function() {
- if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
- headersReceivedState = true;
-
- headersReceivedNullHeader = (x.getResponseHeader("Nonexistant-header") == "");
- headersReceivedValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue");
- headersReceivedMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue");
- headersReceivedCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == "");
- } else if (x.readyState == XMLHttpRequest.DONE) {
- doneState = headersReceivedState && true;
-
- doneNullHeader = (x.getResponseHeader("Nonexistant-header") == "");
- doneValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue");
- doneMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue");
- doneCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == "");
+ if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ headersReceivedState = true;
+
+ headersReceivedNullHeader = (x.getResponseHeader("Nonexistant-header") == "");
+ headersReceivedValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue");
+ headersReceivedMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue");
+ headersReceivedCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == "");
+ } else if (x.readyState == XMLHttpRequest.DONE) {
+ doneState = headersReceivedState && true;
+
+ doneNullHeader = (x.getResponseHeader("Nonexistant-header") == "");
+ doneValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue");
+ doneMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue");
+ doneCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == "");
dataOK = (x.responseText == "QML Rocks!\n");
}
}
-import QtQuick 2.0
+import QtQuick 2.0
QtObject {
property bool readyState: false
property bool dataOK: false
property bool done: false
-
+
Component.onCompleted: {
var x = new XMLHttpRequest;
x.open("GET", url);
property bool dataOK: false
property bool done: false
-
+
Component.onCompleted: {
var x = new XMLHttpRequest;
x.open("GET", url);
property bool dataOK: false
property bool done: false
-
+
Component.onCompleted: {
var x = new XMLHttpRequest;
x.open("GET", url);
x.send();
try {
- x.send()
+ x.send()
} catch (e) {
if (e.code == DOMException.INVALID_STATE_ERR)
test = true;
Component.onCompleted: {
var x = new XMLHttpRequest;
- try {
- var a = x.status;
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- unsentException = true;
- }
+ try {
+ var a = x.status;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ unsentException = true;
+ }
x.open("GET", url);
x.setRequestHeader("Accept-Language", "en-US");
- try {
- var a = x.status;
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- openedException = true;
- }
+ try {
+ var a = x.status;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ openedException = true;
+ }
// Test to the end
x.onreadystatechange = function() {
x.send()
- try {
- var a = x.status;
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- sentException = true;
- }
+ try {
+ var a = x.status;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ sentException = true;
+ }
}
}
Component.onCompleted: {
var x = new XMLHttpRequest;
- try {
- var a = x.statusText;
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- unsentException = true;
- }
+ try {
+ var a = x.statusText;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ unsentException = true;
+ }
x.open("GET", url);
x.setRequestHeader("Accept-Language", "en-US");
- try {
- var a = x.statusText;
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- openedException = true;
- }
+ try {
+ var a = x.statusText;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ openedException = true;
+ }
// Test to the end
x.onreadystatechange = function() {
x.send()
- try {
- var a = x.statusText;
- } catch (e) {
- if (e.code == DOMException.INVALID_STATE_ERR)
- sentException = true;
- }
+ try {
+ var a = x.statusText;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ sentException = true;
+ }
}
}
QCOMPARE(object->property("done").toInt(), 4);
}
-// Test calling constructor
+// Test calling constructor
void tst_qqmlxmlhttprequest::constructor()
{
QQmlComponent component(&engine, testFileUrl("constructor.qml"));
component.completeCreate();
QCOMPARE(object->property("test").toBool(), true);
-
+
QTRY_VERIFY(object->property("dataOK").toBool() == true);
}
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
QVERIFY(server.wait(testFileUrl("status.expect"),
- replyUrl,
+ replyUrl,
testFileUrl("testdocument.html")));
QQmlComponent component(&engine, testFileUrl("statusText.qml"));
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
QVERIFY(server.wait(testFileUrl("status.expect"),
- replyUrl,
+ replyUrl,
bodyUrl));
QQmlComponent component(&engine, testFileUrl("responseText.qml"));
QMetaObject::invokeMethod(object.data(), "startRequest");
QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
+
QCOMPARE(object->property("responseText").toString(), responseText);
if (!xmlRootNodeValue.isEmpty()) {
object->setProperty("expectedText", "");
component.completeCreate();
- for (int ii = 0; ii < 60; ++ii) {
- if (object->property("done").toBool()) break;
- QTest::qWait(50);
- }
+ for (int ii = 0; ii < 60; ++ii) {
+ if (object->property("done").toBool()) break;
+ QTest::qWait(50);
+ }
QVERIFY(object->property("done").toBool() == true);
QCOMPARE(object->property("dataOK").toBool(), true);
QCOMPARE(flm->property("showDotAndDotDot").toBool(), false);
QCOMPARE(flm->property("showOnlyReadable").toBool(), false);
QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml"));
- QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml"));
-
+ QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml"));
+
flm->setProperty("folder",QUrl::fromLocalFile(""));
QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(""));
}
waitForEchoMessage(worker);
QVariant result = qVariantFromValue(false);
- QVERIFY(QMetaObject::invokeMethod(worker, "compareLiteralResponse", Qt::DirectConnection,
+ QVERIFY(QMetaObject::invokeMethod(worker, "compareLiteralResponse", Qt::DirectConnection,
Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, jsObject)));
QVERIFY(result.toBool());
duration: 1000
}
}
- }
+ }
}
color: "lightsteelblue"
}
}
-
+
GridView {
id: grid
objectName: "grid"
id: delegate
Item {
id: wrapper
- width: 180; height: 40;
+ width: 180; height: 40;
Column {
x: 5; y: 5
Text { text: '<b>Name:</b> ' + name }
flow: GridView.LeftToRight
}
- data:[
+ data:[
ListModel {
id: listModel
ListElement {
}
]
}
-
-
+
+
import QtQuick 2.0
-Image {
+Image {
source: "heart.png"
fillMode: Image.PreserveAspectFit;
}
if (id == QLatin1String("no-such-file.png"))
return QImage();
- int width = 100;
+ int width = 100;
int height = 100;
QImage image(width, height, QImage::Format_RGB32);
- if (size)
+ if (size)
*size = QSize(width, height);
if (requestedSize.isValid())
image = image.scaled(requestedSize);
if (id == QLatin1String("no-such-file.png"))
return QPixmap();
- int width = 100;
+ int width = 100;
int height = 100;
QPixmap image(width, height);
- if (size)
+ if (size)
*size = QSize(width, height);
if (requestedSize.isValid())
image = image.scaled(requestedSize);
QString tst_qquickimageprovider::newImageFileName() const
{
// need to generate new filenames each time or else images are loaded
- // from cache and we won't get loading status changes when testing
+ // from cache and we won't get loading status changes when testing
// async loading
static int count = 0;
return QString("image://test/image-%1.png").arg(count++);
engine.addImageProvider("test", provider);
QVERIFY(engine.imageProvider("test") != 0);
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; "
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; "
+ (async ? "asynchronous: true; " : "")
+ properties + " }";
QQmlComponent component(&engine);
Repeater {
model: 1
- Rectangle { }
+ Rectangle { }
}
}
}
color: "lightsteelblue"
}
}
-
+
ListView {
id: list
objectName: "list"
id: delegate
Item {
id: wrapper
- width: 180; height: 40;
+ width: 180; height: 40;
Column {
x: 5; y: 5
Text { text: '<b>Name:</b> ' + name }
snapMode: ListView.SnapToItem
}
- data:[
+ data:[
ListModel {
id: listModel
ListElement {
}
]
}
-
-
+
+
{
if (!index.isValid())
return QVariant();
-
+
if (index.row() >= list.size() || index.row() < 0)
return QVariant();
-
+
if (role == Qt::DisplayRole)
return list.at(index.row());
return QVariant();
int itemsToFetch = qMin(5, remainder);
beginInsertRows(QModelIndex(), count, count+itemsToFetch-1);
-
+
count += itemsToFetch;
endInsertRows();
import QtQuick 2.0
Rectangle {
id: whiteRect
- width: 200
+ width: 200
height: 200
color: "white"
Rectangle {
import QtQuick 2.0
Rectangle {
id: whiteRect
- width: 200
+ width: 200
height: 200
color: "white"
Rectangle {
id: myDelegate
Item {
id: wrapper
- width: 180; height: 40;
+ width: 180; height: 40;
opacity: PathView.opacity
Column {
x: 5; y: 5
}
}
- data:[
+ data:[
ListModel {
id: listModel
ListElement {
import QtQuick 2.0
-Row {
- Repeater {
+Row {
+ Repeater {
objectName: "repeater"
model: 5
- Text {
- text: "I'm item " + index
- }
+ Text {
+ text: "I'm item " + index
+ }
}
}
const QChar tst_qquickstyledtext::square(0x25a1);
// For malformed input all we test is that we get the expected text and format out.
-//
+//
void tst_qquickstyledtext::textOutput_data()
{
QTest::addColumn<QString>("input");
import QtQuick 2.0
Rectangle { width: 300; height: 300; color: "white"
- resources: [
+ resources: [
Component { id:cursorFail; FailItem { objectName: "delegateFail" } },
Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } },
Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } },
Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } }
- ]
+ ]
TextEdit {
cursorDelegate: cursorFail
cursorVisible: true
import QtQuick 2.0
Rectangle { width: 300; height: 300; color: "white"
- resources: [
+ resources: [
Component { id:cursorFail; FailItem { objectName: "delegateFail" } },
Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } },
Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }
- ]
+ ]
TextEdit {
cursorDelegate: cursorFail
cursorVisible: true
import QtQuick 2.0
Rectangle { width: 300; height: 300; color: "white"
- resources: [
+ resources: [
Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } },
Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } },
Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } }
- ]
+ ]
TextEdit {
cursorDelegate: cursorWait
cursorVisible: true
import QtQuick 2.0
Rectangle { width: 300; height: 300; color: "white"
- resources: [
+ resources: [
Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } },
Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }
- ]
+ ]
TextEdit {
cursorDelegate: cursorWait
text: "Hello"
import QtQuick 2.0
-TextEdit {
+TextEdit {
text: "Hello world!"
inputMethodHints: Qt.ImhNoPredictiveText
}
width: 800; height: 600; color: "blue"
- Item {
+ Item {
id: firstItem;
KeyNavigation.right: input
}
text: "a"
}
Item {
- id: lastItem
+ id: lastItem
KeyNavigation.left: input
}
}
width: 800; height: 600; color: "blue"
- Item {
+ Item {
id: firstItem;
KeyNavigation.right: input
}
KeyNavigation.down: lastItem
}
Item {
- id: lastItem
+ id: lastItem
KeyNavigation.left: input
}
}
property bool acceptable: acceptableInput
}
}
-
+
}
QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create());
QVERIFY(model != 0);
-
+
QString xml;
-
+
xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
model->setProperty("xml",xml);
QTRY_COMPARE(model->rowCount(), 2);
QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
QAbstractItemModel *m1 = qobject_cast<QAbstractItemModel *>(component.create());
- QVERIFY(m1 != 0);
+ QVERIFY(m1 != 0);
QAbstractItemModel *m2 = qobject_cast<QAbstractItemModel *>(component.create());
- QVERIFY(m2 != 0);
+ QVERIFY(m2 != 0);
QAbstractItemModel *m3 = qobject_cast<QAbstractItemModel *>(component.create());
- QVERIFY(m3 != 0);
+ QVERIFY(m3 != 0);
for (int dataCount=0; dataCount<xmlDataCount; dataCount++) {
QFile expectFile(expect.toLocalFile());
if (!expectFile.open(QIODevice::ReadOnly)) return false;
-
+
QFile replyFile(reply.toLocalFile());
if (!replyFile.open(QIODevice::ReadOnly)) return false;
QByteArray total = dataCache[socket] + data;
dataCache[socket] = total;
-
+
if (total.contains("\n\r\n")) {
bool close = true;
}
dataCache.remove(socket);
- if (close)
+ if (close)
socket->disconnectFromHost();
}
}
import Test 1.0
-MyQmlObject {
+MyQmlObject {
result: ###
}
#include <QtCore/qobject.h>
-class TestObject : public QObject
+class TestObject : public QObject
{
Q_OBJECT
Q_PROPERTY(int intValue READ intValue);
private:
QString m_string;
-};
+};
void registerTypes();
last = elapsed;
}
QPainter p(this);
- p.fillRect(rect(), Qt::white);
- p.setPen(Qt::black);
+ p.fillRect(rect(), Qt::white);
+ p.setPen(Qt::black);
QTime drawTimer;
drawTimer.start();
testFunc(p);
QObject *o = m_component->create(&context);
QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
- if (m_willparent && go)
+ if (m_willparent && go)
go->setParentItem(&m_item);
delete o;
-
+
runTest(&context, iterations);
}
for (uint ii = 0; ii < iterations; ++ii) {
QObject *o = m_component->create(context);
QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
- if (m_willparent && go)
+ if (m_willparent && go)
go->setParentItem(&m_item);
delete o;
}
QT += qml widgets testlib
macx:CONFIG -= app_bundle
-SOURCES += qmltime.cpp
+SOURCES += qmltime.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
QT += qml testlib
macx:CONFIG -= app_bundle
-SOURCES += tst_qqmlmetaproperty.cpp
+SOURCES += tst_qqmlmetaproperty.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
var a = 1;
while (n > 0) {
a = a * n;
- n--;
+ n--;
}
return a;
}
help="Print summary after running tests")
result.add_option("--full-summary", default=False, action="store_true",
help="Print summary and test output after running tests")
- result.add_option("--strict_only", default=False, action="store_true",
+ result.add_option("--strict_only", default=False, action="store_true",
help="Test only strict mode")
- result.add_option("--non_strict_only", default=False, action="store_true",
+ result.add_option("--non_strict_only", default=False, action="store_true",
help="Test only non-strict mode")
result.add_option("--parallel", default=False, action="store_true",
help="Run tests in parallel")
help="Update test expectations fail when a test passes that was expected to fail")
# TODO: Once enough tests are made strict compat, change the default
# to "both"
- result.add_option("--unmarked_default", default="non_strict",
+ result.add_option("--unmarked_default", default="non_strict",
help="default mode for tests of unspecified strictness")
return result
del testRecord["header"]
del testRecord["commentary"]
self.testRecord = testRecord;
-
+
def GetName(self):
return path.join(*self.name)
parser = BuildOptions()
(options, args) = parser.parse_args()
ValidateOptions(options)
- test_suite = TestSuite(options.tests,
- options.strict_only,
+ test_suite = TestSuite(options.tests,
+ options.strict_only,
options.non_strict_only,
options.unmarked_default,
options.with_test_expectations)
tmp = tmp.replace(/\n/g, "<br />");
tmp = tmp.replace(/\t/g, "  ");
return tmp;
-
+
}
document.write("<div id='stdout'></div>");
} else // current.cdr == null
break;
}
-
+
res += ")";
return res;
}
return res;
}
-
+
function sc_dualAppend(l1, l2) {
if (l1 === null) return l2;
if (l2 === null) return l1;
if (c === "(")
return new sc_Token(14/*VECTOR_BEGIN*/);
-
+
if (c === "\\") { // character
var tmp = ""
while (!isWhitespaceOrEOF(port.peekChar()))
} else
return new sc_Token(13/*ERROR*/, "bad #-pattern5");
}
-
+
};
skipWhitespaceAndComments();
+ " " + par.type;
else
return sc_reverseAppendBang(res, cdr);
-
+
default:
res = sc_cons(this.read(), res);
case 2/*CLOSE_PAR*/:
tokenizer.readToken();
return a;
-
+
default:
a.push(this.read());
}
this.backref[nb] = tmp;
return tmp;
};
-
+
function readReference(nb) {
if (nb in this.backref)
return this.backref[nb];
/*!
Returns the maximum packet size allowed. By default this is
2,147,483,647 bytes.
-
+
If a packet claiming to be larger than the maximum packet size is received,
the QPacketProtocol::invalidPacket() signal is emitted.
{
}
-QQmlDebugClient::QQmlDebugClient(const QString &name,
+QQmlDebugClient::QQmlDebugClient(const QString &name,
QQmlDebugConnection *parent)
: QObject(parent),
d(new QQmlDebugClientPrivate)