kernel/qdesktopwidget_qpa.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
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 "qdesktopwidget.h" -
43#include "qscreen.h" -
44#include "private/qapplication_p.h" -
45#include <QWidget> -
46#include "private/qwidget_p.h" -
47#include "private/qdesktopwidget_qpa_p.h" -
48QT_BEGIN_NAMESPACE -
49 -
50QT_USE_NAMESPACE -
51 -
52void QDesktopWidgetPrivate::updateScreenList() -
53{ -
54 Q_Q(QDesktopWidget);
executed (the execution status of this line is deduced): QDesktopWidget * const q = q_func();
-
55 QList<QScreen *> screenList = QGuiApplication::screens();
executed (the execution status of this line is deduced): QList<QScreen *> screenList = QGuiApplication::screens();
-
56 int targetLength = screenList.length();
executed (the execution status of this line is deduced): int targetLength = screenList.length();
-
57 int currentLength = screens.length();
executed (the execution status of this line is deduced): int currentLength = screens.length();
-
58 -
59 // Add or remove screen widgets as necessary -
60 if(currentLength > targetLength) {
partially evaluated: currentLength > targetLength
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:131
0-131
61 QDesktopScreenWidget *screen;
never executed (the execution status of this line is deduced): QDesktopScreenWidget *screen;
-
62 while (currentLength-- > targetLength) {
never evaluated: currentLength-- > targetLength
0
63 screen = screens.takeLast();
never executed (the execution status of this line is deduced): screen = screens.takeLast();
-
64 delete screen;
never executed (the execution status of this line is deduced): delete screen;
-
65 }
never executed: }
0
66 }
never executed: }
0
67 else if (currentLength < targetLength) {
partially evaluated: currentLength < targetLength
TRUEFALSE
yes
Evaluation Count:131
no
Evaluation Count:0
0-131
68 QDesktopScreenWidget *screen;
executed (the execution status of this line is deduced): QDesktopScreenWidget *screen;
-
69 while (currentLength < targetLength) {
evaluated: currentLength < targetLength
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:131
131
70 screen = new QDesktopScreenWidget(currentLength++);
executed (the execution status of this line is deduced): screen = new QDesktopScreenWidget(currentLength++);
-
71 screens.append(screen);
executed (the execution status of this line is deduced): screens.append(screen);
-
72 }
executed: }
Execution Count:131
131
73 }
executed: }
Execution Count:131
131
74 -
75 QRegion virtualGeometry;
executed (the execution status of this line is deduced): QRegion virtualGeometry;
-
76 -
77 // update the geometry of each screen widget -
78 for (int i = 0; i < screens.length(); i++) {
evaluated: i < screens.length()
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:131
131
79 QRect screenGeometry = screenList.at(i)->geometry();
executed (the execution status of this line is deduced): QRect screenGeometry = screenList.at(i)->geometry();
-
80 screens.at(i)->setGeometry(screenGeometry);
executed (the execution status of this line is deduced): screens.at(i)->setGeometry(screenGeometry);
-
81 virtualGeometry += screenGeometry;
executed (the execution status of this line is deduced): virtualGeometry += screenGeometry;
-
82 }
executed: }
Execution Count:131
131
83 -
84 q->setGeometry(virtualGeometry.boundingRect());
executed (the execution status of this line is deduced): q->setGeometry(virtualGeometry.boundingRect());
-
85}
executed: }
Execution Count:131
131
86 -
87QDesktopWidget::QDesktopWidget() -
88 : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop) -
89{ -
90 Q_D(QDesktopWidget);
executed (the execution status of this line is deduced): QDesktopWidgetPrivate * const d = d_func();
-
91 setObjectName(QLatin1String("desktop"));
executed (the execution status of this line is deduced): setObjectName(QLatin1String("desktop"));
-
92 d->updateScreenList();
executed (the execution status of this line is deduced): d->updateScreenList();
-
93}
executed: }
Execution Count:131
131
94 -
95QDesktopWidget::~QDesktopWidget() -
96{ -
97} -
98 -
99bool QDesktopWidget::isVirtualDesktop() const -
100{ -
101 return QGuiApplication::primaryScreen()->virtualSiblings().size() > 1;
executed: return QGuiApplication::primaryScreen()->virtualSiblings().size() > 1;
Execution Count:388
388
102} -
103 -
104int QDesktopWidget::primaryScreen() const -
105{ -
106 return 0;
executed: return 0;
Execution Count:16
16
107} -
108 -
109int QDesktopWidget::numScreens() const -
110{ -
111 return qMax(QGuiApplication::screens().size(), 1);
executed: return qMax(QGuiApplication::screens().size(), 1);
Execution Count:21
21
112} -
113 -
114QWidget *QDesktopWidget::screen(int screen) -
115{ -
116 Q_D(QDesktopWidget);
executed (the execution status of this line is deduced): QDesktopWidgetPrivate * const d = d_func();
-
117 if (screen < 0 || screen >= d->screens.length())
partially evaluated: screen < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
partially evaluated: screen >= d->screens.length()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
118 return d->screens.at(0);
never executed: return d->screens.at(0);
0
119 return d->screens.at(screen);
executed: return d->screens.at(screen);
Execution Count:16
16
120} -
121 -
122const QRect QDesktopWidget::availableGeometry(int screenNo) const -
123{ -
124 QList<QScreen *> screens = QGuiApplication::screens();
executed (the execution status of this line is deduced): QList<QScreen *> screens = QGuiApplication::screens();
-
125 if (screenNo == -1)
evaluated: screenNo == -1
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:1487
22-1487
126 screenNo = 0;
executed: screenNo = 0;
Execution Count:22
22
127 if (screenNo < 0 || screenNo >= screens.size())
partially evaluated: screenNo < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1509
partially evaluated: screenNo >= screens.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1509
0-1509
128 return QRect();
never executed: return QRect();
0
129 else -
130 return screens.at(screenNo)->availableGeometry();
executed: return screens.at(screenNo)->availableGeometry();
Execution Count:1509
1509
131} -
132 -
133const QRect QDesktopWidget::screenGeometry(int screenNo) const -
134{ -
135 QList<QScreen *> screens = QGuiApplication::screens();
executed (the execution status of this line is deduced): QList<QScreen *> screens = QGuiApplication::screens();
-
136 if (screenNo == -1)
evaluated: screenNo == -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1847
2-1847
137 screenNo = 0;
executed: screenNo = 0;
Execution Count:2
2
138 if (screenNo < 0 || screenNo >= screens.size())
partially evaluated: screenNo < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1849
partially evaluated: screenNo >= screens.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1849
0-1849
139 return QRect();
never executed: return QRect();
0
140 else -
141 return screens.at(screenNo)->geometry();
executed: return screens.at(screenNo)->geometry();
Execution Count:1849
1849
142} -
143 -
144int QDesktopWidget::screenNumber(const QWidget *w) const -
145{ -
146 if (!w)
evaluated: !w
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1347
2-1347
147 return 0;
executed: return 0;
Execution Count:2
2
148 -
149 QRect frame = w->frameGeometry();
executed (the execution status of this line is deduced): QRect frame = w->frameGeometry();
-
150 if (!w->isWindow())
evaluated: !w->isWindow()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:1308
39-1308
151 frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
executed: frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
Execution Count:39
39
152 const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2;
executed (the execution status of this line is deduced): const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2;
-
153 return screenNumber(midpoint);
executed: return screenNumber(midpoint);
Execution Count:1347
1347
154} -
155 -
156int QDesktopWidget::screenNumber(const QPoint &p) const -
157{ -
158 QList<QScreen *> screens = QGuiApplication::screens();
executed (the execution status of this line is deduced): QList<QScreen *> screens = QGuiApplication::screens();
-
159 -
160 for (int i = 0; i < screens.size(); ++i)
evaluated: i < screens.size()
TRUEFALSE
yes
Evaluation Count:3337
yes
Evaluation Count:4
4-3337
161 if (screens.at(i)->geometry().contains(p))
evaluated: screens.at(i)->geometry().contains(p)
TRUEFALSE
yes
Evaluation Count:3333
yes
Evaluation Count:4
4-3333
162 return i;
executed: return i;
Execution Count:3333
3333
163 -
164 return primaryScreen(); //even better would be closest screen
executed: return primaryScreen();
Execution Count:4
4
165} -
166 -
167void QDesktopWidget::resizeEvent(QResizeEvent *) -
168{ -
169} -
170 -
171QT_END_NAMESPACE -
172 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial