Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui 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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qcolordialog_p.h" | - |
43 | | - |
44 | #ifndef QT_NO_COLORDIALOG | - |
45 | | - |
46 | #include "qapplication.h" | - |
47 | #include "qdesktopwidget.h" | - |
48 | #include "qdrawutil.h" | - |
49 | #include "qevent.h" | - |
50 | #include "qimage.h" | - |
51 | #include "qdrag.h" | - |
52 | #include "qlabel.h" | - |
53 | #include "qlayout.h" | - |
54 | #include "qlineedit.h" | - |
55 | #include "qmenu.h" | - |
56 | #include "qpainter.h" | - |
57 | #include "qpixmap.h" | - |
58 | #include "qpushbutton.h" | - |
59 | #include "qsettings.h" | - |
60 | #include "qstyle.h" | - |
61 | #include "qstyleoption.h" | - |
62 | #include "qvalidator.h" | - |
63 | #include "qmimedata.h" | - |
64 | #include "qspinbox.h" | - |
65 | #include "qdialogbuttonbox.h" | - |
66 | | - |
67 | QT_BEGIN_NAMESPACE | - |
68 | | - |
69 | //////////// QWellArray BEGIN | - |
70 | | - |
71 | struct QWellArrayData; | - |
72 | | - |
73 | class QWellArray : public QWidget | - |
74 | { | - |
75 | Q_OBJECT | - |
76 | Q_PROPERTY(int selectedColumn READ selectedColumn) | - |
77 | Q_PROPERTY(int selectedRow READ selectedRow) | - |
78 | | - |
79 | public: | - |
80 | QWellArray(int rows, int cols, QWidget* parent=0); | - |
81 | ~QWellArray() {} | - |
82 | QString cellContent(int row, int col) const; | - |
83 | | - |
84 | int selectedColumn() const { return selCol; } never executed: return selCol; | 0 |
85 | int selectedRow() const { return selRow; } never executed: return selRow; | 0 |
86 | | - |
87 | virtual void setCurrent(int row, int col); | - |
88 | virtual void setSelected(int row, int col); | - |
89 | | - |
90 | QSize sizeHint() const; | - |
91 | | - |
92 | virtual void setCellBrush(int row, int col, const QBrush &); | - |
93 | QBrush cellBrush(int row, int col); | - |
94 | | - |
95 | inline int cellWidth() const | - |
96 | { return cellw; } executed: return cellw; Execution Count:6 | 6 |
97 | | - |
98 | inline int cellHeight() const | - |
99 | { return cellh; } executed: return cellh; Execution Count:6 | 6 |
100 | | - |
101 | inline int rowAt(int y) const | - |
102 | { return y / cellh; } executed: return y / cellh; Execution Count:12 | 12 |
103 | | - |
104 | inline int columnAt(int x) const | - |
105 | { if (isRightToLeft()) return ncols - (x / cellw) - 1; return x / cellw; } never executed: return ncols - (x / cellw) - 1; executed: return x / cellw; Execution Count:12 partially evaluated: isRightToLeft() no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
106 | | - |
107 | inline int rowY(int row) const | - |
108 | { return cellh * row; } executed: return cellh * row; Execution Count:35 | 35 |
109 | | - |
110 | inline int columnX(int column) const | - |
111 | { if (isRightToLeft()) return cellw * (ncols - column - 1); return cellw * column; } never executed: return cellw * (ncols - column - 1); executed: return cellw * column; Execution Count:147 partially evaluated: isRightToLeft() no Evaluation Count:0 | yes Evaluation Count:147 |
| 0-147 |
112 | | - |
113 | inline int numRows() const | - |
114 | { return nrows; } executed: return nrows; Execution Count:130 | 130 |
115 | | - |
116 | inline int numCols() const | - |
117 | {return ncols; } never executed: return ncols; | 0 |
118 | | - |
119 | inline QRect cellRect() const | - |
120 | { return QRect(0, 0, cellw, cellh); } never executed: return QRect(0, 0, cellw, cellh); | 0 |
121 | | - |
122 | inline QSize gridSize() const | - |
123 | { return QSize(ncols * cellw, nrows * cellh); } executed: return QSize(ncols * cellw, nrows * cellh); Execution Count:4 | 4 |
124 | | - |
125 | QRect cellGeometry(int row, int column) | - |
126 | { | - |
127 | QRect r; executed (the execution status of this line is deduced): QRect r; | - |
128 | if (row >= 0 && row < nrows && column >= 0 && column < ncols) evaluated: row >= 0 yes Evaluation Count:17 | yes Evaluation Count:19 |
partially evaluated: row < nrows yes Evaluation Count:17 | no Evaluation Count:0 |
partially evaluated: column >= 0 yes Evaluation Count:17 | no Evaluation Count:0 |
partially evaluated: column < ncols yes Evaluation Count:17 | no Evaluation Count:0 |
| 0-19 |
129 | r.setRect(columnX(column), rowY(row), cellw, cellh); executed: r.setRect(columnX(column), rowY(row), cellw, cellh); Execution Count:17 | 17 |
130 | return r; executed: return r; Execution Count:36 | 36 |
131 | } | - |
132 | | - |
133 | inline void updateCell(int row, int column) { update(cellGeometry(row, column)); } executed: } Execution Count:36 | 36 |
134 | | - |
135 | signals: | - |
136 | void selected(int row, int col); | - |
137 | | - |
138 | protected: | - |
139 | virtual void paintCell(QPainter *, int row, int col, const QRect&); | - |
140 | virtual void paintCellContents(QPainter *, int row, int col, const QRect&); | - |
141 | | - |
142 | void mousePressEvent(QMouseEvent*); | - |
143 | void mouseReleaseEvent(QMouseEvent*); | - |
144 | void keyPressEvent(QKeyEvent*); | - |
145 | void focusInEvent(QFocusEvent*); | - |
146 | void focusOutEvent(QFocusEvent*); | - |
147 | void paintEvent(QPaintEvent *); | - |
148 | | - |
149 | private: | - |
150 | Q_DISABLE_COPY(QWellArray) | - |
151 | | - |
152 | int nrows; | - |
153 | int ncols; | - |
154 | int cellw; | - |
155 | int cellh; | - |
156 | int curRow; | - |
157 | int curCol; | - |
158 | int selRow; | - |
159 | int selCol; | - |
160 | QWellArrayData *d; | - |
161 | }; | - |
162 | | - |
163 | void QWellArray::paintEvent(QPaintEvent *e) | - |
164 | { | - |
165 | QRect r = e->rect(); executed (the execution status of this line is deduced): QRect r = e->rect(); | - |
166 | int cx = r.x(); executed (the execution status of this line is deduced): int cx = r.x(); | - |
167 | int cy = r.y(); executed (the execution status of this line is deduced): int cy = r.y(); | - |
168 | int ch = r.height(); executed (the execution status of this line is deduced): int ch = r.height(); | - |
169 | int cw = r.width(); executed (the execution status of this line is deduced): int cw = r.width(); | - |
170 | int colfirst = columnAt(cx); executed (the execution status of this line is deduced): int colfirst = columnAt(cx); | - |
171 | int collast = columnAt(cx + cw); executed (the execution status of this line is deduced): int collast = columnAt(cx + cw); | - |
172 | int rowfirst = rowAt(cy); executed (the execution status of this line is deduced): int rowfirst = rowAt(cy); | - |
173 | int rowlast = rowAt(cy + ch); executed (the execution status of this line is deduced): int rowlast = rowAt(cy + ch); | - |
174 | | - |
175 | if (isRightToLeft()) { partially evaluated: isRightToLeft() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
176 | int t = colfirst; never executed (the execution status of this line is deduced): int t = colfirst; | - |
177 | colfirst = collast; never executed (the execution status of this line is deduced): colfirst = collast; | - |
178 | collast = t; never executed (the execution status of this line is deduced): collast = t; | - |
179 | } | 0 |
180 | | - |
181 | QPainter painter(this); executed (the execution status of this line is deduced): QPainter painter(this); | - |
182 | QPainter *p = &painter; executed (the execution status of this line is deduced): QPainter *p = &painter; | - |
183 | QRect rect(0, 0, cellWidth(), cellHeight()); executed (the execution status of this line is deduced): QRect rect(0, 0, cellWidth(), cellHeight()); | - |
184 | | - |
185 | | - |
186 | if (collast < 0 || collast >= ncols) partially evaluated: collast < 0 no Evaluation Count:0 | yes Evaluation Count:6 |
partially evaluated: collast >= ncols yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
187 | collast = ncols-1; executed: collast = ncols-1; Execution Count:6 | 6 |
188 | if (rowlast < 0 || rowlast >= nrows) partially evaluated: rowlast < 0 no Evaluation Count:0 | yes Evaluation Count:6 |
partially evaluated: rowlast >= nrows yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
189 | rowlast = nrows-1; executed: rowlast = nrows-1; Execution Count:6 | 6 |
190 | | - |
191 | // Go through the rows | - |
192 | for (int r = rowfirst; r <= rowlast; ++r) { evaluated: r <= rowlast yes Evaluation Count:18 | yes Evaluation Count:6 |
| 6-18 |
193 | // get row position and height | - |
194 | int rowp = rowY(r); executed (the execution status of this line is deduced): int rowp = rowY(r); | - |
195 | | - |
196 | // Go through the columns in the row r | - |
197 | // if we know from where to where, go through [colfirst, collast], | - |
198 | // else go through all of them | - |
199 | for (int c = colfirst; c <= collast; ++c) { evaluated: c <= collast yes Evaluation Count:130 | yes Evaluation Count:18 |
| 18-130 |
200 | // get position and width of column c | - |
201 | int colp = columnX(c); executed (the execution status of this line is deduced): int colp = columnX(c); | - |
202 | // Translate painter and draw the cell | - |
203 | rect.translate(colp, rowp); executed (the execution status of this line is deduced): rect.translate(colp, rowp); | - |
204 | paintCell(p, r, c, rect); executed (the execution status of this line is deduced): paintCell(p, r, c, rect); | - |
205 | rect.translate(-colp, -rowp); executed (the execution status of this line is deduced): rect.translate(-colp, -rowp); | - |
206 | } executed: } Execution Count:130 | 130 |
207 | } executed: } Execution Count:18 | 18 |
208 | } executed: } Execution Count:6 | 6 |
209 | | - |
210 | struct QWellArrayData { | - |
211 | QBrush *brush; | - |
212 | }; | - |
213 | | - |
214 | QWellArray::QWellArray(int rows, int cols, QWidget *parent) | - |
215 | : QWidget(parent) | - |
216 | ,nrows(rows), ncols(cols) | - |
217 | { | - |
218 | d = 0; executed (the execution status of this line is deduced): d = 0; | - |
219 | setFocusPolicy(Qt::StrongFocus); executed (the execution status of this line is deduced): setFocusPolicy(Qt::StrongFocus); | - |
220 | cellw = 28; executed (the execution status of this line is deduced): cellw = 28; | - |
221 | cellh = 24; executed (the execution status of this line is deduced): cellh = 24; | - |
222 | curCol = 0; executed (the execution status of this line is deduced): curCol = 0; | - |
223 | curRow = 0; executed (the execution status of this line is deduced): curRow = 0; | - |
224 | selCol = -1; executed (the execution status of this line is deduced): selCol = -1; | - |
225 | selRow = -1; executed (the execution status of this line is deduced): selRow = -1; | - |
226 | } executed: } Execution Count:6 | 6 |
227 | | - |
228 | QSize QWellArray::sizeHint() const | - |
229 | { | - |
230 | ensurePolished(); executed (the execution status of this line is deduced): ensurePolished(); | - |
231 | return gridSize().boundedTo(QSize(640, 480)); executed: return gridSize().boundedTo(QSize(640, 480)); Execution Count:4 | 4 |
232 | } | - |
233 | | - |
234 | | - |
235 | void QWellArray::paintCell(QPainter* p, int row, int col, const QRect &rect) | - |
236 | { | - |
237 | int b = 3; //margin executed (the execution status of this line is deduced): int b = 3; | - |
238 | | - |
239 | const QPalette & g = palette(); executed (the execution status of this line is deduced): const QPalette & g = palette(); | - |
240 | QStyleOptionFrame opt; executed (the execution status of this line is deduced): QStyleOptionFrame opt; | - |
241 | int dfw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); executed (the execution status of this line is deduced): int dfw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); | - |
242 | opt.lineWidth = dfw; executed (the execution status of this line is deduced): opt.lineWidth = dfw; | - |
243 | opt.midLineWidth = 1; executed (the execution status of this line is deduced): opt.midLineWidth = 1; | - |
244 | opt.rect = rect.adjusted(b, b, -b, -b); executed (the execution status of this line is deduced): opt.rect = rect.adjusted(b, b, -b, -b); | - |
245 | opt.palette = g; executed (the execution status of this line is deduced): opt.palette = g; | - |
246 | opt.state = QStyle::State_Enabled | QStyle::State_Sunken; executed (the execution status of this line is deduced): opt.state = QStyle::State_Enabled | QStyle::State_Sunken; | - |
247 | style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this); executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this); | - |
248 | b += dfw; executed (the execution status of this line is deduced): b += dfw; | - |
249 | | - |
250 | if ((row == curRow) && (col == curCol)) { evaluated: (row == curRow) yes Evaluation Count:34 | yes Evaluation Count:96 |
evaluated: (col == curCol) yes Evaluation Count:6 | yes Evaluation Count:28 |
| 6-96 |
251 | if (hasFocus()) { evaluated: hasFocus() yes Evaluation Count:2 | yes Evaluation Count:4 |
| 2-4 |
252 | QStyleOptionFocusRect opt; executed (the execution status of this line is deduced): QStyleOptionFocusRect opt; | - |
253 | opt.palette = g; executed (the execution status of this line is deduced): opt.palette = g; | - |
254 | opt.rect = rect; executed (the execution status of this line is deduced): opt.rect = rect; | - |
255 | opt.state = QStyle::State_None | QStyle::State_KeyboardFocusChange; executed (the execution status of this line is deduced): opt.state = QStyle::State_None | QStyle::State_KeyboardFocusChange; | - |
256 | style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, this); executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, this); | - |
257 | } executed: } Execution Count:2 | 2 |
258 | } executed: } Execution Count:6 | 6 |
259 | paintCellContents(p, row, col, opt.rect.adjusted(dfw, dfw, -dfw, -dfw)); executed (the execution status of this line is deduced): paintCellContents(p, row, col, opt.rect.adjusted(dfw, dfw, -dfw, -dfw)); | - |
260 | } executed: } Execution Count:130 | 130 |
261 | | - |
262 | /*! | - |
263 | Reimplement this function to change the contents of the well array. | - |
264 | */ | - |
265 | void QWellArray::paintCellContents(QPainter *p, int row, int col, const QRect &r) | - |
266 | { | - |
267 | if (d) { | 0 |
268 | p->fillRect(r, d->brush[row*numCols()+col]); never executed (the execution status of this line is deduced): p->fillRect(r, d->brush[row*numCols()+col]); | - |
269 | } else { | 0 |
270 | p->fillRect(r, Qt::white); never executed (the execution status of this line is deduced): p->fillRect(r, Qt::white); | - |
271 | p->setPen(Qt::black); never executed (the execution status of this line is deduced): p->setPen(Qt::black); | - |
272 | p->drawLine(r.topLeft(), r.bottomRight()); never executed (the execution status of this line is deduced): p->drawLine(r.topLeft(), r.bottomRight()); | - |
273 | p->drawLine(r.topRight(), r.bottomLeft()); never executed (the execution status of this line is deduced): p->drawLine(r.topRight(), r.bottomLeft()); | - |
274 | } | 0 |
275 | } | - |
276 | | - |
277 | void QWellArray::mousePressEvent(QMouseEvent *e) | - |
278 | { | - |
279 | // The current cell marker is set to the cell the mouse is pressed in | - |
280 | QPoint pos = e->pos(); never executed (the execution status of this line is deduced): QPoint pos = e->pos(); | - |
281 | setCurrent(rowAt(pos.y()), columnAt(pos.x())); never executed (the execution status of this line is deduced): setCurrent(rowAt(pos.y()), columnAt(pos.x())); | - |
282 | } | 0 |
283 | | - |
284 | void QWellArray::mouseReleaseEvent(QMouseEvent * /* event */) | - |
285 | { | - |
286 | // The current cell marker is set to the cell the mouse is clicked in | - |
287 | setSelected(curRow, curCol); never executed (the execution status of this line is deduced): setSelected(curRow, curCol); | - |
288 | } | 0 |
289 | | - |
290 | | - |
291 | /* | - |
292 | Sets the cell currently having the focus. This is not necessarily | - |
293 | the same as the currently selected cell. | - |
294 | */ | - |
295 | | - |
296 | void QWellArray::setCurrent(int row, int col) | - |
297 | { | - |
298 | if ((curRow == row) && (curCol == col)) evaluated: (curRow == row) yes Evaluation Count:1 | yes Evaluation Count:3 |
partially evaluated: (curCol == col) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-3 |
299 | return; executed: return; Execution Count:1 | 1 |
300 | | - |
301 | if (row < 0 || col < 0) partially evaluated: row < 0 no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: col < 0 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
302 | row = col = -1; never executed: row = col = -1; | 0 |
303 | | - |
304 | int oldRow = curRow; executed (the execution status of this line is deduced): int oldRow = curRow; | - |
305 | int oldCol = curCol; executed (the execution status of this line is deduced): int oldCol = curCol; | - |
306 | | - |
307 | curRow = row; executed (the execution status of this line is deduced): curRow = row; | - |
308 | curCol = col; executed (the execution status of this line is deduced): curCol = col; | - |
309 | | - |
310 | updateCell(oldRow, oldCol); executed (the execution status of this line is deduced): updateCell(oldRow, oldCol); | - |
311 | updateCell(curRow, curCol); executed (the execution status of this line is deduced): updateCell(curRow, curCol); | - |
312 | } executed: } Execution Count:3 | 3 |
313 | | - |
314 | /* | - |
315 | Sets the currently selected cell to \a row, \a column. If \a row or | - |
316 | \a column are less than zero, the current cell is unselected. | - |
317 | | - |
318 | Does not set the position of the focus indicator. | - |
319 | */ | - |
320 | void QWellArray::setSelected(int row, int col) | - |
321 | { | - |
322 | int oldRow = selRow; executed (the execution status of this line is deduced): int oldRow = selRow; | - |
323 | int oldCol = selCol; executed (the execution status of this line is deduced): int oldCol = selCol; | - |
324 | | - |
325 | if (row < 0 || col < 0) evaluated: row < 0 yes Evaluation Count:8 | yes Evaluation Count:4 |
partially evaluated: col < 0 no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-8 |
326 | row = col = -1; executed: row = col = -1; Execution Count:8 | 8 |
327 | | - |
328 | selCol = col; executed (the execution status of this line is deduced): selCol = col; | - |
329 | selRow = row; executed (the execution status of this line is deduced): selRow = row; | - |
330 | | - |
331 | updateCell(oldRow, oldCol); executed (the execution status of this line is deduced): updateCell(oldRow, oldCol); | - |
332 | updateCell(selRow, selCol); executed (the execution status of this line is deduced): updateCell(selRow, selCol); | - |
333 | if (row >= 0) evaluated: row >= 0 yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-8 |
334 | emit selected(row, col); executed: selected(row, col); Execution Count:4 | 4 |
335 | | - |
336 | #ifndef QT_NO_MENU | - |
337 | if (isVisible() && qobject_cast<QMenu*>(parentWidget())) partially evaluated: isVisible() no Evaluation Count:0 | yes Evaluation Count:12 |
never evaluated: qobject_cast<QMenu*>(parentWidget()) | 0-12 |
338 | parentWidget()->close(); never executed: parentWidget()->close(); | 0 |
339 | #endif | - |
340 | } executed: } Execution Count:12 | 12 |
341 | | - |
342 | void QWellArray::focusInEvent(QFocusEvent*) | - |
343 | { | - |
344 | updateCell(curRow, curCol); executed (the execution status of this line is deduced): updateCell(curRow, curCol); | - |
345 | } executed: } Execution Count:4 | 4 |
346 | | - |
347 | void QWellArray::setCellBrush(int row, int col, const QBrush &b) | - |
348 | { | - |
349 | if (!d) { | 0 |
350 | d = new QWellArrayData; never executed (the execution status of this line is deduced): d = new QWellArrayData; | - |
351 | int i = numRows()*numCols(); never executed (the execution status of this line is deduced): int i = numRows()*numCols(); | - |
352 | d->brush = new QBrush[i]; never executed (the execution status of this line is deduced): d->brush = new QBrush[i]; | - |
353 | } | 0 |
354 | if (row >= 0 && row < numRows() && col >= 0 && col < numCols()) never evaluated: row >= 0 never evaluated: row < numRows() never evaluated: col >= 0 never evaluated: col < numCols() | 0 |
355 | d->brush[row*numCols()+col] = b; never executed: d->brush[row*numCols()+col] = b; | 0 |
356 | } | 0 |
357 | | - |
358 | /* | - |
359 | Returns the brush set for the cell at \a row, \a column. If no brush is | - |
360 | set, Qt::NoBrush is returned. | - |
361 | */ | - |
362 | | - |
363 | QBrush QWellArray::cellBrush(int row, int col) | - |
364 | { | - |
365 | if (d && row >= 0 && row < numRows() && col >= 0 && col < numCols()) never evaluated: d never evaluated: row >= 0 never evaluated: row < numRows() never evaluated: col >= 0 never evaluated: col < numCols() | 0 |
366 | return d->brush[row*numCols()+col]; never executed: return d->brush[row*numCols()+col]; | 0 |
367 | return Qt::NoBrush; never executed: return Qt::NoBrush; | 0 |
368 | } | - |
369 | | - |
370 | | - |
371 | | - |
372 | /*!\reimp | - |
373 | */ | - |
374 | | - |
375 | void QWellArray::focusOutEvent(QFocusEvent*) | - |
376 | { | - |
377 | updateCell(curRow, curCol); executed (the execution status of this line is deduced): updateCell(curRow, curCol); | - |
378 | } executed: } Execution Count:2 | 2 |
379 | | - |
380 | /*\reimp | - |
381 | */ | - |
382 | void QWellArray::keyPressEvent(QKeyEvent* e) | - |
383 | { | - |
384 | switch(e->key()) { // Look at the key code | - |
385 | case Qt::Key_Left: // If 'left arrow'-key, | - |
386 | if(curCol > 0) // and cr't not in leftmost col never evaluated: curCol > 0 | 0 |
387 | setCurrent(curRow, curCol - 1); // set cr't to next left column never executed: setCurrent(curRow, curCol - 1); | 0 |
388 | break; | 0 |
389 | case Qt::Key_Right: // Correspondingly... | - |
390 | if(curCol < numCols()-1) never evaluated: curCol < numCols()-1 | 0 |
391 | setCurrent(curRow, curCol + 1); never executed: setCurrent(curRow, curCol + 1); | 0 |
392 | break; | 0 |
393 | case Qt::Key_Up: | - |
394 | if(curRow > 0) never evaluated: curRow > 0 | 0 |
395 | setCurrent(curRow - 1, curCol); never executed: setCurrent(curRow - 1, curCol); | 0 |
396 | break; | 0 |
397 | case Qt::Key_Down: | - |
398 | if(curRow < numRows()-1) never evaluated: curRow < numRows()-1 | 0 |
399 | setCurrent(curRow + 1, curCol); never executed: setCurrent(curRow + 1, curCol); | 0 |
400 | break; | 0 |
401 | #if 0 | - |
402 | // bad idea that shouldn't have been implemented; very counterintuitive | - |
403 | case Qt::Key_Return: | - |
404 | case Qt::Key_Enter: | - |
405 | /* | - |
406 | ignore the key, so that the dialog get it, but still select | - |
407 | the current row/col | - |
408 | */ | - |
409 | e->ignore(); | - |
410 | // fallthrough intended | - |
411 | #endif | - |
412 | case Qt::Key_Space: | - |
413 | setSelected(curRow, curCol); never executed (the execution status of this line is deduced): setSelected(curRow, curCol); | - |
414 | break; | 0 |
415 | default: // If not an interesting key, | - |
416 | e->ignore(); // we don't accept the event never executed (the execution status of this line is deduced): e->ignore(); | - |
417 | return; | 0 |
418 | } | - |
419 | | - |
420 | } | 0 |
421 | | - |
422 | //////////// QWellArray END | - |
423 | | - |
424 | /*! | - |
425 | Returns the number of custom colors supported by QColorDialog. All | - |
426 | color dialogs share the same custom colors. | - |
427 | */ | - |
428 | int QColorDialog::customCount() | - |
429 | { | - |
430 | return QColorDialogOptions::customColorCount(); never executed: return QColorDialogOptions::customColorCount(); | 0 |
431 | } | - |
432 | | - |
433 | /*! | - |
434 | \since 4.5 | - |
435 | | - |
436 | Returns the custom color at the given \a index as a QColor value. | - |
437 | */ | - |
438 | QColor QColorDialog::customColor(int index) | - |
439 | { | - |
440 | return QColor(QColorDialogOptions::customColor(index)); never executed: return QColor(QColorDialogOptions::customColor(index)); | 0 |
441 | } | - |
442 | | - |
443 | /*! | - |
444 | Sets the custom color at \a index to the QColor \a color value. | - |
445 | | - |
446 | \note This function does not apply to the Native Color Dialog on the Mac | - |
447 | OS X platform. If you still require this function, use the | - |
448 | QColorDialog::DontUseNativeDialog option. | - |
449 | */ | - |
450 | void QColorDialog::setCustomColor(int index, QColor color) | - |
451 | { | - |
452 | QColorDialogOptions::setCustomColor(index, color.rgba()); never executed (the execution status of this line is deduced): QColorDialogOptions::setCustomColor(index, color.rgba()); | - |
453 | } | 0 |
454 | | - |
455 | /*! | - |
456 | \since 5.0 | - |
457 | | - |
458 | Returns the standard color at the given \a index as a QColor value. | - |
459 | */ | - |
460 | QColor QColorDialog::standardColor(int index) | - |
461 | { | - |
462 | return QColor(QColorDialogOptions::standardColor(index)); never executed: return QColor(QColorDialogOptions::standardColor(index)); | 0 |
463 | } | - |
464 | | - |
465 | /*! | - |
466 | Sets the standard color at \a index to the QColor \a color value. | - |
467 | | - |
468 | \note This function does not apply to the Native Color Dialog on the Mac | - |
469 | OS X platform. If you still require this function, use the | - |
470 | QColorDialog::DontUseNativeDialog option. | - |
471 | */ | - |
472 | void QColorDialog::setStandardColor(int index, QColor color) | - |
473 | { | - |
474 | QColorDialogOptions::setStandardColor(index, color.rgba()); never executed (the execution status of this line is deduced): QColorDialogOptions::setStandardColor(index, color.rgba()); | - |
475 | } | 0 |
476 | | - |
477 | static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v) | - |
478 | { | - |
479 | QColor c; executed (the execution status of this line is deduced): QColor c; | - |
480 | c.setRgb(rgb); executed (the execution status of this line is deduced): c.setRgb(rgb); | - |
481 | c.getHsv(&h, &s, &v); executed (the execution status of this line is deduced): c.getHsv(&h, &s, &v); | - |
482 | } executed: } Execution Count:36 | 36 |
483 | | - |
484 | class QColorWell : public QWellArray | - |
485 | { | - |
486 | public: | - |
487 | QColorWell(QWidget *parent, int r, int c, QRgb *vals) | - |
488 | :QWellArray(r, c, parent), values(vals), mousePressed(false), oldCurrent(-1, -1) | - |
489 | { setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); } executed: } Execution Count:6 | 6 |
490 | | - |
491 | protected: | - |
492 | void paintCellContents(QPainter *, int row, int col, const QRect&); | - |
493 | void mousePressEvent(QMouseEvent *e); | - |
494 | void mouseMoveEvent(QMouseEvent *e); | - |
495 | void mouseReleaseEvent(QMouseEvent *e); | - |
496 | #ifndef QT_NO_DRAGANDDROP | - |
497 | void dragEnterEvent(QDragEnterEvent *e); | - |
498 | void dragLeaveEvent(QDragLeaveEvent *e); | - |
499 | void dragMoveEvent(QDragMoveEvent *e); | - |
500 | void dropEvent(QDropEvent *e); | - |
501 | #endif | - |
502 | | - |
503 | private: | - |
504 | QRgb *values; | - |
505 | bool mousePressed; | - |
506 | QPoint pressPos; | - |
507 | QPoint oldCurrent; | - |
508 | | - |
509 | }; | - |
510 | | - |
511 | void QColorWell::paintCellContents(QPainter *p, int row, int col, const QRect &r) | - |
512 | { | - |
513 | int i = row + col*numRows(); executed (the execution status of this line is deduced): int i = row + col*numRows(); | - |
514 | p->fillRect(r, QColor(values[i])); executed (the execution status of this line is deduced): p->fillRect(r, QColor(values[i])); | - |
515 | } executed: } Execution Count:130 | 130 |
516 | | - |
517 | void QColorWell::mousePressEvent(QMouseEvent *e) | - |
518 | { | - |
519 | oldCurrent = QPoint(selectedRow(), selectedColumn()); never executed (the execution status of this line is deduced): oldCurrent = QPoint(selectedRow(), selectedColumn()); | - |
520 | QWellArray::mousePressEvent(e); never executed (the execution status of this line is deduced): QWellArray::mousePressEvent(e); | - |
521 | mousePressed = true; never executed (the execution status of this line is deduced): mousePressed = true; | - |
522 | pressPos = e->pos(); never executed (the execution status of this line is deduced): pressPos = e->pos(); | - |
523 | } | 0 |
524 | | - |
525 | void QColorWell::mouseMoveEvent(QMouseEvent *e) | - |
526 | { | - |
527 | QWellArray::mouseMoveEvent(e); never executed (the execution status of this line is deduced): QWellArray::mouseMoveEvent(e); | - |
528 | #ifndef QT_NO_DRAGANDDROP | - |
529 | if (!mousePressed) never evaluated: !mousePressed | 0 |
530 | return; | 0 |
531 | if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { never evaluated: (pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance() | 0 |
532 | setCurrent(oldCurrent.x(), oldCurrent.y()); never executed (the execution status of this line is deduced): setCurrent(oldCurrent.x(), oldCurrent.y()); | - |
533 | int i = rowAt(pressPos.y()) + columnAt(pressPos.x()) * numRows(); never executed (the execution status of this line is deduced): int i = rowAt(pressPos.y()) + columnAt(pressPos.x()) * numRows(); | - |
534 | QColor col(values[i]); never executed (the execution status of this line is deduced): QColor col(values[i]); | - |
535 | QMimeData *mime = new QMimeData; never executed (the execution status of this line is deduced): QMimeData *mime = new QMimeData; | - |
536 | mime->setColorData(col); never executed (the execution status of this line is deduced): mime->setColorData(col); | - |
537 | QPixmap pix(cellWidth(), cellHeight()); never executed (the execution status of this line is deduced): QPixmap pix(cellWidth(), cellHeight()); | - |
538 | pix.fill(col); never executed (the execution status of this line is deduced): pix.fill(col); | - |
539 | QPainter p(&pix); never executed (the execution status of this line is deduced): QPainter p(&pix); | - |
540 | p.drawRect(0, 0, pix.width() - 1, pix.height() - 1); never executed (the execution status of this line is deduced): p.drawRect(0, 0, pix.width() - 1, pix.height() - 1); | - |
541 | p.end(); never executed (the execution status of this line is deduced): p.end(); | - |
542 | QDrag *drg = new QDrag(this); never executed (the execution status of this line is deduced): QDrag *drg = new QDrag(this); | - |
543 | drg->setMimeData(mime); never executed (the execution status of this line is deduced): drg->setMimeData(mime); | - |
544 | drg->setPixmap(pix); never executed (the execution status of this line is deduced): drg->setPixmap(pix); | - |
545 | mousePressed = false; never executed (the execution status of this line is deduced): mousePressed = false; | - |
546 | drg->start(); never executed (the execution status of this line is deduced): drg->start(); | - |
547 | } | 0 |
548 | #endif | - |
549 | } | 0 |
550 | | - |
551 | #ifndef QT_NO_DRAGANDDROP | - |
552 | void QColorWell::dragEnterEvent(QDragEnterEvent *e) | - |
553 | { | - |
554 | if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) never evaluated: qvariant_cast<QColor>(e->mimeData()->colorData()).isValid() | 0 |
555 | e->accept(); never executed: e->accept(); | 0 |
556 | else | - |
557 | e->ignore(); never executed: e->ignore(); | 0 |
558 | } | - |
559 | | - |
560 | void QColorWell::dragLeaveEvent(QDragLeaveEvent *) | - |
561 | { | - |
562 | if (hasFocus()) never evaluated: hasFocus() | 0 |
563 | parentWidget()->setFocus(); never executed: parentWidget()->setFocus(); | 0 |
564 | } | 0 |
565 | | - |
566 | void QColorWell::dragMoveEvent(QDragMoveEvent *e) | - |
567 | { | - |
568 | if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) { never evaluated: qvariant_cast<QColor>(e->mimeData()->colorData()).isValid() | 0 |
569 | setCurrent(rowAt(e->pos().y()), columnAt(e->pos().x())); never executed (the execution status of this line is deduced): setCurrent(rowAt(e->pos().y()), columnAt(e->pos().x())); | - |
570 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
571 | } else { | 0 |
572 | e->ignore(); never executed (the execution status of this line is deduced): e->ignore(); | - |
573 | } | 0 |
574 | } | - |
575 | | - |
576 | void QColorWell::dropEvent(QDropEvent *e) | - |
577 | { | - |
578 | QColor col = qvariant_cast<QColor>(e->mimeData()->colorData()); never executed (the execution status of this line is deduced): QColor col = qvariant_cast<QColor>(e->mimeData()->colorData()); | - |
579 | if (col.isValid()) { never evaluated: col.isValid() | 0 |
580 | int i = rowAt(e->pos().y()) + columnAt(e->pos().x()) * numRows(); never executed (the execution status of this line is deduced): int i = rowAt(e->pos().y()) + columnAt(e->pos().x()) * numRows(); | - |
581 | values[i] = col.rgb(); never executed (the execution status of this line is deduced): values[i] = col.rgb(); | - |
582 | update(); never executed (the execution status of this line is deduced): update(); | - |
583 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
584 | } else { | 0 |
585 | e->ignore(); never executed (the execution status of this line is deduced): e->ignore(); | - |
586 | } | 0 |
587 | } | - |
588 | | - |
589 | #endif // QT_NO_DRAGANDDROP | - |
590 | | - |
591 | void QColorWell::mouseReleaseEvent(QMouseEvent *e) | - |
592 | { | - |
593 | if (!mousePressed) never evaluated: !mousePressed | 0 |
594 | return; | 0 |
595 | QWellArray::mouseReleaseEvent(e); never executed (the execution status of this line is deduced): QWellArray::mouseReleaseEvent(e); | - |
596 | mousePressed = false; never executed (the execution status of this line is deduced): mousePressed = false; | - |
597 | } | 0 |
598 | | - |
599 | class QColorPicker : public QFrame | - |
600 | { | - |
601 | Q_OBJECT | - |
602 | public: | - |
603 | QColorPicker(QWidget* parent); | - |
604 | ~QColorPicker(); | - |
605 | | - |
606 | public slots: | - |
607 | void setCol(int h, int s); | - |
608 | | - |
609 | signals: | - |
610 | void newCol(int h, int s); | - |
611 | | - |
612 | protected: | - |
613 | QSize sizeHint() const; | - |
614 | void paintEvent(QPaintEvent*); | - |
615 | void mouseMoveEvent(QMouseEvent *); | - |
616 | void mousePressEvent(QMouseEvent *); | - |
617 | void resizeEvent(QResizeEvent *); | - |
618 | | - |
619 | private: | - |
620 | int hue; | - |
621 | int sat; | - |
622 | | - |
623 | QPoint colPt(); | - |
624 | int huePt(const QPoint &pt); | - |
625 | int satPt(const QPoint &pt); | - |
626 | void setCol(const QPoint &pt); | - |
627 | | - |
628 | QPixmap pix; | - |
629 | }; | - |
630 | | - |
631 | static int pWidth = 220; | - |
632 | static int pHeight = 200; | - |
633 | | - |
634 | class QColorLuminancePicker : public QWidget | - |
635 | { | - |
636 | Q_OBJECT | - |
637 | public: | - |
638 | QColorLuminancePicker(QWidget* parent=0); | - |
639 | ~QColorLuminancePicker(); | - |
640 | | - |
641 | public slots: | - |
642 | void setCol(int h, int s, int v); | - |
643 | void setCol(int h, int s); | - |
644 | | - |
645 | signals: | - |
646 | void newHsv(int h, int s, int v); | - |
647 | | - |
648 | protected: | - |
649 | void paintEvent(QPaintEvent*); | - |
650 | void mouseMoveEvent(QMouseEvent *); | - |
651 | void mousePressEvent(QMouseEvent *); | - |
652 | | - |
653 | private: | - |
654 | enum { foff = 3, coff = 4 }; //frame and contents offset | - |
655 | int val; | - |
656 | int hue; | - |
657 | int sat; | - |
658 | | - |
659 | int y2val(int y); | - |
660 | int val2y(int val); | - |
661 | void setVal(int v); | - |
662 | | - |
663 | QPixmap *pix; | - |
664 | }; | - |
665 | | - |
666 | | - |
667 | int QColorLuminancePicker::y2val(int y) | - |
668 | { | - |
669 | int d = height() - 2*coff - 1; executed (the execution status of this line is deduced): int d = height() - 2*coff - 1; | - |
670 | return 255 - (y - coff)*255/d; executed: return 255 - (y - coff)*255/d; Execution Count:5200 | 5200 |
671 | } | - |
672 | | - |
673 | int QColorLuminancePicker::val2y(int v) | - |
674 | { | - |
675 | int d = height() - 2*coff - 1; executed (the execution status of this line is deduced): int d = height() - 2*coff - 1; | - |
676 | return coff + (255-v)*d/255; executed: return coff + (255-v)*d/255; Execution Count:2 | 2 |
677 | } | - |
678 | | - |
679 | QColorLuminancePicker::QColorLuminancePicker(QWidget* parent) | - |
680 | :QWidget(parent) | - |
681 | { | - |
682 | hue = 100; val = 100; sat = 100; executed (the execution status of this line is deduced): hue = 100; val = 100; sat = 100; | - |
683 | pix = 0; executed (the execution status of this line is deduced): pix = 0; | - |
684 | // setAttribute(WA_NoErase, true); | - |
685 | } executed: } Execution Count:3 | 3 |
686 | | - |
687 | QColorLuminancePicker::~QColorLuminancePicker() | - |
688 | { | - |
689 | delete pix; executed (the execution status of this line is deduced): delete pix; | - |
690 | } executed: } Execution Count:3 | 3 |
691 | | - |
692 | void QColorLuminancePicker::mouseMoveEvent(QMouseEvent *m) | - |
693 | { | - |
694 | setVal(y2val(m->y())); never executed (the execution status of this line is deduced): setVal(y2val(m->y())); | - |
695 | } | 0 |
696 | void QColorLuminancePicker::mousePressEvent(QMouseEvent *m) | - |
697 | { | - |
698 | setVal(y2val(m->y())); never executed (the execution status of this line is deduced): setVal(y2val(m->y())); | - |
699 | } | 0 |
700 | | - |
701 | void QColorLuminancePicker::setVal(int v) | - |
702 | { | - |
703 | if (val == v) never evaluated: val == v | 0 |
704 | return; | 0 |
705 | val = qMax(0, qMin(v,255)); never executed (the execution status of this line is deduced): val = qMax(0, qMin(v,255)); | - |
706 | delete pix; pix=0; never executed (the execution status of this line is deduced): delete pix; pix=0; | - |
707 | repaint(); never executed (the execution status of this line is deduced): repaint(); | - |
708 | emit newHsv(hue, sat, val); never executed (the execution status of this line is deduced): newHsv(hue, sat, val); | - |
709 | } | 0 |
710 | | - |
711 | //receives from a hue,sat chooser and relays. | - |
712 | void QColorLuminancePicker::setCol(int h, int s) | - |
713 | { | - |
714 | setCol(h, s, val); never executed (the execution status of this line is deduced): setCol(h, s, val); | - |
715 | emit newHsv(h, s, val); never executed (the execution status of this line is deduced): newHsv(h, s, val); | - |
716 | } | 0 |
717 | | - |
718 | void QColorLuminancePicker::paintEvent(QPaintEvent *) | - |
719 | { | - |
720 | int w = width() - 5; executed (the execution status of this line is deduced): int w = width() - 5; | - |
721 | | - |
722 | QRect r(0, foff, w, height() - 2*foff); executed (the execution status of this line is deduced): QRect r(0, foff, w, height() - 2*foff); | - |
723 | int wi = r.width() - 2; executed (the execution status of this line is deduced): int wi = r.width() - 2; | - |
724 | int hi = r.height() - 2; executed (the execution status of this line is deduced): int hi = r.height() - 2; | - |
725 | if (!pix || pix->height() != hi || pix->width() != wi) { partially evaluated: !pix yes Evaluation Count:2 | no Evaluation Count:0 |
never evaluated: pix->height() != hi never evaluated: pix->width() != wi | 0-2 |
726 | delete pix; executed (the execution status of this line is deduced): delete pix; | - |
727 | QImage img(wi, hi, QImage::Format_RGB32); executed (the execution status of this line is deduced): QImage img(wi, hi, QImage::Format_RGB32); | - |
728 | int y; executed (the execution status of this line is deduced): int y; | - |
729 | uint *pixel = (uint *) img.scanLine(0); executed (the execution status of this line is deduced): uint *pixel = (uint *) img.scanLine(0); | - |
730 | for (y = 0; y < hi; y++) { evaluated: y < hi yes Evaluation Count:400 | yes Evaluation Count:2 |
| 2-400 |
731 | const uint *end = pixel + wi; executed (the execution status of this line is deduced): const uint *end = pixel + wi; | - |
732 | while (pixel < end) { evaluated: pixel < end yes Evaluation Count:5200 | yes Evaluation Count:400 |
| 400-5200 |
733 | QColor c; executed (the execution status of this line is deduced): QColor c; | - |
734 | c.setHsv(hue, sat, y2val(y+coff)); executed (the execution status of this line is deduced): c.setHsv(hue, sat, y2val(y+coff)); | - |
735 | *pixel = c.rgb(); executed (the execution status of this line is deduced): *pixel = c.rgb(); | - |
736 | ++pixel; executed (the execution status of this line is deduced): ++pixel; | - |
737 | } executed: } Execution Count:5200 | 5200 |
738 | } executed: } Execution Count:400 | 400 |
739 | pix = new QPixmap(QPixmap::fromImage(img)); executed (the execution status of this line is deduced): pix = new QPixmap(QPixmap::fromImage(img)); | - |
740 | } executed: } Execution Count:2 | 2 |
741 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
742 | p.drawPixmap(1, coff, *pix); executed (the execution status of this line is deduced): p.drawPixmap(1, coff, *pix); | - |
743 | const QPalette &g = palette(); executed (the execution status of this line is deduced): const QPalette &g = palette(); | - |
744 | qDrawShadePanel(&p, r, g, true); executed (the execution status of this line is deduced): qDrawShadePanel(&p, r, g, true); | - |
745 | p.setPen(g.foreground().color()); executed (the execution status of this line is deduced): p.setPen(g.foreground().color()); | - |
746 | p.setBrush(g.foreground()); executed (the execution status of this line is deduced): p.setBrush(g.foreground()); | - |
747 | QPolygon a; executed (the execution status of this line is deduced): QPolygon a; | - |
748 | int y = val2y(val); executed (the execution status of this line is deduced): int y = val2y(val); | - |
749 | a.setPoints(3, w, y, w+5, y+5, w+5, y-5); executed (the execution status of this line is deduced): a.setPoints(3, w, y, w+5, y+5, w+5, y-5); | - |
750 | p.eraseRect(w, 0, 5, height()); executed (the execution status of this line is deduced): p.eraseRect(w, 0, 5, height()); | - |
751 | p.drawPolygon(a); executed (the execution status of this line is deduced): p.drawPolygon(a); | - |
752 | } executed: } Execution Count:2 | 2 |
753 | | - |
754 | void QColorLuminancePicker::setCol(int h, int s , int v) | - |
755 | { | - |
756 | val = v; executed (the execution status of this line is deduced): val = v; | - |
757 | hue = h; executed (the execution status of this line is deduced): hue = h; | - |
758 | sat = s; executed (the execution status of this line is deduced): sat = s; | - |
759 | delete pix; pix=0; executed (the execution status of this line is deduced): delete pix; pix=0; | - |
760 | repaint(); executed (the execution status of this line is deduced): repaint(); | - |
761 | } executed: } Execution Count:18 | 18 |
762 | | - |
763 | QPoint QColorPicker::colPt() | - |
764 | { | - |
765 | QRect r = contentsRect(); executed (the execution status of this line is deduced): QRect r = contentsRect(); | - |
766 | return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255); executed: return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255); Execution Count:16 | 16 |
767 | } | - |
768 | | - |
769 | int QColorPicker::huePt(const QPoint &pt) | - |
770 | { | - |
771 | QRect r = contentsRect(); executed (the execution status of this line is deduced): QRect r = contentsRect(); | - |
772 | return 360 - pt.x() * 360 / (r.width() - 1); executed: return 360 - pt.x() * 360 / (r.width() - 1); Execution Count:88000 | 88000 |
773 | } | - |
774 | | - |
775 | int QColorPicker::satPt(const QPoint &pt) | - |
776 | { | - |
777 | QRect r = contentsRect(); executed (the execution status of this line is deduced): QRect r = contentsRect(); | - |
778 | return 255 - pt.y() * 255 / (r.height() - 1); executed: return 255 - pt.y() * 255 / (r.height() - 1); Execution Count:88000 | 88000 |
779 | } | - |
780 | | - |
781 | void QColorPicker::setCol(const QPoint &pt) | - |
782 | { | - |
783 | setCol(huePt(pt), satPt(pt)); never executed (the execution status of this line is deduced): setCol(huePt(pt), satPt(pt)); | - |
784 | } | 0 |
785 | | - |
786 | QColorPicker::QColorPicker(QWidget* parent) | - |
787 | : QFrame(parent) | - |
788 | { | - |
789 | hue = 0; sat = 0; executed (the execution status of this line is deduced): hue = 0; sat = 0; | - |
790 | setCol(150, 255); executed (the execution status of this line is deduced): setCol(150, 255); | - |
791 | | - |
792 | setAttribute(Qt::WA_NoSystemBackground); executed (the execution status of this line is deduced): setAttribute(Qt::WA_NoSystemBackground); | - |
793 | setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); executed (the execution status of this line is deduced): setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); | - |
794 | } executed: } Execution Count:3 | 3 |
795 | | - |
796 | QColorPicker::~QColorPicker() | - |
797 | { | - |
798 | } | - |
799 | | - |
800 | QSize QColorPicker::sizeHint() const | - |
801 | { | - |
802 | return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth()); executed: return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth()); Execution Count:2 | 2 |
803 | } | - |
804 | | - |
805 | void QColorPicker::setCol(int h, int s) | - |
806 | { | - |
807 | int nhue = qMin(qMax(0,h), 359); executed (the execution status of this line is deduced): int nhue = qMin(qMax(0,h), 359); | - |
808 | int nsat = qMin(qMax(0,s), 255); executed (the execution status of this line is deduced): int nsat = qMin(qMax(0,s), 255); | - |
809 | if (nhue == hue && nsat == sat) evaluated: nhue == hue yes Evaluation Count:14 | yes Evaluation Count:7 |
partially evaluated: nsat == sat yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-14 |
810 | return; executed: return; Execution Count:14 | 14 |
811 | | - |
812 | QRect r(colPt(), QSize(20,20)); executed (the execution status of this line is deduced): QRect r(colPt(), QSize(20,20)); | - |
813 | hue = nhue; sat = nsat; executed (the execution status of this line is deduced): hue = nhue; sat = nsat; | - |
814 | r = r.united(QRect(colPt(), QSize(20,20))); executed (the execution status of this line is deduced): r = r.united(QRect(colPt(), QSize(20,20))); | - |
815 | r.translate(contentsRect().x()-9, contentsRect().y()-9); executed (the execution status of this line is deduced): r.translate(contentsRect().x()-9, contentsRect().y()-9); | - |
816 | // update(r); | - |
817 | repaint(r); executed (the execution status of this line is deduced): repaint(r); | - |
818 | } executed: } Execution Count:7 | 7 |
819 | | - |
820 | void QColorPicker::mouseMoveEvent(QMouseEvent *m) | - |
821 | { | - |
822 | QPoint p = m->pos() - contentsRect().topLeft(); never executed (the execution status of this line is deduced): QPoint p = m->pos() - contentsRect().topLeft(); | - |
823 | setCol(p); never executed (the execution status of this line is deduced): setCol(p); | - |
824 | emit newCol(hue, sat); never executed (the execution status of this line is deduced): newCol(hue, sat); | - |
825 | } | 0 |
826 | | - |
827 | void QColorPicker::mousePressEvent(QMouseEvent *m) | - |
828 | { | - |
829 | QPoint p = m->pos() - contentsRect().topLeft(); never executed (the execution status of this line is deduced): QPoint p = m->pos() - contentsRect().topLeft(); | - |
830 | setCol(p); never executed (the execution status of this line is deduced): setCol(p); | - |
831 | emit newCol(hue, sat); never executed (the execution status of this line is deduced): newCol(hue, sat); | - |
832 | } | 0 |
833 | | - |
834 | void QColorPicker::paintEvent(QPaintEvent* ) | - |
835 | { | - |
836 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
837 | drawFrame(&p); executed (the execution status of this line is deduced): drawFrame(&p); | - |
838 | QRect r = contentsRect(); executed (the execution status of this line is deduced): QRect r = contentsRect(); | - |
839 | | - |
840 | p.drawPixmap(r.topLeft(), pix); executed (the execution status of this line is deduced): p.drawPixmap(r.topLeft(), pix); | - |
841 | QPoint pt = colPt() + r.topLeft(); executed (the execution status of this line is deduced): QPoint pt = colPt() + r.topLeft(); | - |
842 | p.setPen(Qt::black); executed (the execution status of this line is deduced): p.setPen(Qt::black); | - |
843 | | - |
844 | p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black); executed (the execution status of this line is deduced): p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black); | - |
845 | p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black); executed (the execution status of this line is deduced): p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black); | - |
846 | | - |
847 | } executed: } Execution Count:2 | 2 |
848 | | - |
849 | void QColorPicker::resizeEvent(QResizeEvent *ev) | - |
850 | { | - |
851 | QFrame::resizeEvent(ev); executed (the execution status of this line is deduced): QFrame::resizeEvent(ev); | - |
852 | | - |
853 | int w = width() - frameWidth() * 2; executed (the execution status of this line is deduced): int w = width() - frameWidth() * 2; | - |
854 | int h = height() - frameWidth() * 2; executed (the execution status of this line is deduced): int h = height() - frameWidth() * 2; | - |
855 | QImage img(w, h, QImage::Format_RGB32); executed (the execution status of this line is deduced): QImage img(w, h, QImage::Format_RGB32); | - |
856 | int x, y; executed (the execution status of this line is deduced): int x, y; | - |
857 | uint *pixel = (uint *) img.scanLine(0); executed (the execution status of this line is deduced): uint *pixel = (uint *) img.scanLine(0); | - |
858 | for (y = 0; y < h; y++) { evaluated: y < h yes Evaluation Count:400 | yes Evaluation Count:2 |
| 2-400 |
859 | const uint *end = pixel + w; executed (the execution status of this line is deduced): const uint *end = pixel + w; | - |
860 | x = 0; executed (the execution status of this line is deduced): x = 0; | - |
861 | while (pixel < end) { evaluated: pixel < end yes Evaluation Count:88000 | yes Evaluation Count:400 |
| 400-88000 |
862 | QPoint p(x, y); executed (the execution status of this line is deduced): QPoint p(x, y); | - |
863 | QColor c; executed (the execution status of this line is deduced): QColor c; | - |
864 | c.setHsv(huePt(p), satPt(p), 200); executed (the execution status of this line is deduced): c.setHsv(huePt(p), satPt(p), 200); | - |
865 | *pixel = c.rgb(); executed (the execution status of this line is deduced): *pixel = c.rgb(); | - |
866 | ++pixel; executed (the execution status of this line is deduced): ++pixel; | - |
867 | ++x; executed (the execution status of this line is deduced): ++x; | - |
868 | } executed: } Execution Count:88000 | 88000 |
869 | } executed: } Execution Count:400 | 400 |
870 | pix = QPixmap::fromImage(img); executed (the execution status of this line is deduced): pix = QPixmap::fromImage(img); | - |
871 | } executed: } Execution Count:2 | 2 |
872 | | - |
873 | | - |
874 | class QColSpinBox : public QSpinBox | - |
875 | { | - |
876 | public: | - |
877 | QColSpinBox(QWidget *parent) | - |
878 | : QSpinBox(parent) { setRange(0, 255); } executed: } Execution Count:21 | 21 |
879 | void setValue(int i) { | - |
880 | bool block = signalsBlocked(); executed (the execution status of this line is deduced): bool block = signalsBlocked(); | - |
881 | blockSignals(true); executed (the execution status of this line is deduced): blockSignals(true); | - |
882 | QSpinBox::setValue(i); executed (the execution status of this line is deduced): QSpinBox::setValue(i); | - |
883 | blockSignals(block); executed (the execution status of this line is deduced): blockSignals(block); | - |
884 | } executed: } Execution Count:98 | 98 |
885 | }; | - |
886 | | - |
887 | class QColorShowLabel; | - |
888 | | - |
889 | class QColorShower : public QWidget | - |
890 | { | - |
891 | Q_OBJECT | - |
892 | public: | - |
893 | QColorShower(QColorDialog *parent); | - |
894 | | - |
895 | //things that don't emit signals | - |
896 | void setHsv(int h, int s, int v); | - |
897 | | - |
898 | int currentAlpha() const | - |
899 | { return (colorDialog->options() & QColorDialog::ShowAlphaChannel) ? alphaEd->value() : 255; } executed: return (colorDialog->options() & QColorDialog::ShowAlphaChannel) ? alphaEd->value() : 255; Execution Count:23 | 23 |
900 | void setCurrentAlpha(int a) { alphaEd->setValue(a); rgbEd(); } executed: } Execution Count:5 | 5 |
901 | void showAlpha(bool b); | - |
902 | bool isAlphaVisible() const; | - |
903 | | - |
904 | QRgb currentColor() const { return curCol; } executed: return curCol; Execution Count:80 | 80 |
905 | QColor currentQColor() const { return curQColor; } executed: return curQColor; Execution Count:3 | 3 |
906 | void retranslateStrings(); | - |
907 | void updateQColor(); | - |
908 | | - |
909 | public slots: | - |
910 | void setRgb(QRgb rgb); | - |
911 | | - |
912 | signals: | - |
913 | void newCol(QRgb rgb); | - |
914 | void currentColorChanged(const QColor &color); | - |
915 | | - |
916 | private slots: | - |
917 | void rgbEd(); | - |
918 | void hsvEd(); | - |
919 | private: | - |
920 | void showCurrentColor(); | - |
921 | int hue, sat, val; | - |
922 | QRgb curCol; | - |
923 | QColor curQColor; | - |
924 | QLabel *lblHue; | - |
925 | QLabel *lblSat; | - |
926 | QLabel *lblVal; | - |
927 | QLabel *lblRed; | - |
928 | QLabel *lblGreen; | - |
929 | QLabel *lblBlue; | - |
930 | QColSpinBox *hEd; | - |
931 | QColSpinBox *sEd; | - |
932 | QColSpinBox *vEd; | - |
933 | QColSpinBox *rEd; | - |
934 | QColSpinBox *gEd; | - |
935 | QColSpinBox *bEd; | - |
936 | QColSpinBox *alphaEd; | - |
937 | QLabel *alphaLab; | - |
938 | QColorShowLabel *lab; | - |
939 | bool rgbOriginal; | - |
940 | QColorDialog *colorDialog; | - |
941 | | - |
942 | friend class QColorDialog; | - |
943 | friend class QColorDialogPrivate; | - |
944 | }; | - |
945 | | - |
946 | class QColorShowLabel : public QFrame | - |
947 | { | - |
948 | Q_OBJECT | - |
949 | | - |
950 | public: | - |
951 | QColorShowLabel(QWidget *parent) : QFrame(parent) { | - |
952 | setFrameStyle(QFrame::Panel|QFrame::Sunken); executed (the execution status of this line is deduced): setFrameStyle(QFrame::Panel|QFrame::Sunken); | - |
953 | setAcceptDrops(true); executed (the execution status of this line is deduced): setAcceptDrops(true); | - |
954 | mousePressed = false; executed (the execution status of this line is deduced): mousePressed = false; | - |
955 | } executed: } Execution Count:3 | 3 |
956 | void setColor(QColor c) { col = c; } executed: } Execution Count:18 | 18 |
957 | | - |
958 | signals: | - |
959 | void colorDropped(QRgb); | - |
960 | | - |
961 | protected: | - |
962 | void paintEvent(QPaintEvent *); | - |
963 | void mousePressEvent(QMouseEvent *e); | - |
964 | void mouseMoveEvent(QMouseEvent *e); | - |
965 | void mouseReleaseEvent(QMouseEvent *e); | - |
966 | #ifndef QT_NO_DRAGANDDROP | - |
967 | void dragEnterEvent(QDragEnterEvent *e); | - |
968 | void dragLeaveEvent(QDragLeaveEvent *e); | - |
969 | void dropEvent(QDropEvent *e); | - |
970 | #endif | - |
971 | | - |
972 | private: | - |
973 | QColor col; | - |
974 | bool mousePressed; | - |
975 | QPoint pressPos; | - |
976 | }; | - |
977 | | - |
978 | void QColorShowLabel::paintEvent(QPaintEvent *e) | - |
979 | { | - |
980 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
981 | drawFrame(&p); executed (the execution status of this line is deduced): drawFrame(&p); | - |
982 | p.fillRect(contentsRect()&e->rect(), col); executed (the execution status of this line is deduced): p.fillRect(contentsRect()&e->rect(), col); | - |
983 | } executed: } Execution Count:2 | 2 |
984 | | - |
985 | void QColorShower::showAlpha(bool b) | - |
986 | { | - |
987 | alphaLab->setVisible(b); executed (the execution status of this line is deduced): alphaLab->setVisible(b); | - |
988 | alphaEd->setVisible(b); executed (the execution status of this line is deduced): alphaEd->setVisible(b); | - |
989 | } executed: } Execution Count:2 | 2 |
990 | | - |
991 | inline bool QColorShower::isAlphaVisible() const | - |
992 | { | - |
993 | return alphaLab->isVisible(); never executed: return alphaLab->isVisible(); | 0 |
994 | } | - |
995 | | - |
996 | void QColorShowLabel::mousePressEvent(QMouseEvent *e) | - |
997 | { | - |
998 | mousePressed = true; never executed (the execution status of this line is deduced): mousePressed = true; | - |
999 | pressPos = e->pos(); never executed (the execution status of this line is deduced): pressPos = e->pos(); | - |
1000 | } | 0 |
1001 | | - |
1002 | void QColorShowLabel::mouseMoveEvent(QMouseEvent *e) | - |
1003 | { | - |
1004 | #ifdef QT_NO_DRAGANDDROP | - |
1005 | Q_UNUSED(e); | - |
1006 | #else | - |
1007 | if (!mousePressed) never evaluated: !mousePressed | 0 |
1008 | return; | 0 |
1009 | if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { never evaluated: (pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance() | 0 |
1010 | QMimeData *mime = new QMimeData; never executed (the execution status of this line is deduced): QMimeData *mime = new QMimeData; | - |
1011 | mime->setColorData(col); never executed (the execution status of this line is deduced): mime->setColorData(col); | - |
1012 | QPixmap pix(30, 20); never executed (the execution status of this line is deduced): QPixmap pix(30, 20); | - |
1013 | pix.fill(col); never executed (the execution status of this line is deduced): pix.fill(col); | - |
1014 | QPainter p(&pix); never executed (the execution status of this line is deduced): QPainter p(&pix); | - |
1015 | p.drawRect(0, 0, pix.width() - 1, pix.height() - 1); never executed (the execution status of this line is deduced): p.drawRect(0, 0, pix.width() - 1, pix.height() - 1); | - |
1016 | p.end(); never executed (the execution status of this line is deduced): p.end(); | - |
1017 | QDrag *drg = new QDrag(this); never executed (the execution status of this line is deduced): QDrag *drg = new QDrag(this); | - |
1018 | drg->setMimeData(mime); never executed (the execution status of this line is deduced): drg->setMimeData(mime); | - |
1019 | drg->setPixmap(pix); never executed (the execution status of this line is deduced): drg->setPixmap(pix); | - |
1020 | mousePressed = false; never executed (the execution status of this line is deduced): mousePressed = false; | - |
1021 | drg->start(); never executed (the execution status of this line is deduced): drg->start(); | - |
1022 | } | 0 |
1023 | #endif | - |
1024 | } | 0 |
1025 | | - |
1026 | #ifndef QT_NO_DRAGANDDROP | - |
1027 | void QColorShowLabel::dragEnterEvent(QDragEnterEvent *e) | - |
1028 | { | - |
1029 | if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) never evaluated: qvariant_cast<QColor>(e->mimeData()->colorData()).isValid() | 0 |
1030 | e->accept(); never executed: e->accept(); | 0 |
1031 | else | - |
1032 | e->ignore(); never executed: e->ignore(); | 0 |
1033 | } | - |
1034 | | - |
1035 | void QColorShowLabel::dragLeaveEvent(QDragLeaveEvent *) | - |
1036 | { | - |
1037 | } | - |
1038 | | - |
1039 | void QColorShowLabel::dropEvent(QDropEvent *e) | - |
1040 | { | - |
1041 | QColor color = qvariant_cast<QColor>(e->mimeData()->colorData()); never executed (the execution status of this line is deduced): QColor color = qvariant_cast<QColor>(e->mimeData()->colorData()); | - |
1042 | if (color.isValid()) { never evaluated: color.isValid() | 0 |
1043 | col = color; never executed (the execution status of this line is deduced): col = color; | - |
1044 | repaint(); never executed (the execution status of this line is deduced): repaint(); | - |
1045 | emit colorDropped(col.rgb()); never executed (the execution status of this line is deduced): colorDropped(col.rgb()); | - |
1046 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1047 | } else { | 0 |
1048 | e->ignore(); never executed (the execution status of this line is deduced): e->ignore(); | - |
1049 | } | 0 |
1050 | } | - |
1051 | #endif // QT_NO_DRAGANDDROP | - |
1052 | | - |
1053 | void QColorShowLabel::mouseReleaseEvent(QMouseEvent *) | - |
1054 | { | - |
1055 | if (!mousePressed) never evaluated: !mousePressed | 0 |
1056 | return; | 0 |
1057 | mousePressed = false; never executed (the execution status of this line is deduced): mousePressed = false; | - |
1058 | } | 0 |
1059 | | - |
1060 | QColorShower::QColorShower(QColorDialog *parent) | - |
1061 | : QWidget(parent) | - |
1062 | { | - |
1063 | colorDialog = parent; executed (the execution status of this line is deduced): colorDialog = parent; | - |
1064 | | - |
1065 | curCol = qRgb(255, 255, 255); executed (the execution status of this line is deduced): curCol = qRgb(255, 255, 255); | - |
1066 | curQColor = Qt::white; executed (the execution status of this line is deduced): curQColor = Qt::white; | - |
1067 | | - |
1068 | QGridLayout *gl = new QGridLayout(this); executed (the execution status of this line is deduced): QGridLayout *gl = new QGridLayout(this); | - |
1069 | gl->setMargin(gl->spacing()); executed (the execution status of this line is deduced): gl->setMargin(gl->spacing()); | - |
1070 | lab = new QColorShowLabel(this); executed (the execution status of this line is deduced): lab = new QColorShowLabel(this); | - |
1071 | | - |
1072 | #ifndef Q_OS_WINCE | - |
1073 | #ifdef QT_SMALL_COLORDIALOG | - |
1074 | lab->setMinimumHeight(60); | - |
1075 | #endif | - |
1076 | lab->setMinimumWidth(60); executed (the execution status of this line is deduced): lab->setMinimumWidth(60); | - |
1077 | #else | - |
1078 | lab->setMinimumWidth(20); | - |
1079 | #endif | - |
1080 | | - |
1081 | // For QVGA screens only the comboboxes and color label are visible. | - |
1082 | // For nHD screens only color and luminence pickers and color label are visible. | - |
1083 | #if !defined(QT_SMALL_COLORDIALOG) | - |
1084 | gl->addWidget(lab, 0, 0, -1, 1); executed (the execution status of this line is deduced): gl->addWidget(lab, 0, 0, -1, 1); | - |
1085 | #else | - |
1086 | if (nonTouchUI) | - |
1087 | gl->addWidget(lab, 0, 0, 1, -1); | - |
1088 | else | - |
1089 | gl->addWidget(lab, 0, 0, -1, 1); | - |
1090 | #endif | - |
1091 | connect(lab, SIGNAL(colorDropped(QRgb)), this, SIGNAL(newCol(QRgb))); executed (the execution status of this line is deduced): connect(lab, "2""colorDropped(QRgb)", this, "2""newCol(QRgb)"); | - |
1092 | connect(lab, SIGNAL(colorDropped(QRgb)), this, SLOT(setRgb(QRgb))); executed (the execution status of this line is deduced): connect(lab, "2""colorDropped(QRgb)", this, "1""setRgb(QRgb)"); | - |
1093 | | - |
1094 | hEd = new QColSpinBox(this); executed (the execution status of this line is deduced): hEd = new QColSpinBox(this); | - |
1095 | hEd->setRange(0, 359); executed (the execution status of this line is deduced): hEd->setRange(0, 359); | - |
1096 | lblHue = new QLabel(this); executed (the execution status of this line is deduced): lblHue = new QLabel(this); | - |
1097 | #ifndef QT_NO_SHORTCUT | - |
1098 | lblHue->setBuddy(hEd); executed (the execution status of this line is deduced): lblHue->setBuddy(hEd); | - |
1099 | #endif | - |
1100 | lblHue->setAlignment(Qt::AlignRight|Qt::AlignVCenter); executed (the execution status of this line is deduced): lblHue->setAlignment(Qt::AlignRight|Qt::AlignVCenter); | - |
1101 | #if !defined(QT_SMALL_COLORDIALOG) | - |
1102 | gl->addWidget(lblHue, 0, 1); executed (the execution status of this line is deduced): gl->addWidget(lblHue, 0, 1); | - |
1103 | gl->addWidget(hEd, 0, 2); executed (the execution status of this line is deduced): gl->addWidget(hEd, 0, 2); | - |
1104 | #else | - |
1105 | if (nonTouchUI) { | - |
1106 | gl->addWidget(lblHue, 1, 0); | - |
1107 | gl->addWidget(hEd, 2, 0); | - |
1108 | } else { | - |
1109 | lblHue->hide(); | - |
1110 | hEd->hide(); | - |
1111 | } | - |
1112 | #endif | - |
1113 | | - |
1114 | sEd = new QColSpinBox(this); executed (the execution status of this line is deduced): sEd = new QColSpinBox(this); | - |
1115 | lblSat = new QLabel(this); executed (the execution status of this line is deduced): lblSat = new QLabel(this); | - |
1116 | #ifndef QT_NO_SHORTCUT | - |
1117 | lblSat->setBuddy(sEd); executed (the execution status of this line is deduced): lblSat->setBuddy(sEd); | - |
1118 | #endif | - |
1119 | lblSat->setAlignment(Qt::AlignRight|Qt::AlignVCenter); executed (the execution status of this line is deduced): lblSat->setAlignment(Qt::AlignRight|Qt::AlignVCenter); | - |
1120 | #if !defined(QT_SMALL_COLORDIALOG) | - |
1121 | gl->addWidget(lblSat, 1, 1); executed (the execution status of this line is deduced): gl->addWidget(lblSat, 1, 1); | - |
1122 | gl->addWidget(sEd, 1, 2); executed (the execution status of this line is deduced): gl->addWidget(sEd, 1, 2); | - |
1123 | #else | - |
1124 | if (nonTouchUI) { | - |
1125 | gl->addWidget(lblSat, 1, 1); | - |
1126 | gl->addWidget(sEd, 2, 1); | - |
1127 | } else { | - |
1128 | lblSat->hide(); | - |
1129 | sEd->hide(); | - |
1130 | } | - |
1131 | #endif | - |
1132 | | - |
1133 | vEd = new QColSpinBox(this); executed (the execution status of this line is deduced): vEd = new QColSpinBox(this); | - |
1134 | lblVal = new QLabel(this); executed (the execution status of this line is deduced): lblVal = new QLabel(this); | - |
1135 | #ifndef QT_NO_SHORTCUT | - |
1136 | lblVal->setBuddy(vEd); executed (the execution status of this line is deduced): lblVal->setBuddy(vEd); | - |
1137 | #endif | - |
1138 | lblVal->setAlignment(Qt::AlignRight|Qt::AlignVCenter); executed (the execution status of this line is deduced): lblVal->setAlignment(Qt::AlignRight|Qt::AlignVCenter); | - |
1139 | #if !defined(QT_SMALL_COLORDIALOG) | - |
1140 | gl->addWidget(lblVal, 2, 1); executed (the execution status of this line is deduced): gl->addWidget(lblVal, 2, 1); | - |
1141 | gl->addWidget(vEd, 2, 2); executed (the execution status of this line is deduced): gl->addWidget(vEd, 2, 2); | - |
1142 | #else | - |
1143 | if (nonTouchUI) { | - |
1144 | gl->addWidget(lblVal, 1, 2); | - |
1145 | gl->addWidget(vEd, 2, 2); | - |
1146 | } else { | - |
1147 | lblVal->hide(); | - |
1148 | vEd->hide(); | - |
1149 | } | - |
1150 | #endif | - |
1151 | | - |
1152 | rEd = new QColSpinBox(this); executed (the execution status of this line is deduced): rEd = new QColSpinBox(this); | - |
1153 | lblRed = new QLabel(this); executed (the execution status of this line is deduced): lblRed = new QLabel(this); | - |
1154 | #ifndef QT_NO_SHORTCUT | - |
1155 | lblRed->setBuddy(rEd); executed (the execution status of this line is deduced): lblRed->setBuddy(rEd); | - |
1156 | #endif | - |
1157 | lblRed->setAlignment(Qt::AlignRight|Qt::AlignVCenter); executed (the execution status of this line is deduced): lblRed->setAlignment(Qt::AlignRight|Qt::AlignVCenter); | - |
1158 | #if !defined(QT_SMALL_COLORDIALOG) | - |
1159 | gl->addWidget(lblRed, 0, 3); executed (the execution status of this line is deduced): gl->addWidget(lblRed, 0, 3); | - |
1160 | gl->addWidget(rEd, 0, 4); executed (the execution status of this line is deduced): gl->addWidget(rEd, 0, 4); | - |
1161 | #else | - |
1162 | if (nonTouchUI) { | - |
1163 | gl->addWidget(lblRed, 3, 0); | - |
1164 | gl->addWidget(rEd, 4, 0); | - |
1165 | } else { | - |
1166 | lblRed->hide(); | - |
1167 | rEd->hide(); | - |
1168 | } | - |
1169 | #endif | - |
1170 | | - |
1171 | gEd = new QColSpinBox(this); executed (the execution status of this line is deduced): gEd = new QColSpinBox(this); | - |
1172 | lblGreen = new QLabel(this); executed (the execution status of this line is deduced): lblGreen = new QLabel(this); | - |
1173 | #ifndef QT_NO_SHORTCUT | - |
1174 | lblGreen->setBuddy(gEd); executed (the execution status of this line is deduced): lblGreen->setBuddy(gEd); | - |
1175 | #endif | - |
1176 | lblGreen->setAlignment(Qt::AlignRight|Qt::AlignVCenter); executed (the execution status of this line is deduced): lblGreen->setAlignment(Qt::AlignRight|Qt::AlignVCenter); | - |
1177 | #if !defined(QT_SMALL_COLORDIALOG) | - |
1178 | gl->addWidget(lblGreen, 1, 3); executed (the execution status of this line is deduced): gl->addWidget(lblGreen, 1, 3); | - |
1179 | gl->addWidget(gEd, 1, 4); executed (the execution status of this line is deduced): gl->addWidget(gEd, 1, 4); | - |
1180 | #else | - |
1181 | if (nonTouchUI) { | - |
1182 | gl->addWidget(lblGreen, 3, 1); | - |
1183 | gl->addWidget(gEd, 4, 1); | - |
1184 | } else { | - |
1185 | lblGreen->hide(); | - |
1186 | gEd->hide(); | - |
1187 | } | - |
1188 | #endif | - |
1189 | | - |
1190 | bEd = new QColSpinBox(this); executed (the execution status of this line is deduced): bEd = new QColSpinBox(this); | - |
1191 | lblBlue = new QLabel(this); executed (the execution status of this line is deduced): lblBlue = new QLabel(this); | - |
1192 | #ifndef QT_NO_SHORTCUT | - |
1193 | lblBlue->setBuddy(bEd); executed (the execution status of this line is deduced): lblBlue->setBuddy(bEd); | - |
1194 | #endif | - |
1195 | lblBlue->setAlignment(Qt::AlignRight|Qt::AlignVCenter); executed (the execution status of this line is deduced): lblBlue->setAlignment(Qt::AlignRight|Qt::AlignVCenter); | - |
1196 | #if !defined(QT_SMALL_COLORDIALOG) | - |
1197 | gl->addWidget(lblBlue, 2, 3); executed (the execution status of this line is deduced): gl->addWidget(lblBlue, 2, 3); | - |
1198 | gl->addWidget(bEd, 2, 4); executed (the execution status of this line is deduced): gl->addWidget(bEd, 2, 4); | - |
1199 | #else | - |
1200 | if (nonTouchUI) { | - |
1201 | gl->addWidget(lblBlue, 3, 2); | - |
1202 | gl->addWidget(bEd, 4, 2); | - |
1203 | } else { | - |
1204 | lblBlue->hide(); | - |
1205 | bEd->hide(); | - |
1206 | } | - |
1207 | #endif | - |
1208 | | - |
1209 | alphaEd = new QColSpinBox(this); executed (the execution status of this line is deduced): alphaEd = new QColSpinBox(this); | - |
1210 | alphaLab = new QLabel(this); executed (the execution status of this line is deduced): alphaLab = new QLabel(this); | - |
1211 | #ifndef QT_NO_SHORTCUT | - |
1212 | alphaLab->setBuddy(alphaEd); executed (the execution status of this line is deduced): alphaLab->setBuddy(alphaEd); | - |
1213 | #endif | - |
1214 | alphaLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter); executed (the execution status of this line is deduced): alphaLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter); | - |
1215 | #if !defined(QT_SMALL_COLORDIALOG) | - |
1216 | gl->addWidget(alphaLab, 3, 1, 1, 3); executed (the execution status of this line is deduced): gl->addWidget(alphaLab, 3, 1, 1, 3); | - |
1217 | gl->addWidget(alphaEd, 3, 4); executed (the execution status of this line is deduced): gl->addWidget(alphaEd, 3, 4); | - |
1218 | #else | - |
1219 | if (nonTouchUI) { | - |
1220 | gl->addWidget(alphaLab, 1, 3, 3, 1); | - |
1221 | gl->addWidget(alphaEd, 4, 3); | - |
1222 | } else { | - |
1223 | alphaLab->hide(); | - |
1224 | alphaEd->hide(); | - |
1225 | } | - |
1226 | #endif | - |
1227 | alphaEd->hide(); executed (the execution status of this line is deduced): alphaEd->hide(); | - |
1228 | alphaLab->hide(); executed (the execution status of this line is deduced): alphaLab->hide(); | - |
1229 | | - |
1230 | connect(hEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd())); executed (the execution status of this line is deduced): connect(hEd, "2""valueChanged(int)", this, "1""hsvEd()"); | - |
1231 | connect(sEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd())); executed (the execution status of this line is deduced): connect(sEd, "2""valueChanged(int)", this, "1""hsvEd()"); | - |
1232 | connect(vEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd())); executed (the execution status of this line is deduced): connect(vEd, "2""valueChanged(int)", this, "1""hsvEd()"); | - |
1233 | | - |
1234 | connect(rEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd())); executed (the execution status of this line is deduced): connect(rEd, "2""valueChanged(int)", this, "1""rgbEd()"); | - |
1235 | connect(gEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd())); executed (the execution status of this line is deduced): connect(gEd, "2""valueChanged(int)", this, "1""rgbEd()"); | - |
1236 | connect(bEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd())); executed (the execution status of this line is deduced): connect(bEd, "2""valueChanged(int)", this, "1""rgbEd()"); | - |
1237 | connect(alphaEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd())); executed (the execution status of this line is deduced): connect(alphaEd, "2""valueChanged(int)", this, "1""rgbEd()"); | - |
1238 | | - |
1239 | retranslateStrings(); executed (the execution status of this line is deduced): retranslateStrings(); | - |
1240 | } executed: } Execution Count:3 | 3 |
1241 | | - |
1242 | inline QRgb QColorDialogPrivate::currentColor() const { return cs->currentColor(); } never executed: return cs->currentColor(); | 0 |
1243 | inline int QColorDialogPrivate::currentAlpha() const { return cs->currentAlpha(); } never executed: return cs->currentAlpha(); | 0 |
1244 | inline void QColorDialogPrivate::setCurrentAlpha(int a) { cs->setCurrentAlpha(a); } executed: } Execution Count:5 | 5 |
1245 | inline void QColorDialogPrivate::showAlpha(bool b) { cs->showAlpha(b); } executed: } Execution Count:2 | 2 |
1246 | inline bool QColorDialogPrivate::isAlphaVisible() const { return cs->isAlphaVisible(); } never executed: return cs->isAlphaVisible(); | 0 |
1247 | | - |
1248 | QColor QColorDialogPrivate::currentQColor() const | - |
1249 | { | - |
1250 | if (!options->testOption(QColorDialogOptions::DontUseNativeDialog) && nativeDialogInUse) partially evaluated: !options->testOption(QColorDialogOptions::DontUseNativeDialog) yes Evaluation Count:3 | no Evaluation Count:0 |
partially evaluated: nativeDialogInUse no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1251 | return platformColorDialogHelper()->currentColor(); never executed: return platformColorDialogHelper()->currentColor(); | 0 |
1252 | return cs->currentQColor(); executed: return cs->currentQColor(); Execution Count:3 | 3 |
1253 | } | - |
1254 | | - |
1255 | void QColorShower::showCurrentColor() | - |
1256 | { | - |
1257 | lab->setColor(currentColor()); executed (the execution status of this line is deduced): lab->setColor(currentColor()); | - |
1258 | lab->repaint(); executed (the execution status of this line is deduced): lab->repaint(); | - |
1259 | } executed: } Execution Count:18 | 18 |
1260 | | - |
1261 | void QColorShower::rgbEd() | - |
1262 | { | - |
1263 | rgbOriginal = true; executed (the execution status of this line is deduced): rgbOriginal = true; | - |
1264 | curCol = qRgba(rEd->value(), gEd->value(), bEd->value(), currentAlpha()); executed (the execution status of this line is deduced): curCol = qRgba(rEd->value(), gEd->value(), bEd->value(), currentAlpha()); | - |
1265 | | - |
1266 | rgb2hsv(currentColor(), hue, sat, val); executed (the execution status of this line is deduced): rgb2hsv(currentColor(), hue, sat, val); | - |
1267 | | - |
1268 | hEd->setValue(hue); executed (the execution status of this line is deduced): hEd->setValue(hue); | - |
1269 | sEd->setValue(sat); executed (the execution status of this line is deduced): sEd->setValue(sat); | - |
1270 | vEd->setValue(val); executed (the execution status of this line is deduced): vEd->setValue(val); | - |
1271 | | - |
1272 | showCurrentColor(); executed (the execution status of this line is deduced): showCurrentColor(); | - |
1273 | emit newCol(currentColor()); executed (the execution status of this line is deduced): newCol(currentColor()); | - |
1274 | updateQColor(); executed (the execution status of this line is deduced): updateQColor(); | - |
1275 | } executed: } Execution Count:5 | 5 |
1276 | | - |
1277 | void QColorShower::hsvEd() | - |
1278 | { | - |
1279 | rgbOriginal = false; never executed (the execution status of this line is deduced): rgbOriginal = false; | - |
1280 | hue = hEd->value(); never executed (the execution status of this line is deduced): hue = hEd->value(); | - |
1281 | sat = sEd->value(); never executed (the execution status of this line is deduced): sat = sEd->value(); | - |
1282 | val = vEd->value(); never executed (the execution status of this line is deduced): val = vEd->value(); | - |
1283 | | - |
1284 | QColor c; never executed (the execution status of this line is deduced): QColor c; | - |
1285 | c.setHsv(hue, sat, val); never executed (the execution status of this line is deduced): c.setHsv(hue, sat, val); | - |
1286 | curCol = c.rgb(); never executed (the execution status of this line is deduced): curCol = c.rgb(); | - |
1287 | | - |
1288 | rEd->setValue(qRed(currentColor())); never executed (the execution status of this line is deduced): rEd->setValue(qRed(currentColor())); | - |
1289 | gEd->setValue(qGreen(currentColor())); never executed (the execution status of this line is deduced): gEd->setValue(qGreen(currentColor())); | - |
1290 | bEd->setValue(qBlue(currentColor())); never executed (the execution status of this line is deduced): bEd->setValue(qBlue(currentColor())); | - |
1291 | | - |
1292 | showCurrentColor(); never executed (the execution status of this line is deduced): showCurrentColor(); | - |
1293 | emit newCol(currentColor()); never executed (the execution status of this line is deduced): newCol(currentColor()); | - |
1294 | updateQColor(); never executed (the execution status of this line is deduced): updateQColor(); | - |
1295 | } | 0 |
1296 | | - |
1297 | void QColorShower::setRgb(QRgb rgb) | - |
1298 | { | - |
1299 | rgbOriginal = true; executed (the execution status of this line is deduced): rgbOriginal = true; | - |
1300 | curCol = rgb; executed (the execution status of this line is deduced): curCol = rgb; | - |
1301 | | - |
1302 | rgb2hsv(currentColor(), hue, sat, val); executed (the execution status of this line is deduced): rgb2hsv(currentColor(), hue, sat, val); | - |
1303 | | - |
1304 | hEd->setValue(hue); executed (the execution status of this line is deduced): hEd->setValue(hue); | - |
1305 | sEd->setValue(sat); executed (the execution status of this line is deduced): sEd->setValue(sat); | - |
1306 | vEd->setValue(val); executed (the execution status of this line is deduced): vEd->setValue(val); | - |
1307 | | - |
1308 | rEd->setValue(qRed(currentColor())); executed (the execution status of this line is deduced): rEd->setValue(qRed(currentColor())); | - |
1309 | gEd->setValue(qGreen(currentColor())); executed (the execution status of this line is deduced): gEd->setValue(qGreen(currentColor())); | - |
1310 | bEd->setValue(qBlue(currentColor())); executed (the execution status of this line is deduced): bEd->setValue(qBlue(currentColor())); | - |
1311 | | - |
1312 | showCurrentColor(); executed (the execution status of this line is deduced): showCurrentColor(); | - |
1313 | updateQColor(); executed (the execution status of this line is deduced): updateQColor(); | - |
1314 | } executed: } Execution Count:13 | 13 |
1315 | | - |
1316 | void QColorShower::setHsv(int h, int s, int v) | - |
1317 | { | - |
1318 | if (h < -1 || (uint)s > 255 || (uint)v > 255) never evaluated: h < -1 never evaluated: (uint)s > 255 never evaluated: (uint)v > 255 | 0 |
1319 | return; | 0 |
1320 | | - |
1321 | rgbOriginal = false; never executed (the execution status of this line is deduced): rgbOriginal = false; | - |
1322 | hue = h; val = v; sat = s; never executed (the execution status of this line is deduced): hue = h; val = v; sat = s; | - |
1323 | QColor c; never executed (the execution status of this line is deduced): QColor c; | - |
1324 | c.setHsv(hue, sat, val); never executed (the execution status of this line is deduced): c.setHsv(hue, sat, val); | - |
1325 | curCol = c.rgb(); never executed (the execution status of this line is deduced): curCol = c.rgb(); | - |
1326 | | - |
1327 | hEd->setValue(hue); never executed (the execution status of this line is deduced): hEd->setValue(hue); | - |
1328 | sEd->setValue(sat); never executed (the execution status of this line is deduced): sEd->setValue(sat); | - |
1329 | vEd->setValue(val); never executed (the execution status of this line is deduced): vEd->setValue(val); | - |
1330 | | - |
1331 | rEd->setValue(qRed(currentColor())); never executed (the execution status of this line is deduced): rEd->setValue(qRed(currentColor())); | - |
1332 | gEd->setValue(qGreen(currentColor())); never executed (the execution status of this line is deduced): gEd->setValue(qGreen(currentColor())); | - |
1333 | bEd->setValue(qBlue(currentColor())); never executed (the execution status of this line is deduced): bEd->setValue(qBlue(currentColor())); | - |
1334 | | - |
1335 | showCurrentColor(); never executed (the execution status of this line is deduced): showCurrentColor(); | - |
1336 | updateQColor(); never executed (the execution status of this line is deduced): updateQColor(); | - |
1337 | } | 0 |
1338 | | - |
1339 | void QColorShower::retranslateStrings() | - |
1340 | { | - |
1341 | lblHue->setText(QColorDialog::tr("Hu&e:")); executed (the execution status of this line is deduced): lblHue->setText(QColorDialog::tr("Hu&e:")); | - |
1342 | lblSat->setText(QColorDialog::tr("&Sat:")); executed (the execution status of this line is deduced): lblSat->setText(QColorDialog::tr("&Sat:")); | - |
1343 | lblVal->setText(QColorDialog::tr("&Val:")); executed (the execution status of this line is deduced): lblVal->setText(QColorDialog::tr("&Val:")); | - |
1344 | lblRed->setText(QColorDialog::tr("&Red:")); executed (the execution status of this line is deduced): lblRed->setText(QColorDialog::tr("&Red:")); | - |
1345 | lblGreen->setText(QColorDialog::tr("&Green:")); executed (the execution status of this line is deduced): lblGreen->setText(QColorDialog::tr("&Green:")); | - |
1346 | lblBlue->setText(QColorDialog::tr("Bl&ue:")); executed (the execution status of this line is deduced): lblBlue->setText(QColorDialog::tr("Bl&ue:")); | - |
1347 | alphaLab->setText(QColorDialog::tr("A&lpha channel:")); executed (the execution status of this line is deduced): alphaLab->setText(QColorDialog::tr("A&lpha channel:")); | - |
1348 | } executed: } Execution Count:6 | 6 |
1349 | | - |
1350 | void QColorShower::updateQColor() | - |
1351 | { | - |
1352 | QColor oldQColor(curQColor); executed (the execution status of this line is deduced): QColor oldQColor(curQColor); | - |
1353 | curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), currentAlpha())); executed (the execution status of this line is deduced): curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), currentAlpha())); | - |
1354 | if (curQColor != oldQColor) evaluated: curQColor != oldQColor yes Evaluation Count:2 | yes Evaluation Count:16 |
| 2-16 |
1355 | emit currentColorChanged(curQColor); executed: currentColorChanged(curQColor); Execution Count:2 | 2 |
1356 | } executed: } Execution Count:18 | 18 |
1357 | | - |
1358 | //sets all widgets to display h,s,v | - |
1359 | void QColorDialogPrivate::_q_newHsv(int h, int s, int v) | - |
1360 | { | - |
1361 | cs->setHsv(h, s, v); never executed (the execution status of this line is deduced): cs->setHsv(h, s, v); | - |
1362 | cp->setCol(h, s); never executed (the execution status of this line is deduced): cp->setCol(h, s); | - |
1363 | lp->setCol(h, s, v); never executed (the execution status of this line is deduced): lp->setCol(h, s, v); | - |
1364 | } | 0 |
1365 | | - |
1366 | //sets all widgets to display rgb | - |
1367 | void QColorDialogPrivate::setCurrentColor(QRgb rgb) | - |
1368 | { | - |
1369 | cs->setRgb(rgb); executed (the execution status of this line is deduced): cs->setRgb(rgb); | - |
1370 | _q_newColorTypedIn(rgb); executed (the execution status of this line is deduced): _q_newColorTypedIn(rgb); | - |
1371 | } executed: } Execution Count:13 | 13 |
1372 | | - |
1373 | // hack; doesn't keep curCol in sync, so use with care | - |
1374 | void QColorDialogPrivate::setCurrentQColor(const QColor &color) | - |
1375 | { | - |
1376 | Q_Q(QColorDialog); never executed (the execution status of this line is deduced): QColorDialog * const q = q_func(); | - |
1377 | if (cs->curQColor != color) { never evaluated: cs->curQColor != color | 0 |
1378 | cs->curQColor = color; never executed (the execution status of this line is deduced): cs->curQColor = color; | - |
1379 | emit q->currentColorChanged(color); never executed (the execution status of this line is deduced): q->currentColorChanged(color); | - |
1380 | } | 0 |
1381 | } | 0 |
1382 | | - |
1383 | bool QColorDialogPrivate::selectColor(const QColor &col) | - |
1384 | { | - |
1385 | QRgb color = col.rgb(); executed (the execution status of this line is deduced): QRgb color = col.rgb(); | - |
1386 | int i = 0, j = 0; executed (the execution status of this line is deduced): int i = 0, j = 0; | - |
1387 | // Check standard colors | - |
1388 | if (standard) { partially evaluated: standard yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1389 | const QRgb *standardColors = QColorDialogOptions::standardColors(); executed (the execution status of this line is deduced): const QRgb *standardColors = QColorDialogOptions::standardColors(); | - |
1390 | for (i = 0; i < 6; i++) { evaluated: i < 6 yes Evaluation Count:30 | yes Evaluation Count:1 |
| 1-30 |
1391 | for (j = 0; j < 8; j++) { evaluated: j < 8 yes Evaluation Count:240 | yes Evaluation Count:26 |
| 26-240 |
1392 | if (color == standardColors[i + j*6]) { evaluated: color == standardColors[i + j*6] yes Evaluation Count:4 | yes Evaluation Count:236 |
| 4-236 |
1393 | _q_newStandard(i, j); executed (the execution status of this line is deduced): _q_newStandard(i, j); | - |
1394 | standard->setCurrent(i, j); executed (the execution status of this line is deduced): standard->setCurrent(i, j); | - |
1395 | standard->setSelected(i, j); executed (the execution status of this line is deduced): standard->setSelected(i, j); | - |
1396 | standard->setFocus(); executed (the execution status of this line is deduced): standard->setFocus(); | - |
1397 | return true; executed: return true; Execution Count:4 | 4 |
1398 | } | - |
1399 | } executed: } Execution Count:236 | 236 |
1400 | } executed: } Execution Count:26 | 26 |
1401 | } executed: } Execution Count:1 | 1 |
1402 | // Check custom colors | - |
1403 | if (custom) { partially evaluated: custom yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1404 | const QRgb *customColors = QColorDialogOptions::customColors(); executed (the execution status of this line is deduced): const QRgb *customColors = QColorDialogOptions::customColors(); | - |
1405 | for (i = 0; i < 2; i++) { evaluated: i < 2 yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
1406 | for (j = 0; j < 8; j++) { evaluated: j < 8 yes Evaluation Count:16 | yes Evaluation Count:2 |
| 2-16 |
1407 | if (color == customColors[i + j*2]) { partially evaluated: color == customColors[i + j*2] no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
1408 | _q_newCustom(i, j); never executed (the execution status of this line is deduced): _q_newCustom(i, j); | - |
1409 | custom->setCurrent(i, j); never executed (the execution status of this line is deduced): custom->setCurrent(i, j); | - |
1410 | custom->setSelected(i, j); never executed (the execution status of this line is deduced): custom->setSelected(i, j); | - |
1411 | custom->setFocus(); never executed (the execution status of this line is deduced): custom->setFocus(); | - |
1412 | return true; never executed: return true; | 0 |
1413 | } | - |
1414 | } executed: } Execution Count:16 | 16 |
1415 | } executed: } Execution Count:2 | 2 |
1416 | } executed: } Execution Count:1 | 1 |
1417 | return false; executed: return false; Execution Count:1 | 1 |
1418 | } | - |
1419 | | - |
1420 | //sets all widgets except cs to display rgb | - |
1421 | void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb) | - |
1422 | { | - |
1423 | int h, s, v; executed (the execution status of this line is deduced): int h, s, v; | - |
1424 | rgb2hsv(rgb, h, s, v); executed (the execution status of this line is deduced): rgb2hsv(rgb, h, s, v); | - |
1425 | cp->setCol(h, s); executed (the execution status of this line is deduced): cp->setCol(h, s); | - |
1426 | lp->setCol(h, s, v); executed (the execution status of this line is deduced): lp->setCol(h, s, v); | - |
1427 | } executed: } Execution Count:18 | 18 |
1428 | | - |
1429 | void QColorDialogPrivate::_q_newCustom(int r, int c) | - |
1430 | { | - |
1431 | const int i = r + 2 * c; never executed (the execution status of this line is deduced): const int i = r + 2 * c; | - |
1432 | setCurrentColor(QColorDialogOptions::customColor(i)); never executed (the execution status of this line is deduced): setCurrentColor(QColorDialogOptions::customColor(i)); | - |
1433 | nextCust = i; never executed (the execution status of this line is deduced): nextCust = i; | - |
1434 | if (standard) never evaluated: standard | 0 |
1435 | standard->setSelected(-1,-1); never executed: standard->setSelected(-1,-1); | 0 |
1436 | } | 0 |
1437 | | - |
1438 | void QColorDialogPrivate::_q_newStandard(int r, int c) | - |
1439 | { | - |
1440 | setCurrentColor(QColorDialogOptions::standardColor(r + c * 6)); executed (the execution status of this line is deduced): setCurrentColor(QColorDialogOptions::standardColor(r + c * 6)); | - |
1441 | if (custom) partially evaluated: custom yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
1442 | custom->setSelected(-1,-1); executed: custom->setSelected(-1,-1); Execution Count:8 | 8 |
1443 | } executed: } Execution Count:8 | 8 |
1444 | | - |
1445 | void QColorDialogPrivate::init(const QColor &initial) | - |
1446 | { | - |
1447 | Q_Q(QColorDialog); executed (the execution status of this line is deduced): QColorDialog * const q = q_func(); | - |
1448 | | - |
1449 | q->setSizeGripEnabled(false); executed (the execution status of this line is deduced): q->setSizeGripEnabled(false); | - |
1450 | q->setWindowTitle(QColorDialog::tr("Select Color")); executed (the execution status of this line is deduced): q->setWindowTitle(QColorDialog::tr("Select Color")); | - |
1451 | | - |
1452 | nativeDialogInUse = (platformColorDialogHelper() != 0); executed (the execution status of this line is deduced): nativeDialogInUse = (platformColorDialogHelper() != 0); | - |
1453 | | - |
1454 | nextCust = 0; executed (the execution status of this line is deduced): nextCust = 0; | - |
1455 | QVBoxLayout *mainLay = new QVBoxLayout(q); executed (the execution status of this line is deduced): QVBoxLayout *mainLay = new QVBoxLayout(q); | - |
1456 | // there's nothing in this dialog that benefits from sizing up | - |
1457 | mainLay->setSizeConstraint(QLayout::SetFixedSize); executed (the execution status of this line is deduced): mainLay->setSizeConstraint(QLayout::SetFixedSize); | - |
1458 | | - |
1459 | QHBoxLayout *topLay = new QHBoxLayout(); executed (the execution status of this line is deduced): QHBoxLayout *topLay = new QHBoxLayout(); | - |
1460 | mainLay->addLayout(topLay); executed (the execution status of this line is deduced): mainLay->addLayout(topLay); | - |
1461 | | - |
1462 | leftLay = 0; executed (the execution status of this line is deduced): leftLay = 0; | - |
1463 | | - |
1464 | #if defined(Q_OS_WINCE) || defined(QT_SMALL_COLORDIALOG) | - |
1465 | smallDisplay = true; | - |
1466 | const int lumSpace = 20; | - |
1467 | #else | - |
1468 | // small displays (e.g. PDAs) cannot fit the full color dialog, | - |
1469 | // so just use the color picker. | - |
1470 | smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350); partially evaluated: QApplication::desktop()->width() < 480 no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: QApplication::desktop()->height() < 350 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1471 | const int lumSpace = topLay->spacing() / 2; executed (the execution status of this line is deduced): const int lumSpace = topLay->spacing() / 2; | - |
1472 | #endif | - |
1473 | | - |
1474 | if (!smallDisplay) { partially evaluated: !smallDisplay yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1475 | leftLay = new QVBoxLayout; executed (the execution status of this line is deduced): leftLay = new QVBoxLayout; | - |
1476 | topLay->addLayout(leftLay); executed (the execution status of this line is deduced): topLay->addLayout(leftLay); | - |
1477 | } executed: } Execution Count:3 | 3 |
1478 | | - |
1479 | if (!smallDisplay) { partially evaluated: !smallDisplay yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1480 | standard = new QColorWell(q, 6, 8, QColorDialogOptions::standardColors()); executed (the execution status of this line is deduced): standard = new QColorWell(q, 6, 8, QColorDialogOptions::standardColors()); | - |
1481 | lblBasicColors = new QLabel(q); executed (the execution status of this line is deduced): lblBasicColors = new QLabel(q); | - |
1482 | #ifndef QT_NO_SHORTCUT | - |
1483 | lblBasicColors->setBuddy(standard); executed (the execution status of this line is deduced): lblBasicColors->setBuddy(standard); | - |
1484 | #endif | - |
1485 | q->connect(standard, SIGNAL(selected(int,int)), SLOT(_q_newStandard(int,int))); executed (the execution status of this line is deduced): q->connect(standard, "2""selected(int,int)", "1""_q_newStandard(int,int)"); | - |
1486 | leftLay->addWidget(lblBasicColors); executed (the execution status of this line is deduced): leftLay->addWidget(lblBasicColors); | - |
1487 | leftLay->addWidget(standard); executed (the execution status of this line is deduced): leftLay->addWidget(standard); | - |
1488 | | - |
1489 | #if !defined(Q_OS_WINCE) | - |
1490 | leftLay->addStretch(); executed (the execution status of this line is deduced): leftLay->addStretch(); | - |
1491 | #endif | - |
1492 | | - |
1493 | custom = new QColorWell(q, 2, 8, QColorDialogOptions::customColors()); executed (the execution status of this line is deduced): custom = new QColorWell(q, 2, 8, QColorDialogOptions::customColors()); | - |
1494 | custom->setAcceptDrops(true); executed (the execution status of this line is deduced): custom->setAcceptDrops(true); | - |
1495 | | - |
1496 | q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int))); executed (the execution status of this line is deduced): q->connect(custom, "2""selected(int,int)", "1""_q_newCustom(int,int)"); | - |
1497 | lblCustomColors = new QLabel(q); executed (the execution status of this line is deduced): lblCustomColors = new QLabel(q); | - |
1498 | #ifndef QT_NO_SHORTCUT | - |
1499 | lblCustomColors->setBuddy(custom); executed (the execution status of this line is deduced): lblCustomColors->setBuddy(custom); | - |
1500 | #endif | - |
1501 | leftLay->addWidget(lblCustomColors); executed (the execution status of this line is deduced): leftLay->addWidget(lblCustomColors); | - |
1502 | leftLay->addWidget(custom); executed (the execution status of this line is deduced): leftLay->addWidget(custom); | - |
1503 | | - |
1504 | addCusBt = new QPushButton(q); executed (the execution status of this line is deduced): addCusBt = new QPushButton(q); | - |
1505 | QObject::connect(addCusBt, SIGNAL(clicked()), q, SLOT(_q_addCustom())); executed (the execution status of this line is deduced): QObject::connect(addCusBt, "2""clicked()", q, "1""_q_addCustom()"); | - |
1506 | leftLay->addWidget(addCusBt); executed (the execution status of this line is deduced): leftLay->addWidget(addCusBt); | - |
1507 | } else { executed: } Execution Count:3 | 3 |
1508 | // better color picker size for small displays | - |
1509 | #if defined(QT_SMALL_COLORDIALOG) | - |
1510 | QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); | - |
1511 | pWidth = pHeight = qMin(screenSize.width(), screenSize.height()); | - |
1512 | pHeight -= 20; | - |
1513 | if(screenSize.height() > screenSize.width()) | - |
1514 | pWidth -= 20; | - |
1515 | #else | - |
1516 | pWidth = 150; never executed (the execution status of this line is deduced): pWidth = 150; | - |
1517 | pHeight = 100; never executed (the execution status of this line is deduced): pHeight = 100; | - |
1518 | #endif | - |
1519 | custom = 0; never executed (the execution status of this line is deduced): custom = 0; | - |
1520 | standard = 0; never executed (the execution status of this line is deduced): standard = 0; | - |
1521 | } | 0 |
1522 | | - |
1523 | QVBoxLayout *rightLay = new QVBoxLayout; executed (the execution status of this line is deduced): QVBoxLayout *rightLay = new QVBoxLayout; | - |
1524 | topLay->addLayout(rightLay); executed (the execution status of this line is deduced): topLay->addLayout(rightLay); | - |
1525 | | - |
1526 | QHBoxLayout *pickLay = new QHBoxLayout; executed (the execution status of this line is deduced): QHBoxLayout *pickLay = new QHBoxLayout; | - |
1527 | rightLay->addLayout(pickLay); executed (the execution status of this line is deduced): rightLay->addLayout(pickLay); | - |
1528 | | - |
1529 | QVBoxLayout *cLay = new QVBoxLayout; executed (the execution status of this line is deduced): QVBoxLayout *cLay = new QVBoxLayout; | - |
1530 | pickLay->addLayout(cLay); executed (the execution status of this line is deduced): pickLay->addLayout(cLay); | - |
1531 | cp = new QColorPicker(q); executed (the execution status of this line is deduced): cp = new QColorPicker(q); | - |
1532 | | - |
1533 | cp->setFrameStyle(QFrame::Panel + QFrame::Sunken); executed (the execution status of this line is deduced): cp->setFrameStyle(QFrame::Panel + QFrame::Sunken); | - |
1534 | | - |
1535 | #if defined(QT_SMALL_COLORDIALOG) | - |
1536 | if (!nonTouchUI) { | - |
1537 | pickLay->addWidget(cp); | - |
1538 | cLay->addSpacing(lumSpace); | - |
1539 | } else { | - |
1540 | cp->hide(); | - |
1541 | } | - |
1542 | #else | - |
1543 | cLay->addSpacing(lumSpace); executed (the execution status of this line is deduced): cLay->addSpacing(lumSpace); | - |
1544 | cLay->addWidget(cp); executed (the execution status of this line is deduced): cLay->addWidget(cp); | - |
1545 | #endif | - |
1546 | cLay->addSpacing(lumSpace); executed (the execution status of this line is deduced): cLay->addSpacing(lumSpace); | - |
1547 | | - |
1548 | lp = new QColorLuminancePicker(q); executed (the execution status of this line is deduced): lp = new QColorLuminancePicker(q); | - |
1549 | #if defined(QT_SMALL_COLORDIALOG) | - |
1550 | QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); | - |
1551 | const int minDimension = qMin(screenSize.height(), screenSize.width()); | - |
1552 | //set picker to be finger-usable | - |
1553 | int pickerWidth = !nonTouchUI ? minDimension/9 : minDimension/12; | - |
1554 | lp->setFixedWidth(pickerWidth); | - |
1555 | if (!nonTouchUI) | - |
1556 | pickLay->addWidget(lp); | - |
1557 | else | - |
1558 | lp->hide(); | - |
1559 | #else | - |
1560 | lp->setFixedWidth(20); executed (the execution status of this line is deduced): lp->setFixedWidth(20); | - |
1561 | pickLay->addWidget(lp); executed (the execution status of this line is deduced): pickLay->addWidget(lp); | - |
1562 | #endif | - |
1563 | | - |
1564 | QObject::connect(cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int))); executed (the execution status of this line is deduced): QObject::connect(cp, "2""newCol(int,int)", lp, "1""setCol(int,int)"); | - |
1565 | QObject::connect(lp, SIGNAL(newHsv(int,int,int)), q, SLOT(_q_newHsv(int,int,int))); executed (the execution status of this line is deduced): QObject::connect(lp, "2""newHsv(int,int,int)", q, "1""_q_newHsv(int,int,int)"); | - |
1566 | | - |
1567 | rightLay->addStretch(); executed (the execution status of this line is deduced): rightLay->addStretch(); | - |
1568 | | - |
1569 | cs = new QColorShower(q); executed (the execution status of this line is deduced): cs = new QColorShower(q); | - |
1570 | QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb))); executed (the execution status of this line is deduced): QObject::connect(cs, "2""newCol(QRgb)", q, "1""_q_newColorTypedIn(QRgb)"); | - |
1571 | QObject::connect(cs, SIGNAL(currentColorChanged(QColor)), executed (the execution status of this line is deduced): QObject::connect(cs, "2""currentColorChanged(QColor)", | - |
1572 | q, SIGNAL(currentColorChanged(QColor))); executed (the execution status of this line is deduced): q, "2""currentColorChanged(QColor)"); | - |
1573 | #if defined(QT_SMALL_COLORDIALOG) | - |
1574 | if (!nonTouchUI) | - |
1575 | pWidth -= cp->size().width(); | - |
1576 | topLay->addWidget(cs); | - |
1577 | #else | - |
1578 | rightLay->addWidget(cs); executed (the execution status of this line is deduced): rightLay->addWidget(cs); | - |
1579 | #endif | - |
1580 | | - |
1581 | buttons = new QDialogButtonBox(q); executed (the execution status of this line is deduced): buttons = new QDialogButtonBox(q); | - |
1582 | mainLay->addWidget(buttons); executed (the execution status of this line is deduced): mainLay->addWidget(buttons); | - |
1583 | | - |
1584 | ok = buttons->addButton(QDialogButtonBox::Ok); executed (the execution status of this line is deduced): ok = buttons->addButton(QDialogButtonBox::Ok); | - |
1585 | QObject::connect(ok, SIGNAL(clicked()), q, SLOT(accept())); executed (the execution status of this line is deduced): QObject::connect(ok, "2""clicked()", q, "1""accept()"); | - |
1586 | ok->setDefault(true); executed (the execution status of this line is deduced): ok->setDefault(true); | - |
1587 | cancel = buttons->addButton(QDialogButtonBox::Cancel); executed (the execution status of this line is deduced): cancel = buttons->addButton(QDialogButtonBox::Cancel); | - |
1588 | QObject::connect(cancel, SIGNAL(clicked()), q, SLOT(reject())); executed (the execution status of this line is deduced): QObject::connect(cancel, "2""clicked()", q, "1""reject()"); | - |
1589 | | - |
1590 | retranslateStrings(); executed (the execution status of this line is deduced): retranslateStrings(); | - |
1591 | | - |
1592 | #ifdef Q_WS_MAC | - |
1593 | delegate = 0; | - |
1594 | #endif | - |
1595 | | - |
1596 | q->setCurrentColor(initial); executed (the execution status of this line is deduced): q->setCurrentColor(initial); | - |
1597 | } executed: } Execution Count:3 | 3 |
1598 | | - |
1599 | void QColorDialogPrivate::initHelper(QPlatformDialogHelper *h) | - |
1600 | { | - |
1601 | QColorDialog *d = q_func(); never executed (the execution status of this line is deduced): QColorDialog *d = q_func(); | - |
1602 | QObject::connect(h, SIGNAL(currentColorChanged(QColor)), d, SIGNAL(currentColorChanged(QColor))); never executed (the execution status of this line is deduced): QObject::connect(h, "2""currentColorChanged(QColor)", d, "2""currentColorChanged(QColor)"); | - |
1603 | QObject::connect(h, SIGNAL(colorSelected(QColor)), d, SIGNAL(colorSelected(QColor))); never executed (the execution status of this line is deduced): QObject::connect(h, "2""colorSelected(QColor)", d, "2""colorSelected(QColor)"); | - |
1604 | static_cast<QPlatformColorDialogHelper *>(h)->setOptions(options); never executed (the execution status of this line is deduced): static_cast<QPlatformColorDialogHelper *>(h)->setOptions(options); | - |
1605 | } | 0 |
1606 | | - |
1607 | void QColorDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) | - |
1608 | { | - |
1609 | options->setWindowTitle(q_func()->windowTitle()); never executed (the execution status of this line is deduced): options->setWindowTitle(q_func()->windowTitle()); | - |
1610 | } | 0 |
1611 | | - |
1612 | void QColorDialogPrivate::_q_addCustom() | - |
1613 | { | - |
1614 | QColorDialogOptions::setCustomColor(nextCust, cs->currentColor()); never executed (the execution status of this line is deduced): QColorDialogOptions::setCustomColor(nextCust, cs->currentColor()); | - |
1615 | if (custom) | 0 |
1616 | custom->update(); never executed: custom->update(); | 0 |
1617 | nextCust = (nextCust+1) % 16; never executed (the execution status of this line is deduced): nextCust = (nextCust+1) % 16; | - |
1618 | } | 0 |
1619 | | - |
1620 | void QColorDialogPrivate::retranslateStrings() | - |
1621 | { | - |
1622 | if (!smallDisplay) { partially evaluated: !smallDisplay yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1623 | lblBasicColors->setText(QColorDialog::tr("&Basic colors")); executed (the execution status of this line is deduced): lblBasicColors->setText(QColorDialog::tr("&Basic colors")); | - |
1624 | lblCustomColors->setText(QColorDialog::tr("&Custom colors")); executed (the execution status of this line is deduced): lblCustomColors->setText(QColorDialog::tr("&Custom colors")); | - |
1625 | addCusBt->setText(QColorDialog::tr("&Add to Custom Colors")); executed (the execution status of this line is deduced): addCusBt->setText(QColorDialog::tr("&Add to Custom Colors")); | - |
1626 | } executed: } Execution Count:3 | 3 |
1627 | | - |
1628 | cs->retranslateStrings(); executed (the execution status of this line is deduced): cs->retranslateStrings(); | - |
1629 | } executed: } Execution Count:3 | 3 |
1630 | | - |
1631 | static const Qt::WindowFlags DefaultWindowFlags = | - |
1632 | Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint | - |
1633 | | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | - |
1634 | | - |
1635 | /*! | - |
1636 | \class QColorDialog | - |
1637 | \brief The QColorDialog class provides a dialog widget for specifying colors. | - |
1638 | | - |
1639 | \ingroup standard-dialogs | - |
1640 | \inmodule QtWidgets | - |
1641 | | - |
1642 | The color dialog's function is to allow users to choose colors. | - |
1643 | For example, you might use this in a drawing program to allow the | - |
1644 | user to set the brush color. | - |
1645 | | - |
1646 | The static functions provide modal color dialogs. | - |
1647 | \omit | - |
1648 | If you require a modeless dialog, use the QColorDialog constructor. | - |
1649 | \endomit | - |
1650 | | - |
1651 | The static getColor() function shows the dialog, and allows the user to | - |
1652 | specify a color. This function can also be used to let users choose a | - |
1653 | color with a level of transparency: pass the ShowAlphaChannel option as | - |
1654 | an additional argument. | - |
1655 | | - |
1656 | The user can store customCount() different custom colors. The | - |
1657 | custom colors are shared by all color dialogs, and remembered | - |
1658 | during the execution of the program. Use setCustomColor() to set | - |
1659 | the custom colors, and use customColor() to get them. | - |
1660 | | - |
1661 | The \l{dialogs/standarddialogs}{Standard Dialogs} example shows | - |
1662 | how to use QColorDialog as well as other built-in Qt dialogs. | - |
1663 | | - |
1664 | \image fusion-colordialog.png A color dialog in the Fusion widget style. | - |
1665 | | - |
1666 | \sa QColor, QFileDialog, QFontDialog, {Standard Dialogs Example} | - |
1667 | */ | - |
1668 | | - |
1669 | /*! | - |
1670 | \since 4.5 | - |
1671 | | - |
1672 | Constructs a color dialog with the given \a parent. | - |
1673 | */ | - |
1674 | QColorDialog::QColorDialog(QWidget *parent) | - |
1675 | : QDialog(*new QColorDialogPrivate, parent, DefaultWindowFlags) | - |
1676 | { | - |
1677 | Q_D(QColorDialog); executed (the execution status of this line is deduced): QColorDialogPrivate * const d = d_func(); | - |
1678 | d->init(Qt::white); executed (the execution status of this line is deduced): d->init(Qt::white); | - |
1679 | } executed: } Execution Count:3 | 3 |
1680 | | - |
1681 | /*! | - |
1682 | \since 4.5 | - |
1683 | | - |
1684 | Constructs a color dialog with the given \a parent and specified | - |
1685 | \a initial color. | - |
1686 | */ | - |
1687 | QColorDialog::QColorDialog(const QColor &initial, QWidget *parent) | - |
1688 | : QDialog(*new QColorDialogPrivate, parent, DefaultWindowFlags) | - |
1689 | { | - |
1690 | Q_D(QColorDialog); never executed (the execution status of this line is deduced): QColorDialogPrivate * const d = d_func(); | - |
1691 | d->init(initial); never executed (the execution status of this line is deduced): d->init(initial); | - |
1692 | } | 0 |
1693 | | - |
1694 | /*! | - |
1695 | \property QColorDialog::currentColor | - |
1696 | \brief the currently selected color in the dialog | - |
1697 | */ | - |
1698 | | - |
1699 | void QColorDialog::setCurrentColor(const QColor &color) | - |
1700 | { | - |
1701 | Q_D(QColorDialog); executed (the execution status of this line is deduced): QColorDialogPrivate * const d = d_func(); | - |
1702 | d->setCurrentColor(color.rgb()); executed (the execution status of this line is deduced): d->setCurrentColor(color.rgb()); | - |
1703 | d->selectColor(color); executed (the execution status of this line is deduced): d->selectColor(color); | - |
1704 | d->setCurrentAlpha(color.alpha()); executed (the execution status of this line is deduced): d->setCurrentAlpha(color.alpha()); | - |
1705 | | - |
1706 | if (!testOption(QColorDialog::DontUseNativeDialog) && d->nativeDialogInUse) partially evaluated: !testOption(QColorDialog::DontUseNativeDialog) yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: d->nativeDialogInUse no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1707 | d->platformColorDialogHelper()->setCurrentColor(color); never executed: d->platformColorDialogHelper()->setCurrentColor(color); | 0 |
1708 | } executed: } Execution Count:5 | 5 |
1709 | | - |
1710 | QColor QColorDialog::currentColor() const | - |
1711 | { | - |
1712 | Q_D(const QColorDialog); executed (the execution status of this line is deduced): const QColorDialogPrivate * const d = d_func(); | - |
1713 | return d->currentQColor(); executed: return d->currentQColor(); Execution Count:2 | 2 |
1714 | } | - |
1715 | | - |
1716 | /*! | - |
1717 | Returns the color that the user selected by clicking the \uicontrol{OK} | - |
1718 | or equivalent button. | - |
1719 | | - |
1720 | \note This color is not always the same as the color held by the | - |
1721 | \l currentColor property since the user can choose different colors | - |
1722 | before finally selecting the one to use. | - |
1723 | */ | - |
1724 | QColor QColorDialog::selectedColor() const | - |
1725 | { | - |
1726 | Q_D(const QColorDialog); executed (the execution status of this line is deduced): const QColorDialogPrivate * const d = d_func(); | - |
1727 | return d->selectedQColor; executed: return d->selectedQColor; Execution Count:1 | 1 |
1728 | } | - |
1729 | | - |
1730 | /*! | - |
1731 | Sets the given \a option to be enabled if \a on is true; | - |
1732 | otherwise, clears the given \a option. | - |
1733 | | - |
1734 | \sa options, testOption() | - |
1735 | */ | - |
1736 | void QColorDialog::setOption(ColorDialogOption option, bool on) | - |
1737 | { | - |
1738 | const QColorDialog::ColorDialogOptions previousOptions = options(); executed (the execution status of this line is deduced): const QColorDialog::ColorDialogOptions previousOptions = options(); | - |
1739 | if (!(previousOptions & option) != !on) partially evaluated: !(previousOptions & option) != !on yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1740 | setOptions(previousOptions ^ option); executed: setOptions(previousOptions ^ option); Execution Count:1 | 1 |
1741 | } executed: } Execution Count:1 | 1 |
1742 | | - |
1743 | /*! | - |
1744 | \since 4.5 | - |
1745 | | - |
1746 | Returns true if the given \a option is enabled; otherwise, returns | - |
1747 | false. | - |
1748 | | - |
1749 | \sa options, setOption() | - |
1750 | */ | - |
1751 | bool QColorDialog::testOption(ColorDialogOption option) const | - |
1752 | { | - |
1753 | Q_D(const QColorDialog); executed (the execution status of this line is deduced): const QColorDialogPrivate * const d = d_func(); | - |
1754 | return d->options->testOption(static_cast<QColorDialogOptions::ColorDialogOption>(option)); executed: return d->options->testOption(static_cast<QColorDialogOptions::ColorDialogOption>(option)); Execution Count:5 | 5 |
1755 | } | - |
1756 | | - |
1757 | /*! | - |
1758 | \property QColorDialog::options | - |
1759 | \brief the various options that affect the look and feel of the dialog | - |
1760 | | - |
1761 | By default, all options are disabled. | - |
1762 | | - |
1763 | Options should be set before showing the dialog. Setting them while the | - |
1764 | dialog is visible is not guaranteed to have an immediate effect on the | - |
1765 | dialog (depending on the option and on the platform). | - |
1766 | | - |
1767 | \sa setOption(), testOption() | - |
1768 | */ | - |
1769 | void QColorDialog::setOptions(ColorDialogOptions options) | - |
1770 | { | - |
1771 | Q_D(QColorDialog); executed (the execution status of this line is deduced): QColorDialogPrivate * const d = d_func(); | - |
1772 | | - |
1773 | if (QColorDialog::options() == options) partially evaluated: QColorDialog::options() == options no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1774 | return; | 0 |
1775 | | - |
1776 | d->options->setOptions(QColorDialogOptions::ColorDialogOptions(int(options))); executed (the execution status of this line is deduced): d->options->setOptions(QColorDialogOptions::ColorDialogOptions(int(options))); | - |
1777 | d->buttons->setVisible(!(options & NoButtons)); executed (the execution status of this line is deduced): d->buttons->setVisible(!(options & NoButtons)); | - |
1778 | d->showAlpha(options & ShowAlphaChannel); executed (the execution status of this line is deduced): d->showAlpha(options & ShowAlphaChannel); | - |
1779 | } executed: } Execution Count:2 | 2 |
1780 | | - |
1781 | QColorDialog::ColorDialogOptions QColorDialog::options() const | - |
1782 | { | - |
1783 | Q_D(const QColorDialog); executed (the execution status of this line is deduced): const QColorDialogPrivate * const d = d_func(); | - |
1784 | return QColorDialog::ColorDialogOptions(int(d->options->options())); executed: return QColorDialog::ColorDialogOptions(int(d->options->options())); Execution Count:30 | 30 |
1785 | } | - |
1786 | | - |
1787 | /*! | - |
1788 | \enum QColorDialog::ColorDialogOption | - |
1789 | | - |
1790 | \since 4.5 | - |
1791 | | - |
1792 | This enum specifies various options that affect the look and feel | - |
1793 | of a color dialog. | - |
1794 | | - |
1795 | \value ShowAlphaChannel Allow the user to select the alpha component of a color. | - |
1796 | \value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".) | - |
1797 | \value DontUseNativeDialog Use Qt's standard color dialog on the Mac instead of Apple's | - |
1798 | native color panel. | - |
1799 | | - |
1800 | \sa options, setOption(), testOption(), windowModality() | - |
1801 | */ | - |
1802 | | - |
1803 | /*! | - |
1804 | \fn void QColorDialog::currentColorChanged(const QColor &color) | - |
1805 | | - |
1806 | This signal is emitted whenever the current color changes in the dialog. | - |
1807 | The current color is specified by \a color. | - |
1808 | | - |
1809 | \sa color, colorSelected() | - |
1810 | */ | - |
1811 | | - |
1812 | #ifdef Q_WS_MAC | - |
1813 | // can only have one Cocoa color panel active | - |
1814 | bool QColorDialogPrivate::sharedColorPanelAvailable = true; | - |
1815 | #endif | - |
1816 | | - |
1817 | /*! | - |
1818 | \fn void QColorDialog::colorSelected(const QColor &color); | - |
1819 | | - |
1820 | This signal is emitted just after the user has clicked \uicontrol{OK} to | - |
1821 | select a color to use. The chosen color is specified by \a color. | - |
1822 | | - |
1823 | \sa color, currentColorChanged() | - |
1824 | */ | - |
1825 | | - |
1826 | /*! | - |
1827 | Changes the visibility of the dialog. If \a visible is true, the dialog | - |
1828 | is shown; otherwise, it is hidden. | - |
1829 | */ | - |
1830 | void QColorDialog::setVisible(bool visible) | - |
1831 | { | - |
1832 | Q_D(QColorDialog); executed (the execution status of this line is deduced): QColorDialogPrivate * const d = d_func(); | - |
1833 | | - |
1834 | if (visible){ evaluated: visible yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
1835 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden)) partially evaluated: testAttribute(Qt::WA_WState_ExplicitShowHide) no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: !testAttribute(Qt::WA_WState_Hidden) | 0-2 |
1836 | return; | 0 |
1837 | } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden)) executed: } Execution Count:2 partially evaluated: testAttribute(Qt::WA_WState_ExplicitShowHide) yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: testAttribute(Qt::WA_WState_Hidden) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1838 | return; | 0 |
1839 | | - |
1840 | if (visible) evaluated: visible yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
1841 | d->selectedQColor = QColor(); executed: d->selectedQColor = QColor(); Execution Count:2 | 2 |
1842 | | - |
1843 | #if defined(Q_WS_MAC) | - |
1844 | if (visible) { | - |
1845 | if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable && | - |
1846 | !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){ | - |
1847 | d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options()); | - |
1848 | QColorDialogPrivate::sharedColorPanelAvailable = false; | - |
1849 | setAttribute(Qt::WA_DontShowOnScreen); | - |
1850 | } | - |
1851 | setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags); | - |
1852 | } else { | - |
1853 | if (d->delegate) { | - |
1854 | d->closeCocoaColorPanel(); | - |
1855 | setAttribute(Qt::WA_DontShowOnScreen, false); | - |
1856 | } | - |
1857 | } | - |
1858 | #else | - |
1859 | | - |
1860 | if (!(options() & DontUseNativeDialog)) partially evaluated: !(options() & DontUseNativeDialog) yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1861 | d->setNativeDialogVisible(visible); executed: d->setNativeDialogVisible(visible); Execution Count:4 | 4 |
1862 | | - |
1863 | if (d->nativeDialogInUse) { partially evaluated: d->nativeDialogInUse no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1864 | // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below | - |
1865 | // updates the state correctly, but skips showing the non-native version: | - |
1866 | setAttribute(Qt::WA_DontShowOnScreen); never executed (the execution status of this line is deduced): setAttribute(Qt::WA_DontShowOnScreen); | - |
1867 | } else { | 0 |
1868 | d->nativeDialogInUse = false; executed (the execution status of this line is deduced): d->nativeDialogInUse = false; | - |
1869 | setAttribute(Qt::WA_DontShowOnScreen, false); executed (the execution status of this line is deduced): setAttribute(Qt::WA_DontShowOnScreen, false); | - |
1870 | } executed: } Execution Count:4 | 4 |
1871 | #endif | - |
1872 | | - |
1873 | QDialog::setVisible(visible); executed (the execution status of this line is deduced): QDialog::setVisible(visible); | - |
1874 | } executed: } Execution Count:4 | 4 |
1875 | | - |
1876 | /*! | - |
1877 | \overload | - |
1878 | \since 4.5 | - |
1879 | | - |
1880 | Opens the dialog and connects its colorSelected() signal to the slot specified | - |
1881 | by \a receiver and \a member. | - |
1882 | | - |
1883 | The signal will be disconnected from the slot when the dialog is closed. | - |
1884 | */ | - |
1885 | void QColorDialog::open(QObject *receiver, const char *member) | - |
1886 | { | - |
1887 | Q_D(QColorDialog); never executed (the execution status of this line is deduced): QColorDialogPrivate * const d = d_func(); | - |
1888 | connect(this, SIGNAL(colorSelected(QColor)), receiver, member); never executed (the execution status of this line is deduced): connect(this, "2""colorSelected(QColor)", receiver, member); | - |
1889 | d->receiverToDisconnectOnClose = receiver; never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose = receiver; | - |
1890 | d->memberToDisconnectOnClose = member; never executed (the execution status of this line is deduced): d->memberToDisconnectOnClose = member; | - |
1891 | QDialog::open(); never executed (the execution status of this line is deduced): QDialog::open(); | - |
1892 | } | 0 |
1893 | | - |
1894 | /*! | - |
1895 | \fn QColorDialog::open() | - |
1896 | | - |
1897 | \since 4.5 | - |
1898 | Shows the dialog as a \l{QDialog#Modal Dialogs}{window modal dialog}, | - |
1899 | returning immediately. | - |
1900 | | - |
1901 | \sa QDialog::open() | - |
1902 | */ | - |
1903 | | - |
1904 | /*! | - |
1905 | \since 4.5 | - |
1906 | | - |
1907 | Pops up a modal color dialog with the given window \a title (or "Select Color" if none is | - |
1908 | specified), lets the user choose a color, and returns that color. The color is initially set | - |
1909 | to \a initial. The dialog is a child of \a parent. It returns an invalid (see | - |
1910 | QColor::isValid()) color if the user cancels the dialog. | - |
1911 | | - |
1912 | The \a options argument allows you to customize the dialog. | - |
1913 | */ | - |
1914 | QColor QColorDialog::getColor(const QColor &initial, QWidget *parent, const QString &title, | - |
1915 | ColorDialogOptions options) | - |
1916 | { | - |
1917 | QColorDialog dlg(parent); executed (the execution status of this line is deduced): QColorDialog dlg(parent); | - |
1918 | if (!title.isEmpty()) partially evaluated: !title.isEmpty() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1919 | dlg.setWindowTitle(title); never executed: dlg.setWindowTitle(title); | 0 |
1920 | dlg.setOptions(options); executed (the execution status of this line is deduced): dlg.setOptions(options); | - |
1921 | dlg.setCurrentColor(initial); executed (the execution status of this line is deduced): dlg.setCurrentColor(initial); | - |
1922 | dlg.exec(); executed (the execution status of this line is deduced): dlg.exec(); | - |
1923 | return dlg.selectedColor(); executed: return dlg.selectedColor(); Execution Count:1 | 1 |
1924 | } | - |
1925 | | - |
1926 | /*! | - |
1927 | \obsolete | - |
1928 | | - |
1929 | Pops up a modal color dialog to allow the user to choose a color | - |
1930 | and an alpha channel (transparency) value. The color+alpha is | - |
1931 | initially set to \a initial. The dialog is a child of \a parent. | - |
1932 | | - |
1933 | If \a ok is non-null, \e *\a ok is set to true if the user clicked | - |
1934 | \uicontrol{OK}, and to false if the user clicked Cancel. | - |
1935 | | - |
1936 | If the user clicks Cancel, the \a initial value is returned. | - |
1937 | | - |
1938 | Use QColorDialog::getColor() instead, passing the | - |
1939 | QColorDialog::ShowAlphaChannel option. | - |
1940 | */ | - |
1941 | | - |
1942 | QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent) | - |
1943 | { | - |
1944 | QColor color(getColor(QColor(initial), parent, QString(), ShowAlphaChannel)); executed (the execution status of this line is deduced): QColor color(getColor(QColor(initial), parent, QString(), ShowAlphaChannel)); | - |
1945 | QRgb result = color.isValid() ? color.rgba() : initial; partially evaluated: color.isValid() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1946 | if (ok) partially evaluated: ok yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1947 | *ok = color.isValid(); executed: *ok = color.isValid(); Execution Count:1 | 1 |
1948 | return result; executed: return result; Execution Count:1 | 1 |
1949 | } | - |
1950 | | - |
1951 | /*! | - |
1952 | Destroys the color dialog. | - |
1953 | */ | - |
1954 | | - |
1955 | QColorDialog::~QColorDialog() | - |
1956 | { | - |
1957 | #if defined(Q_WS_MAC) | - |
1958 | Q_D(QColorDialog); | - |
1959 | if (d->delegate) { | - |
1960 | d->releaseCocoaColorPanelDelegate(); | - |
1961 | QColorDialogPrivate::sharedColorPanelAvailable = true; | - |
1962 | } | - |
1963 | #endif | - |
1964 | } | - |
1965 | | - |
1966 | /*! | - |
1967 | \reimp | - |
1968 | */ | - |
1969 | void QColorDialog::changeEvent(QEvent *e) | - |
1970 | { | - |
1971 | Q_D(QColorDialog); executed (the execution status of this line is deduced): QColorDialogPrivate * const d = d_func(); | - |
1972 | if (e->type() == QEvent::LanguageChange) partially evaluated: e->type() == QEvent::LanguageChange no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1973 | d->retranslateStrings(); never executed: d->retranslateStrings(); | 0 |
1974 | QDialog::changeEvent(e); executed (the execution status of this line is deduced): QDialog::changeEvent(e); | - |
1975 | } executed: } Execution Count:7 | 7 |
1976 | | - |
1977 | /*! | - |
1978 | Closes the dialog and sets its result code to \a result. If this dialog | - |
1979 | is shown with exec(), done() causes the local event loop to finish, | - |
1980 | and exec() to return \a result. | - |
1981 | | - |
1982 | \sa QDialog::done() | - |
1983 | */ | - |
1984 | void QColorDialog::done(int result) | - |
1985 | { | - |
1986 | Q_D(QColorDialog); executed (the execution status of this line is deduced): QColorDialogPrivate * const d = d_func(); | - |
1987 | QDialog::done(result); executed (the execution status of this line is deduced): QDialog::done(result); | - |
1988 | if (result == Accepted) { partially evaluated: result == Accepted yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1989 | d->selectedQColor = d->currentQColor(); executed (the execution status of this line is deduced): d->selectedQColor = d->currentQColor(); | - |
1990 | emit colorSelected(d->selectedQColor); executed (the execution status of this line is deduced): colorSelected(d->selectedQColor); | - |
1991 | } else { executed: } Execution Count:1 | 1 |
1992 | d->selectedQColor = QColor(); never executed (the execution status of this line is deduced): d->selectedQColor = QColor(); | - |
1993 | } | 0 |
1994 | if (d->receiverToDisconnectOnClose) { partially evaluated: d->receiverToDisconnectOnClose no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1995 | disconnect(this, SIGNAL(colorSelected(QColor)), never executed (the execution status of this line is deduced): disconnect(this, "2""colorSelected(QColor)", | - |
1996 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | - |
1997 | d->receiverToDisconnectOnClose = 0; never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose = 0; | - |
1998 | } | 0 |
1999 | d->memberToDisconnectOnClose.clear(); executed (the execution status of this line is deduced): d->memberToDisconnectOnClose.clear(); | - |
2000 | } executed: } Execution Count:1 | 1 |
2001 | | - |
2002 | QT_END_NAMESPACE | - |
2003 | | - |
2004 | #include "qcolordialog.moc" | - |
2005 | #include "moc_qcolordialog.cpp" | - |
2006 | | - |
2007 | #endif // QT_NO_COLORDIALOG | - |
2008 | | - |
2009 | | - |
| | |