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

mcallegari / qlcplus / 18357067171

08 Oct 2025 08:16PM UTC coverage: 34.26% (+2.2%) from 32.066%
18357067171

push

github

mcallegari
Merge branch 'master' into filedialog

1282 of 4424 new or added lines in 152 files covered. (28.98%)

1342 existing lines in 152 files now uncovered.

17704 of 51675 relevant lines covered (34.26%)

19430.31 hits per line

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

43.84
/ui/src/fixtureselection.cpp
1
/*
2
  Q Light Controller
3
  fixtureselection.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 <QTreeWidgetItem>
21
#include <QTreeWidget>
22
#include <QHeaderView>
23
#include <QLabel>
24
#include <QAction>
25
#include <QSettings>
26

27
#include "fixturetreewidget.h"
28
#include "fixtureselection.h"
29
#include "doc.h"
30

31
#define SETTINGS_GEOMETRY "fixtureselection/geometry"
32

33
FixtureSelection::FixtureSelection(QWidget* parent, Doc* doc)
1✔
34
    : QDialog(parent)
35
    , m_doc(doc)
1✔
36
    , m_selectionMode(Fixtures)
1✔
37
{
38
    Q_ASSERT(doc != NULL);
1✔
39

40
    setupUi(this);
1✔
41

42
    QAction* action = new QAction(this);
1✔
43
    action->setShortcut(QKeySequence(QKeySequence::Close));
1✔
44
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
1✔
45
    addAction(action);
1✔
46

47
    m_treeFlags = FixtureTreeWidget::UniverseNumber |
1✔
48
                  FixtureTreeWidget::HeadsNumber |
49
                  FixtureTreeWidget::Manufacturer |
50
                  FixtureTreeWidget::Model |
51
                  FixtureTreeWidget::AddressRange |
52
                  FixtureTreeWidget::ShowGroups;
53

54
    m_tree = new FixtureTreeWidget(m_doc, m_treeFlags, this);
1✔
55
    m_mainLayout->addWidget(m_tree);
1✔
56

57
    QSettings settings;
1✔
58
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
1✔
59
    if (geometrySettings.isValid() == true)
1✔
NEW
60
        restoreGeometry(geometrySettings.toByteArray());
×
61

62
    connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
1✔
63
            this, SLOT(slotItemDoubleClicked()));
64

65
    connect(m_tree, SIGNAL(itemSelectionChanged()),
1✔
66
            this, SLOT(slotSelectionChanged()));
67
}
1✔
68

69
FixtureSelection::~FixtureSelection()
1✔
70
{
71
    QSettings settings;
1✔
72
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
2✔
73
}
1✔
74

75
int FixtureSelection::exec()
1✔
76
{
77
    //fillTree();
78
    m_tree->updateTree();
1✔
79
    if (m_tree->topLevelItemCount() == 0)
1✔
80
    {
81
        m_tree->setHeaderLabel(tr("No fixtures available"));
1✔
82
        QTreeWidgetItem* item = new QTreeWidgetItem(m_tree);
1✔
83
        item->setText(0, tr("Go to the Fixture Manager and add some fixtures first."));
1✔
84
        m_tree->resizeColumnToContents(0);
1✔
85
        m_tree->setEnabled(false);
1✔
86
        m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
1✔
87
    }
88
    return QDialog::exec();
1✔
89
}
90

91
/****************************************************************************
92
 * Selected fixtures
93
 ****************************************************************************/
94

95
QList <quint32> FixtureSelection::selection() const
×
96
{
97
    return m_selectedFixtures;
×
98
}
99

100
QList <GroupHead> FixtureSelection::selectedHeads() const
×
101
{
102
    return m_selectedHeads;
×
103
}
104

105
/****************************************************************************
106
 * Multi-selection
107
 ****************************************************************************/
108

109
void FixtureSelection::setMultiSelection(bool multi)
×
110
{
111
    if (multi == true)
×
112
        m_tree->setSelectionMode(QAbstractItemView::ExtendedSelection);
×
113
    else
114
        m_tree->setSelectionMode(QAbstractItemView::SingleSelection);
×
115
}
×
116

117
/****************************************************************************
118
 * Selection mode
119
 ****************************************************************************/
120

121
void FixtureSelection::setSelectionMode(SelectionMode mode)
×
122
{
123
    m_selectionMode = mode;
×
124
    if (mode == Fixtures)
×
125
    {
126
        m_tree->setRootIsDecorated(false);
×
127
        m_tree->setItemsExpandable(false);
×
128
        m_treeFlags = m_treeFlags & (~FixtureTreeWidget::ShowHeads);
×
129
    }
130
    else
131
    {
132
        m_tree->setRootIsDecorated(true);
×
133
        m_tree->setItemsExpandable(true);
×
134
        m_treeFlags = m_treeFlags | FixtureTreeWidget::ShowHeads;
×
135
    }
136
    m_tree->setFlags(m_treeFlags);
×
137
}
×
138

139
/****************************************************************************
140
 * Disabled items
141
 ****************************************************************************/
142

143
void FixtureSelection::setDisabledFixtures(const QList <quint32>& disabled)
×
144
{
145
    m_tree->setDisabledFixtures(disabled);
×
146
}
×
147

148
void FixtureSelection::setDisabledHeads(const QList <GroupHead>& disabled)
×
149
{
150
    m_tree->setDisabledHeads(disabled);
×
151
}
×
152

153
/****************************************************************************
154
 * Tree
155
 ****************************************************************************/
156

157
void FixtureSelection::slotItemDoubleClicked()
×
158
{
159
    if (m_tree->selectedItems().isEmpty() == false)
×
160
        accept();
×
161
}
×
162

163
void FixtureSelection::slotSelectionChanged()
×
164
{
165
    if (m_tree->selectedItems().size() > 0)
×
166
        m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
×
167
    else
168
        m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
×
169
}
×
170

171
void FixtureSelection::accept()
×
172
{
173
    m_selectedFixtures = m_tree->selectedFixtures();
×
174
    m_selectedHeads = m_tree->selectedHeads();
×
175

176
    QDialog::accept();
×
177
}
×
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