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

mcallegari / qlcplus / 8961243534

05 May 2024 09:23PM UTC coverage: 32.068% (+4.0%) from 28.094%
8961243534

push

github

mcallegari
Merge branch 'master' into qmltoqt6

902 of 2557 new or added lines in 140 files covered. (35.28%)

166 existing lines in 76 files now uncovered.

15395 of 48008 relevant lines covered (32.07%)

22949.67 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
#define SETTINGS_GEOMETRY "addvcbuttonmatrix/geometry"
38

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

45
    QSettings settings;
×
46
    QVariant var;
×
47

48
    setupUi(this);
×
49

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

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

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

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

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

NEW
82
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
×
NEW
83
    if (geometrySettings.isValid() == true)
×
NEW
84
        restoreGeometry(geometrySettings.toByteArray());
×
85

86
    setAllocationText();
×
87
}
×
88

89
AddVCButtonMatrix::~AddVCButtonMatrix()
×
90
{
91
    QSettings settings;
×
92
    settings.setValue(HORIZONTAL_COUNT, horizontalCount());
×
93
    settings.setValue(VERTICAL_COUNT, verticalCount());
×
94
    settings.setValue(BUTTON_SIZE, buttonSize());
×
NEW
95
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
UNCOV
96
}
×
97

98
QList <quint32> AddVCButtonMatrix::functions() const
×
99
{
100
    return m_functions;
×
101
}
102

103
quint32 AddVCButtonMatrix::horizontalCount() const
×
104
{
105
    return m_horizontalCount;
×
106
}
107

108
quint32 AddVCButtonMatrix::verticalCount() const
×
109
{
110
    return m_verticalCount;
×
111
}
112

113
quint32 AddVCButtonMatrix::buttonSize() const
×
114
{
115
    return m_buttonSize;
×
116
}
117

118
AddVCButtonMatrix::FrameStyle AddVCButtonMatrix::frameStyle() const
×
119
{
120
    return m_frameStyle;
×
121
}
122

123
void AddVCButtonMatrix::slotAddClicked()
×
124
{
125
    FunctionSelection fs(this, m_doc);
×
126
    fs.setDisabledFunctions(functions());
×
127
    if (fs.exec() == true)
×
128
    {
129
        QListIterator <quint32> it(fs.selection());
×
130
        while (it.hasNext() == true)
×
131
            addFunction(it.next());
×
132
    }
133

134
    setAllocationText();
×
135
}
×
136

137
void AddVCButtonMatrix::slotRemoveClicked()
×
138
{
139
    QListIterator <QTreeWidgetItem*> it(m_tree->selectedItems());
×
140
    while (it.hasNext() == true)
×
141
    {
142
        QTreeWidgetItem* item(it.next());
×
143
        m_functions.removeAll(item->data(KColumnFunction, Qt::UserRole).toUInt());
×
144
        delete item;
×
145
    }
146

147
    setAllocationText();
×
148
}
×
149

150
void AddVCButtonMatrix::slotHorizontalChanged()
×
151
{
152
    m_horizontalCount = m_horizontalSpin->value();
×
153
    setAllocationText();
×
154
}
×
155

156
void AddVCButtonMatrix::slotVerticalChanged()
×
157
{
158
    m_verticalCount = m_verticalSpin->value();
×
159
    setAllocationText();
×
160
}
×
161

162
void AddVCButtonMatrix::slotButtonSizeChanged()
×
163
{
164
    m_buttonSize = m_sizeSpin->value();
×
165
}
×
166

167
void AddVCButtonMatrix::slotNormalFrameToggled(bool toggled)
×
168
{
169
    if (toggled == true)
×
170
        setFrameStyle(AddVCButtonMatrix::NormalFrame);
×
171
    else
172
        setFrameStyle(AddVCButtonMatrix::SoloFrame);
×
173
}
×
174

175
void AddVCButtonMatrix::accept()
×
176
{
177
    QDialog::accept();
×
178
}
×
179

180
void AddVCButtonMatrix::addFunction(quint32 fid)
×
181
{
182
    Function* function = m_doc->function(fid);
×
183
    if (function == NULL)
×
184
        return;
×
185

186
    QTreeWidgetItem* item = new QTreeWidgetItem(m_tree);
×
187
    item->setText(KColumnFunction, function->name());
×
188
    item->setText(KColumnType, function->typeString());
×
189
    item->setData(KColumnFunction, Qt::UserRole, fid);
×
190

191
    m_functions << fid;
×
192
}
193

194
void AddVCButtonMatrix::setAllocationText()
×
195
{
196
    QString text("%1 / %2");
×
197
    m_allocationEdit->setText(text.arg(m_tree->topLevelItemCount())
×
198
                              .arg(horizontalCount() * verticalCount()));
×
199
}
×
200

201
void AddVCButtonMatrix::setFrameStyle(AddVCButtonMatrix::FrameStyle style)
×
202
{
203
    switch (style)
×
204
    {
205
    default:
×
206
    case NormalFrame:
207
        m_frameNormalRadio->setChecked(true);
×
208
        m_frameStyle = NormalFrame;
×
209
        break;
×
210
    case SoloFrame:
×
211
        m_frameSoloRadio->setChecked(true);
×
212
        m_frameStyle = SoloFrame;
×
213
        break;
×
214
    }
215
}
×
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

© 2025 Coveralls, Inc