This file is indexed.

/usr/share/qt5/doc/qtquick/qtquick-demos-stocqt-example.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- stocqt.qdoc -->
  <title>Qt Quick Demo - StocQt | Qt Quick 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="qtquick-index.html">Qt Quick</a></li>
<li>Qt Quick Demo - StocQt</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="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#running-the-example">Running the Example</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Quick Demo - StocQt</h1>
<span class="subtitle"></span>
<!-- $$$demos/stocqt-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/qtquick-demo-stocqt.png" alt="" /></p><p>The <i>StocQt</i> application presents a trend chart for the first stock in the list of NASDAQ-100 stocks maintained by it. It allows the user to choose another stock from the list, and fetches the required data for the selected stock by sending an <code>XMLHttpRequest</code> to http://finance.yahoo.com.</p>
<p>The application uses several custom types such as Button, CheckBox, StockChart, StockInfo, StockView, and so on. These types are used to present the stock data in a readable form and also let the user customize the trend chart. For example, the user can choose to view the yearly, monthly, or daily trends in the stock price.</p>
<p>The application uses the <a href="qtquick-views-example.html#objectmodel">ObjectModel</a> type to access the two visual data models that it depends on.</p>
<pre class="qml">    <span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
        <span class="name">id</span>: <span class="name">root</span>
        ...
        <span class="name">model</span>: <span class="name">ObjectModel</span> {
            <span class="type">StockListView</span> {
                <span class="name">id</span>: <span class="name">listView</span>
                <span class="name">width</span>: <span class="name">root</span>.<span class="name">width</span>
                <span class="name">height</span>: <span class="name">root</span>.<span class="name">height</span>
            }

            <span class="type">StockView</span> {
                <span class="name">id</span>: <span class="name">stockView</span>
                <span class="name">width</span>: <span class="name">root</span>.<span class="name">width</span>
                <span class="name">height</span>: <span class="name">root</span>.<span class="name">height</span>
                <span class="name">stocklist</span>: <span class="name">listView</span>
                <span class="name">stock</span>: <span class="name">stock</span>
            }
        }
    }</pre>
<p>The StockListView model is a static data model listing the NASDAQ-100 stocks with basic information such as stockId, name, value, change, and so on. This data model is used by the application if the user wants to choose another stock from the list.</p>
<p>StockView is a complex data model that presents a trend chart for the selected stock. It uses another custom type, StockChart, which presents the graphical trend of the stock price using a Canvas. This data model is used for most of the time during the lifetime of the application.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
    <span class="name">id</span>: <span class="name">chart</span>
    <span class="name">width</span>: <span class="number">320</span>
    <span class="name">height</span>: <span class="number">200</span>

    ...
    <span class="type"><a href="qml-qtquick-canvas.html">Canvas</a></span> {
        <span class="name">id</span>: <span class="name">canvas</span>

        ...
        <span class="name">onPaint</span>: {
            <span class="keyword">if</span> (!<span class="name">stockModel</span>.<span class="name">ready</span>) {
                <span class="keyword">return</span>;
            }

            <span class="name">numPoints</span> <span class="operator">=</span> <span class="name">stockModel</span>.<span class="name">indexOf</span>(<span class="name">chart</span>.<span class="name">startDate</span>);

            <span class="keyword">if</span> (<span class="name">chart</span>.<span class="name">gridSize</span> <span class="operator">==</span> <span class="number">0</span>)
                <span class="name">chart</span>.<span class="name">gridSize</span> <span class="operator">=</span> <span class="name">numPoints</span>

            var <span class="name">ctx</span> = <span class="name">canvas</span>.<span class="name">getContext</span>(<span class="string">&quot;2d&quot;</span>);
            <span class="name">ctx</span>.<span class="name">globalCompositeOperation</span> <span class="operator">=</span> <span class="string">&quot;source-over&quot;</span>;
            <span class="name">ctx</span>.<span class="name">lineWidth</span> <span class="operator">=</span> <span class="number">1</span>;

            <span class="name">drawBackground</span>(<span class="name">ctx</span>);

            var <span class="name">highestPrice</span> = <span class="number">0</span>;
            var <span class="name">highestVolume</span> = <span class="number">0</span>;
            var <span class="name">lowestPrice</span> = -<span class="number">1</span>;
            var <span class="name">points</span> = [];
            <span class="keyword">for</span> (<span class="keyword">var</span> <span class="name">i</span> = <span class="name">numPoints</span>, <span class="name">j</span> = <span class="number">0</span>; <span class="name">i</span> <span class="operator">&gt;=</span> <span class="number">0</span> ; <span class="name">i</span> <span class="operator">-=</span> <span class="name">pixelSkip</span>, <span class="name">j</span> <span class="operator">+=</span> <span class="name">pixelSkip</span>) {
                var <span class="name">price</span> = <span class="name">stockModel</span>.<span class="name">get</span>(<span class="name">i</span>);
                <span class="keyword">if</span> (<span class="name">parseFloat</span>(<span class="name">highestPrice</span>) <span class="operator">&lt;</span> <span class="name">parseFloat</span>(<span class="name">price</span>.<span class="name">high</span>))
                    <span class="name">highestPrice</span> <span class="operator">=</span> <span class="name">price</span>.<span class="name">high</span>;
                <span class="keyword">if</span> (<span class="name">parseInt</span>(<span class="name">highestVolume</span>, <span class="number">10</span>) <span class="operator">&lt;</span> <span class="name">parseInt</span>(<span class="name">price</span>.<span class="name">volume</span>, <span class="number">10</span>))
                    <span class="name">highestVolume</span> <span class="operator">=</span> <span class="name">price</span>.<span class="name">volume</span>;
                <span class="keyword">if</span> (<span class="name">lowestPrice</span> <span class="operator">&lt;</span> <span class="number">0</span> <span class="operator">||</span> <span class="name">parseFloat</span>(<span class="name">lowestPrice</span>) <span class="operator">&gt;</span> <span class="name">parseFloat</span>(<span class="name">price</span>.<span class="name">low</span>))
                    <span class="name">lowestPrice</span> <span class="operator">=</span> <span class="name">price</span>.<span class="name">low</span>;
                <span class="name">points</span>.<span class="name">push</span>({
                                x: <span class="name">j</span> <span class="operator">*</span> <span class="name">xGridStep</span>,
                                open: <span class="name">price</span>.<span class="name">open</span>,
                                close: <span class="name">price</span>.<span class="name">close</span>,
                                high: <span class="name">price</span>.<span class="name">high</span>,
                                low: <span class="name">price</span>.<span class="name">low</span>,
                                volume: <span class="name">price</span>.<span class="name">volume</span>
                            });
            }

            <span class="keyword">if</span> (<span class="name">settings</span>.<span class="name">drawHighPrice</span>)
                <span class="name">drawPrice</span>(<span class="name">ctx</span>, <span class="number">0</span>, <span class="name">numPoints</span>, <span class="name">settings</span>.<span class="name">highColor</span>, <span class="string">&quot;high&quot;</span>, <span class="name">points</span>, <span class="name">highestPrice</span>, <span class="name">lowestPrice</span>);
            <span class="keyword">if</span> (<span class="name">settings</span>.<span class="name">drawLowPrice</span>)
                <span class="name">drawPrice</span>(<span class="name">ctx</span>, <span class="number">0</span>, <span class="name">numPoints</span>, <span class="name">settings</span>.<span class="name">lowColor</span>, <span class="string">&quot;low&quot;</span>, <span class="name">points</span>, <span class="name">highestPrice</span>, <span class="name">lowestPrice</span>);
            <span class="keyword">if</span> (<span class="name">settings</span>.<span class="name">drawOpenPrice</span>)
                <span class="name">drawPrice</span>(<span class="name">ctx</span>, <span class="number">0</span>, <span class="name">numPoints</span>,<span class="name">settings</span>.<span class="name">openColor</span>, <span class="string">&quot;open&quot;</span>, <span class="name">points</span>, <span class="name">highestPrice</span>, <span class="name">lowestPrice</span>);
            <span class="keyword">if</span> (<span class="name">settings</span>.<span class="name">drawClosePrice</span>)
                <span class="name">drawPrice</span>(<span class="name">ctx</span>, <span class="number">0</span>, <span class="name">numPoints</span>, <span class="name">settings</span>.<span class="name">closeColor</span>, <span class="string">&quot;close&quot;</span>, <span class="name">points</span>, <span class="name">highestPrice</span>, <span class="name">lowestPrice</span>);

            <span class="name">drawVolume</span>(<span class="name">ctx</span>, <span class="number">0</span>, <span class="name">numPoints</span>, <span class="name">settings</span>.<span class="name">volumeColor</span>, <span class="string">&quot;volume&quot;</span>, <span class="name">points</span>, <span class="name">highestVolume</span>);
            <span class="name">drawScales</span>(<span class="name">ctx</span>, <span class="name">highestPrice</span>, <span class="name">lowestPrice</span>, <span class="name">highestVolume</span>);
        }
    }
}</pre>
<p>To understand the application better, browse through its code using Qt Creator.</p>
<a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<p>Files:</p>
<ul>
<li><a href="qtquick-demos-stocqt-stocqt-qml.html">demos/stocqt/stocqt.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-button-qml.html">demos/stocqt/content/Button.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-checkbox-qml.html">demos/stocqt/content/CheckBox.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-stockchart-qml.html">demos/stocqt/content/StockChart.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-stockinfo-qml.html">demos/stocqt/content/StockInfo.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-stocklistmodel-qml.html">demos/stocqt/content/StockListModel.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-stocklistview-qml.html">demos/stocqt/content/StockListView.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-stockmodel-qml.html">demos/stocqt/content/StockModel.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-stocksettingspanel-qml.html">demos/stocqt/content/StockSettingsPanel.qml</a></li>
<li><a href="qtquick-demos-stocqt-content-stockview-qml.html">demos/stocqt/content/StockView.qml</a></li>
<li><a href="qtquick-demos-stocqt-main-cpp.html">demos/stocqt/main.cpp</a></li>
<li><a href="qtquick-demos-stocqt-stocqt-pro.html">demos/stocqt/stocqt.pro</a></li>
<li><a href="qtquick-demos-stocqt-stocqt-qmlproject.html">demos/stocqt/stocqt.qmlproject</a></li>
<li><a href="qtquick-demos-stocqt-stocqt-qrc.html">demos/stocqt/stocqt.qrc</a></li>
</ul>
</div>
<p><b>See also </b>QML Applications.</p>
<!-- @@@demos/stocqt -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</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>