/usr/share/qt5/doc/qtqml/qtqml-dynamicscene-content-itemcreation-js.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>itemCreation.js Example File | Qt QML 5.5</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.5</li>
<li><a href="qtqml-index.html">Qt QML</a></li>
<li><a href="qtqml-dynamicscene-example.html">QML Example - Dynamic Scene</a></li>
<li>itemCreation.js Example File</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">itemCreation.js Example File</h1>
<span class="subtitle">dynamicscene/content/itemCreation.js</span>
<!-- $$$dynamicscene/content/itemCreation.js-description -->
<div class="descr"> <a name="details"></a>
<pre class="js">var <span class="name">itemComponent</span> = <span class="number">null</span>;
var <span class="name">draggedItem</span> = <span class="number">null</span>;
var <span class="name">startingMouse</span>;
var <span class="name">posnInWindow</span>;
<span class="keyword">function</span> <span class="name">startDrag</span>(<span class="name">mouse</span>)
{
<span class="name">posnInWindow</span> <span class="operator">=</span> <span class="name">paletteItem</span>.<span class="name">mapToItem</span>(<span class="name">window</span>, <span class="number">0</span>, <span class="number">0</span>);
<span class="name">startingMouse</span> <span class="operator">=</span> { x: <span class="name">mouse</span>.<span class="name">x</span>, y: <span class="name">mouse</span>.<span class="name">y</span> }
<span class="name">loadComponent</span>();
}
<span class="comment">//Creation is split into two functions due to an asynchronous wait while</span>
<span class="comment">//possible external files are loaded.</span>
<span class="keyword">function</span> <span class="name">loadComponent</span>() {
<span class="keyword">if</span> (<span class="name">itemComponent</span> <span class="operator">!=</span> <span class="number">null</span>) { <span class="comment">// component has been previously loaded</span>
<span class="name">createItem</span>();
<span class="keyword">return</span>;
}
<span class="name">itemComponent</span> <span class="operator">=</span> <span class="name">Qt</span>.<span class="name">createComponent</span>(<span class="name">paletteItem</span>.<span class="name">componentFile</span>);
<span class="keyword">if</span> (<span class="name">itemComponent</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Component</span>.<span class="name">Loading</span>) <span class="comment">//Depending on the content, it can be ready or error immediately</span>
<span class="name">component</span>.<span class="name">statusChanged</span>.<span class="name">connect</span>(<span class="name">createItem</span>);
<span class="keyword">else</span>
<span class="name">createItem</span>();
}
<span class="keyword">function</span> <span class="name">createItem</span>() {
<span class="keyword">if</span> (<span class="name">itemComponent</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Component</span>.<span class="name">Ready</span> <span class="operator">&&</span> <span class="name">draggedItem</span> <span class="operator">==</span> <span class="number">null</span>) {
<span class="name">draggedItem</span> <span class="operator">=</span> <span class="name">itemComponent</span>.<span class="name">createObject</span>(<span class="name">window</span>, {"image": <span class="name">paletteItem</span>.<span class="name">image</span>, "x": <span class="name">posnInWindow</span>.<span class="name">x</span>, "y": <span class="name">posnInWindow</span>.<span class="name">y</span>, "z": <span class="number">3</span>});
<span class="comment">// make sure created item is above the ground layer</span>
} <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">itemComponent</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Component</span>.<span class="name">Error</span>) {
<span class="name">draggedItem</span> <span class="operator">=</span> <span class="number">null</span>;
<span class="name">console</span>.<span class="name">log</span>(<span class="string">"error creating component"</span>);
<span class="name">console</span>.<span class="name">log</span>(<span class="name">itemComponent</span>.<span class="name">errorString</span>());
}
}
<span class="keyword">function</span> <span class="name">continueDrag</span>(<span class="name">mouse</span>)
{
<span class="keyword">if</span> (<span class="name">draggedItem</span> <span class="operator">==</span> <span class="number">null</span>)
<span class="keyword">return</span>;
<span class="name">draggedItem</span>.<span class="name">x</span> <span class="operator">=</span> <span class="name">mouse</span>.<span class="name">x</span> <span class="operator">+</span> <span class="name">posnInWindow</span>.<span class="name">x</span> <span class="operator">-</span> <span class="name">startingMouse</span>.<span class="name">x</span>;
<span class="name">draggedItem</span>.<span class="name">y</span> <span class="operator">=</span> <span class="name">mouse</span>.<span class="name">y</span> <span class="operator">+</span> <span class="name">posnInWindow</span>.<span class="name">y</span> <span class="operator">-</span> <span class="name">startingMouse</span>.<span class="name">y</span>;
}
<span class="keyword">function</span> <span class="name">endDrag</span>(<span class="name">mouse</span>)
{
<span class="keyword">if</span> (<span class="name">draggedItem</span> <span class="operator">==</span> <span class="number">null</span>)
<span class="keyword">return</span>;
<span class="keyword">if</span> (<span class="name">draggedItem</span>.<span class="name">y</span> <span class="operator"><</span> <span class="name">toolbox</span>.<span class="name">height</span>) { <span class="comment">//Don't drop it in the toolbox</span>
<span class="name">draggedItem</span>.<span class="name">destroy</span>();
<span class="name">draggedItem</span> <span class="operator">=</span> <span class="number">null</span>;
} <span class="keyword">else</span> {
<span class="name">draggedItem</span>.<span class="name">created</span> <span class="operator">=</span> <span class="number">true</span>;
<span class="name">draggedItem</span> <span class="operator">=</span> <span class="number">null</span>;
}
}</pre>
</div>
<!-- @@@dynamicscene/content/itemCreation.js -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|