OpenCoverage

qquickscalegrid.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickscalegrid.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qquickscalegrid_p_p.h"-
41-
42#include <QtQml/qqml.h>-
43-
44QT_BEGIN_NAMESPACE-
45-
46/*!-
47 \internal-
48 \class QQuickScaleGrid-
49 \brief The QQuickScaleGrid class allows you to specify a 3x3 grid to use in scaling an image.-
50*/-
51-
52QQuickScaleGrid::QQuickScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0)-
53{-
54}
executed 100 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
100
55-
56QQuickScaleGrid::~QQuickScaleGrid()-
57{-
58}-
59-
60bool QQuickScaleGrid::isNull() const-
61{-
62 return !_left && !_top && !_right && !_bottom;
never executed: return !_left && !_top && !_right && !_bottom;
0
63}-
64-
65void QQuickScaleGrid::setLeft(int pos)-
66{-
67 if (_left != pos) {
_left != posDescription
TRUEevaluated 98 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
2-98
68 _left = pos;-
69 emit leftBorderChanged();-
70 emit borderChanged();-
71 }
executed 98 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
98
72}
executed 100 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
100
73-
74void QQuickScaleGrid::setTop(int pos)-
75{-
76 if (_top != pos) {
_top != posDescription
TRUEevaluated 94 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEnever evaluated
0-94
77 _top = pos;-
78 emit topBorderChanged();-
79 emit borderChanged();-
80 }
executed 94 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
94
81}
executed 94 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
94
82-
83void QQuickScaleGrid::setRight(int pos)-
84{-
85 if (_right != pos) {
_right != posDescription
TRUEevaluated 98 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
2-98
86 _right = pos;-
87 emit rightBorderChanged();-
88 emit borderChanged();-
89 }
executed 98 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
98
90}
executed 100 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
100
91-
92void QQuickScaleGrid::setBottom(int pos)-
93{-
94 if (_bottom != pos) {
_bottom != posDescription
TRUEevaluated 94 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEnever evaluated
0-94
95 _bottom = pos;-
96 emit bottomBorderChanged();-
97 emit borderChanged();-
98 }
executed 94 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
94
99}
executed 94 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
94
100-
101QQuickGridScaledImage::QQuickGridScaledImage()-
102: _l(-1), _r(-1), _t(-1), _b(-1),-
103 _h(QQuickBorderImage::Stretch), _v(QQuickBorderImage::Stretch)-
104{-
105}
never executed: end of block
0
106-
107QQuickGridScaledImage::QQuickGridScaledImage(const QQuickGridScaledImage &o)-
108: _l(o._l), _r(o._r), _t(o._t), _b(o._b), _h(o._h), _v(o._v), _pix(o._pix)-
109{-
110}
never executed: end of block
0
111-
112QQuickGridScaledImage &QQuickGridScaledImage::operator=(const QQuickGridScaledImage &o)-
113{-
114 _l = o._l;-
115 _r = o._r;-
116 _t = o._t;-
117 _b = o._b;-
118 _h = o._h;-
119 _v = o._v;-
120 _pix = o._pix;-
121 return *this;
never executed: return *this;
0
122}-
123-
124QQuickGridScaledImage::QQuickGridScaledImage(QIODevice *data)-
125: _l(-1), _r(-1), _t(-1), _b(-1), _h(QQuickBorderImage::Stretch), _v(QQuickBorderImage::Stretch)-
126{-
127 int l = -1;-
128 int r = -1;-
129 int t = -1;-
130 int b = -1;-
131 QString imgFile;-
132-
133 QByteArray raw;-
134 while (raw = data->readLine(), !raw.isEmpty()) {
raw = data->re...!raw.isEmpty()Description
TRUEevaluated 160 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
26-160
135 QString line = QString::fromUtf8(raw.trimmed());-
136 if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
line.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 160 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
line.startsWit...tin1Char('#'))Description
TRUEnever evaluated
FALSEevaluated 160 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-160
137 continue;
never executed: continue;
0
138-
139 int colonId = line.indexOf(QLatin1Char(':'));-
140 if (colonId <= 0)
colonId <= 0Description
TRUEnever evaluated
FALSEevaluated 160 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-160
141 return;
never executed: return;
0
142-
143 const QStringRef property = line.leftRef(colonId).trimmed();-
144 QStringRef value = line.midRef(colonId + 1).trimmed();-
145-
146 if (property == QLatin1String("border.left")) {
property == QL..."border.left")Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 136 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
24-136
147 l = value.toInt();-
148 } else if (property == QLatin1String("border.right")) {
executed 24 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
property == QL...border.right")Description
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 114 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
22-114
149 r = value.toInt();-
150 } else if (property == QLatin1String("border.top")) {
executed 22 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
property == QL...("border.top")Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 90 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
22-90
151 t = value.toInt();-
152 } else if (property == QLatin1String("border.bottom")) {
executed 24 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
property == QL...order.bottom")Description
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 68 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
22-68
153 b = value.toInt();-
154 } else if (property == QLatin1String("source")) {
executed 22 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
property == QL...ring("source")Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickborderimage
22-44
155 if (value.startsWith(QLatin1Char('"')) && value.endsWith(QLatin1Char('"')))
value.startsWi...tin1Char('"'))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 20 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
value.endsWith...tin1Char('"'))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEnever evaluated
0-20
156 value = value.mid(1, value.size() - 2); // remove leading/trailing quotes.
executed 4 times by 1 test: value = value.mid(1, value.size() - 2);
Executed by:
  • tst_qquickborderimage
4
157 imgFile = value.toString();-
158 } else if (property == QLatin1String("horizontalTileRule") || property == QLatin1String("horizontalTileMode")) {
executed 24 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
property == QL...ntalTileRule")Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickborderimage
property == QL...ntalTileMode")Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickborderimage
8-32
159 _h = stringToRule(value);-
160 } else if (property == QLatin1String("verticalTileRule") || property == QLatin1String("verticalTileMode")) {
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickborderimage
property == QL...icalTileRule")Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickborderimage
property == QL...icalTileMode")Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickborderimage
4-20
161 _v = stringToRule(value);-
162 }
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickborderimage
20
163 }
executed 160 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
160
164-
165 if (l < 0 || r < 0 || t < 0 || b < 0 || imgFile.isEmpty())
l < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
r < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
t < 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
b < 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
imgFile.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-24
166 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickborderimage
4
167-
168 _l = l; _r = r; _t = t; _b = b;-
169 _pix = imgFile;-
170}
executed 22 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
22
171-
172QQuickBorderImage::TileMode QQuickGridScaledImage::stringToRule(const QStringRef &s)-
173{-
174 QStringRef string = s;-
175 if (string.startsWith(QLatin1Char('"')) && string.endsWith(QLatin1Char('"')))
string.startsW...tin1Char('"'))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickborderimage
string.endsWit...tin1Char('"'))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEnever evaluated
0-32
176 string = string.mid(1, string.size() - 2); // remove leading/trailing quotes.
executed 8 times by 1 test: string = string.mid(1, string.size() - 2);
Executed by:
  • tst_qquickborderimage
8
177-
178 if (string == QLatin1String("Stretch") || string == QLatin1String("BorderImage.Stretch"))
string == QLat...ing("Stretch")Description
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquickborderimage
string == QLat...mage.Stretch")Description
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquickborderimage
0-40
179 return QQuickBorderImage::Stretch;
never executed: return QQuickBorderImage::Stretch;
0
180 if (string == QLatin1String("Repeat") || string == QLatin1String("BorderImage.Repeat"))
string == QLat...ring("Repeat")Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquickborderimage
string == QLat...Image.Repeat")Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickborderimage
4-26
181 return QQuickBorderImage::Repeat;
executed 18 times by 1 test: return QQuickBorderImage::Repeat;
Executed by:
  • tst_qquickborderimage
18
182 if (string == QLatin1String("Round") || string == QLatin1String("BorderImage.Round"))
string == QLat...tring("Round")Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickborderimage
string == QLat...rImage.Round")Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickborderimage
4-14
183 return QQuickBorderImage::Round;
executed 18 times by 1 test: return QQuickBorderImage::Round;
Executed by:
  • tst_qquickborderimage
18
184-
185 qWarning("QQuickGridScaledImage: Invalid tile rule specified. Using Stretch.");-
186 return QQuickBorderImage::Stretch;
executed 4 times by 1 test: return QQuickBorderImage::Stretch;
Executed by:
  • tst_qquickborderimage
4
187}-
188-
189bool QQuickGridScaledImage::isValid() const-
190{-
191 return _l >= 0;
executed 26 times by 2 tests: return _l >= 0;
Executed by:
  • tst_examples
  • tst_qquickborderimage
26
192}-
193-
194int QQuickGridScaledImage::gridLeft() const-
195{-
196 return _l;
executed 22 times by 2 tests: return _l;
Executed by:
  • tst_examples
  • tst_qquickborderimage
22
197}-
198-
199int QQuickGridScaledImage::gridRight() const-
200{-
201 return _r;
executed 22 times by 2 tests: return _r;
Executed by:
  • tst_examples
  • tst_qquickborderimage
22
202}-
203-
204int QQuickGridScaledImage::gridTop() const-
205{-
206 return _t;
executed 22 times by 2 tests: return _t;
Executed by:
  • tst_examples
  • tst_qquickborderimage
22
207}-
208-
209int QQuickGridScaledImage::gridBottom() const-
210{-
211 return _b;
executed 22 times by 2 tests: return _b;
Executed by:
  • tst_examples
  • tst_qquickborderimage
22
212}-
213-
214QString QQuickGridScaledImage::pixmapUrl() const-
215{-
216 return _pix;
executed 22 times by 2 tests: return _pix;
Executed by:
  • tst_examples
  • tst_qquickborderimage
22
217}-
218-
219QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0