• 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

0.0
/ui/src/virtualconsole/addvcbuttonmatrix.cpp
1
/*
2
  Q Light Controller
3
  addvcbuttonmatrix.cpp
4

5
  Copyright (C) Heikki Junnila
6

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

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

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

20
#include <QSettings>
21
#include <QDebug>
22
#include <QAction>
23

24
#include "addvcbuttonmatrix.h"
25
#include "functionselection.h"
26
#include "vcbutton.h"
27
#include "function.h"
28
#include "doc.h"
29

30
#define KColumnFunction 0
31
#define KColumnType     1
32

33
#define HORIZONTAL_COUNT "addvcbuttonmatrix/horizontalcount"
34
#define VERTICAL_COUNT "addvcbuttonmatrix/verticalcount"
35
#define BUTTON_SIZE "addvcbuttonmatrix/buttonsize"
36
#define FRAME_STYLE "addvcbuttonmatrix/framestyle"
37

38
AddVCButtonMatrix::AddVCButtonMatrix(QWidget* parent, Doc* doc)
×
39
    : QDialog(parent)
40
    , m_doc(doc)
×
41
{
42
    Q_ASSERT(doc != NULL);
×
43

44
    QSettings settings;
×
45
    QVariant var;
×
46

47
    setupUi(this);
×
48

49
    QAction* action = new QAction(this);
×
50
    action->setShortcut(QKeySequence(QKeySequence::Close));
×
51
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
×
52
    addAction(action);
×
53

54
    var = settings.value(HORIZONTAL_COUNT);
×
55
    if (var.isValid() == true)
×
56
        m_horizontalSpin->setValue(var.toInt());
×
57
    else
58
        m_horizontalSpin->setValue(5);
×
59
    m_horizontalCount = m_horizontalSpin->value();
×
60

61
    var = settings.value(VERTICAL_COUNT);
×
62
    if (var.isValid() == true)
×
63
        m_verticalSpin->setValue(var.toInt());
×
64
    else
65
        m_verticalSpin->setValue(5);
×
66
    m_verticalCount = m_verticalSpin->value();
×
67

68
    var = settings.value(BUTTON_SIZE);
×
69
    if (var.isValid() == true)
×
70
        m_sizeSpin->setValue(var.toInt());
×
71
    else
72
        m_sizeSpin->setValue(VCButton::defaultSize.width());
×
73
    m_buttonSize = m_sizeSpin->value();
×
74

75
    var = settings.value(FRAME_STYLE);
×
76
    if (var.isValid() == true)
×
77
        setFrameStyle(AddVCButtonMatrix::FrameStyle(var.toInt()));
×
78
    else
79
        setFrameStyle(AddVCButtonMatrix::NormalFrame);
×
80

81
    setAllocationText();
×
82
}
×
83

84
AddVCButtonMatrix::~AddVCButtonMatrix()
×
85
{
86
    QSettings settings;
×
87
    settings.setValue(HORIZONTAL_COUNT, horizontalCount());
×
88
    settings.setValue(VERTICAL_COUNT, verticalCount());
×
89
    settings.setValue(BUTTON_SIZE, buttonSize());
×
90
}
×
91

92
QList <quint32> AddVCButtonMatrix::functions() const
×
93
{
94
    return m_functions;
×
95
}
96

97
quint32 AddVCButtonMatrix::horizontalCount() const
×
98
{
99
    return m_horizontalCount;
×
100
}
101

102
quint32 AddVCButtonMatrix::verticalCount() const
×
103
{
104
    return m_verticalCount;
×
105
}
106

107
quint32 AddVCButtonMatrix::buttonSize() const
×
108
{
109
    return m_buttonSize;
×
110
}
111

112
AddVCButtonMatrix::FrameStyle AddVCButtonMatrix::frameStyle() const
×
113
{
114
    return m_frameStyle;
×
115
}
116

117
void AddVCButtonMatrix::slotAddClicked()
×
118
{
119
    FunctionSelection fs(this, m_doc);
×
120
    fs.setDisabledFunctions(functions());
×
121
    if (fs.exec() == true)
×
122
    {
123
        QListIterator <quint32> it(fs.selection());
×
124
        while (it.hasNext() == true)
×
125
            addFunction(it.next());
×
126
    }
127

128
    setAllocationText();
×
129
}
×
130

131
void AddVCButtonMatrix::slotRemoveClicked()
×
132
{
133
    QListIterator <QTreeWidgetItem*> it(m_tree->selectedItems());
×
134
    while (it.hasNext() == true)
×
135
    {
136
        QTreeWidgetItem* item(it.next());
×
137
        m_functions.removeAll(item->data(KColumnFunction, Qt::UserRole).toUInt());
×
138
        delete item;
×
139
    }
140

141
    setAllocationText();
×
142
}
×
143

144
void AddVCButtonMatrix::slotHorizontalChanged()
×
145
{
146
    m_horizontalCount = m_horizontalSpin->value();
×
147
    setAllocationText();
×
148
}
×
149

150
void AddVCButtonMatrix::slotVerticalChanged()
×
151
{
152
    m_verticalCount = m_verticalSpin->value();
×
153
    setAllocationText();
×
154
}
×
155

156
void AddVCButtonMatrix::slotButtonSizeChanged()
×
157
{
158
    m_buttonSize = m_sizeSpin->value();
×
159
}
×
160

161
void AddVCButtonMatrix::slotNormalFrameToggled(bool toggled)
×
162
{
163
    if (toggled == true)
×
164
        setFrameStyle(AddVCButtonMatrix::NormalFrame);
×
165
    else
166
        setFrameStyle(AddVCButtonMatrix::SoloFrame);
×
167
}
×
168

169
void AddVCButtonMatrix::accept()
×
170
{
171
    QDialog::accept();
×
172
}
×
173

174
void AddVCButtonMatrix::addFunction(quint32 fid)
×
175
{
176
    Function* function = m_doc->function(fid);
×
177
    if (function == NULL)
×
178
        return;
×
179

180
    QTreeWidgetItem* item = new QTreeWidgetItem(m_tree);
×
181
    item->setText(KColumnFunction, function->name());
×
182
    item->setText(KColumnType, function->typeString());
×
183
    item->setData(KColumnFunction, Qt::UserRole, fid);
×
184

185
    m_functions << fid;
×
186
}
187

188
void AddVCButtonMatrix::setAllocationText()
×
189
{
190
    QString text("%1 / %2");
×
191
    m_allocationEdit->setText(text.arg(m_tree->topLevelItemCount())
×
192
                              .arg(horizontalCount() * verticalCount()));
×
193
}
×
194

195
void AddVCButtonMatrix::setFrameStyle(AddVCButtonMatrix::FrameStyle style)
×
196
{
197
    switch (style)
×
198
    {
199
    default:
×
200
    case NormalFrame:
201
        m_frameNormalRadio->setChecked(true);
×
202
        m_frameStyle = NormalFrame;
×
203
        break;
×
204
    case SoloFrame:
×
205
        m_frameSoloRadio->setChecked(true);
×
206
        m_frameStyle = SoloFrame;
×
207
        break;
×
208
    }
209
}
×
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