• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mcallegari / qlcplus / 14809507932

03 May 2025 09:13AM UTC coverage: 31.879% (+0.03%) from 31.845%
14809507932

push

github

web-flow
Merge pull request #1745 from mcallegari/qmluiqt6

Port QML UI to Qt6

2 of 9 new or added lines in 3 files covered. (22.22%)

3720 existing lines in 174 files now uncovered.

16422 of 51513 relevant lines covered (31.88%)

19079.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/ui/src/monitor/monitorlayout.cpp
1
/*
2
  Q Light Controller
3
  monitorlayout.cpp
4

5
  Copyright (c) Nokia Corporation/QtSoftware
6
                Heikki Junnila
7

8
  Licensed under the Apache License, Version 2.0 (the "License");
9
  you may not use this file except in compliance with the License.
10
  You may obtain a copy of the License at
11

12
      http://www.apache.org/licenses/LICENSE-2.0.txt
13

14
  Unless required by applicable law or agreed to in writing, software
15
  distributed under the License is distributed on an "AS IS" BASIS,
16
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
  See the License for the specific language governing permissions and
18
  limitations under the License.
19
*/
20

21
#include <QWidgetItem>
22
#include <QLayout>
23
#include <QDebug>
24

25
#include "monitorfixture.h"
26
#include "monitorlayout.h"
27

28
/****************************************************************************
29
 * MonitorLayoutItem
30
 ****************************************************************************/
31

32
MonitorLayoutItem::MonitorLayoutItem(MonitorFixture* mof) : QWidgetItem(mof)
×
33
{
34
}
×
35

36
MonitorLayoutItem::~MonitorLayoutItem()
×
37
{
38
}
×
39

40
bool MonitorLayoutItem::operator<(const MonitorLayoutItem& item)
×
41
{
UNCOV
42
    MonitorLayoutItem& ncitem = const_cast<MonitorLayoutItem&> (item);
×
43
    MonitorFixture* item_mof;
44
    MonitorFixture* mof;
45

46
    mof = qobject_cast<MonitorFixture*> (widget());
×
UNCOV
47
    Q_ASSERT(mof != NULL);
×
48

49
    item_mof = qobject_cast<MonitorFixture*> (ncitem.widget());
×
UNCOV
50
    Q_ASSERT(item_mof != NULL);
×
51

52
    if ((*mof) < (*item_mof))
×
UNCOV
53
        return true;
×
54
    else
55
        return false;
×
56
}
57

58
/****************************************************************************
59
 * Initialization
60
 ****************************************************************************/
61

62
MonitorLayout::MonitorLayout(QWidget *parent) : QLayout(parent)
×
63
{
64
}
×
65

66
MonitorLayout::~MonitorLayout()
×
67
{
68
    while (m_items.isEmpty() == false)
×
69
        delete m_items.takeFirst();
×
70
}
×
71

72
/****************************************************************************
73
 * Items
74
 ****************************************************************************/
75

76
void MonitorLayout::addItem(QLayoutItem* item)
×
77
{
78
    m_items.append(static_cast<MonitorLayoutItem*> (item));
×
79
    sort();
×
80
    update();
×
81
}
×
82

83
int MonitorLayout::count() const
×
84
{
85
    return m_items.size();
×
86
}
87

88
MonitorLayoutItem* MonitorLayout::itemAt(int index) const
×
89
{
90
    return m_items.value(index);
×
91
}
92

93
MonitorLayoutItem* MonitorLayout::takeAt(int index)
×
94
{
95
    if (index >= 0 && index < m_items.size())
×
96
        return m_items.takeAt(index);
×
97
    else
UNCOV
98
        return NULL;
×
99
}
100

101
static bool MonitorLayoutLessThan(MonitorLayoutItem* i1, MonitorLayoutItem* i2)
×
102
{
103
    if ((*i1) < (*i2))
×
UNCOV
104
        return true;
×
105
    else
106
        return false;
×
107
}
108

109
void MonitorLayout::sort()
×
110
{
111
    std::sort(m_items.begin(), m_items.end(), MonitorLayoutLessThan);
×
112
}
×
113

114
/****************************************************************************
115
 * Size & Geometry
116
 ****************************************************************************/
117

118
Qt::Orientations MonitorLayout::expandingDirections() const
×
119
{
120
    return Qt::Vertical;
×
121
}
122

123
bool MonitorLayout::hasHeightForWidth() const
×
124
{
125
    return true;
×
126
}
127

128
int MonitorLayout::heightForWidth(int width) const
×
129
{
130
    int height = doLayout(QRect(0, 0, width, 0), true);
×
131
    return height;
×
132
}
133

134
void MonitorLayout::setGeometry(const QRect& rect)
×
135
{
136
    QLayout::setGeometry(rect);
×
137
    doLayout(rect, false);
×
138
}
×
139

140
QSize MonitorLayout::sizeHint() const
×
141
{
142
    return minimumSize();
×
143
}
144

145
QSize MonitorLayout::minimumSize() const
×
146
{
147
    QSize size;
×
148
    QLayoutItem* item;
149

150
    foreach (item, m_items)
×
151
    size = size.expandedTo(item->minimumSize());
×
152

153
    size += QSize(2 * contentsMargins().left(), 2 * contentsMargins().top());
×
154

155
    return size;
×
156
}
157

158
int MonitorLayout::doLayout(const QRect& rect, bool testOnly) const
×
159
{
UNCOV
160
    int x = rect.x();
×
UNCOV
161
    int y = rect.y();
×
162
    int lineHeight = 0;
×
163
    QLayoutItem* item;
164

165
    foreach (item, m_items)
×
166
    {
167
        int nextX = x + item->sizeHint().width() + spacing();
×
168
        if (nextX - spacing() > rect.right() && lineHeight > 0)
×
169
        {
UNCOV
170
            x = rect.x();
×
171
            y = y + lineHeight + spacing();
×
172
            nextX = x + item->sizeHint().width() + spacing();
×
173
            lineHeight = 0;
×
174
        }
175

176
        if (testOnly == false)
×
177
        {
178
            item->setGeometry(QRect(QPoint(x, y),
×
179
                                    item->sizeHint()));
×
180
        }
181

UNCOV
182
        x = nextX;
×
183
        lineHeight = qMax(lineHeight, item->sizeHint().height());
×
UNCOV
184
    }
×
185

186
    return y + lineHeight - rect.y();
×
187
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc