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

mcallegari / qlcplus / 6683238402

29 Oct 2023 12:10PM UTC coverage: 28.07%. Remained the same
6683238402

push

github

mcallegari
engine: fix build

15385 of 54809 relevant lines covered (28.07%)

20267.63 hits per line

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

83.93
/ui/src/virtualconsole/vclabel.cpp
1
/*
2
  Q Light Controller Plus
3
  vclabel.cpp
4

5
  Copyright (c) Heikki Junnila
6
                Stefan Krumm
7
                Massimo Callegari
8

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

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

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

22
#include <QXmlStreamReader>
23
#include <QXmlStreamWriter>
24
#include <QInputDialog>
25
#include <QPaintEvent>
26
#include <QLineEdit>
27
#include <QPainter>
28
#include <QString>
29
#include <QDebug>
30
#include <QStyle>
31
#include <QSize>
32

33
#include "vclabel.h"
34
#include "doc.h"
35

36
VCLabel::VCLabel(QWidget* parent, Doc* doc) : VCWidget(parent, doc)
7✔
37
{
38
    /* Set the class name "VCLabel" as the object name as well */
39
    setObjectName(VCLabel::staticMetaObject.className());
7✔
40

41
    setType(VCWidget::LabelWidget);
7✔
42
    setCaption(tr("Label"));
7✔
43
    resize(QSize(100, 30));
7✔
44
}
7✔
45

46
VCLabel::~VCLabel()
9✔
47
{
48
}
9✔
49

50
/*****************************************************************************
51
 * Clipboard
52
 *****************************************************************************/
53

54
VCWidget* VCLabel::createCopy(VCWidget* parent)
1✔
55
{
56
    Q_ASSERT(parent != NULL);
1✔
57

58
    VCLabel* label = new VCLabel(parent, m_doc);
1✔
59
    if (label->copyFrom(this) == false)
1✔
60
    {
61
        delete label;
×
62
        label = NULL;
×
63
    }
64

65
    return label;
1✔
66
}
67

68
/*****************************************************************************
69
 * Properties
70
 *****************************************************************************/
71

72
void VCLabel::editProperties()
×
73
{
74
    bool ok = false;
×
75
    QString text = QInputDialog::getText(NULL, tr("Rename Label"), tr("Caption:"),
×
76
                                         QLineEdit::Normal, caption(), &ok);
×
77
    if (ok == true)
×
78
        setCaption(text);
×
79
}
×
80

81
/*****************************************************************************
82
 * Load & Save
83
 *****************************************************************************/
84

85
bool VCLabel::loadXML(QXmlStreamReader &root)
3✔
86
{
87
    if (root.name() != KXMLQLCVCLabel)
3✔
88
    {
89
        qWarning() << Q_FUNC_INFO << "Label node not found";
1✔
90
        return false;
1✔
91
    }
92

93
    /* Widget commons */
94
    loadXMLCommon(root);
2✔
95

96
    /* Children */
97
    while (root.readNextStartElement())
5✔
98
    {
99
        if (root.name() == KXMLQLCWindowState)
3✔
100
        {
101
            int x = 0, y = 0, w = 0, h = 0;
1✔
102
            bool visible = false;
1✔
103
            loadXMLWindowState(root, &x, &y, &w, &h, &visible);
1✔
104
            setGeometry(x, y, w, h);
1✔
105
        }
106
        else if (root.name() == KXMLQLCVCWidgetAppearance)
2✔
107
        {
108
            loadXMLAppearance(root);
1✔
109
        }
110
        else
111
        {
112
            qWarning() << Q_FUNC_INFO << "Unknown label tag:" << root.name().toString();
1✔
113
            root.skipCurrentElement();
1✔
114
        }
115
    }
116

117
    return true;
2✔
118
}
119

120
bool VCLabel::saveXML(QXmlStreamWriter *doc)
1✔
121
{
122
    Q_ASSERT(doc != NULL);
1✔
123

124
    /* VC Label entry */
125
    doc->writeStartElement(KXMLQLCVCLabel);
1✔
126

127
    saveXMLCommon(doc);
1✔
128

129
    /* Window state */
130
    saveXMLWindowState(doc);
1✔
131

132
    /* Appearance */
133
    saveXMLAppearance(doc);
1✔
134

135
    /* End the <Label> tag */
136
    doc->writeEndElement();
1✔
137

138
    return true;
1✔
139
}
140

141
/****************************************************************************
142
 * Drawing
143
 ****************************************************************************/
144

145
void VCLabel::paintEvent(QPaintEvent* e)
4✔
146
{
147
    bool enabled = false;
4✔
148
    if (mode() == Doc::Operate && isDisabled() == false)
4✔
149
        enabled = true;
1✔
150

151
    QPainter painter(this);
8✔
152
    style()->drawItemText(&painter, rect(), Qt::AlignCenter | Qt::TextWordWrap, palette(),
8✔
153
                          enabled, caption(), foregroundRole());
8✔
154
    painter.end();
4✔
155

156
    VCWidget::paintEvent(e);
4✔
157
}
4✔
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