• 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/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

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

30
FixtureSelection::FixtureSelection(QWidget* parent, Doc* doc)
×
31
    : QDialog(parent)
32
    , m_doc(doc)
33
    , m_selectionMode(Fixtures)
×
34
{
35
    Q_ASSERT(doc != NULL);
×
36

37
    setupUi(this);
×
38

39
    QAction* action = new QAction(this);
×
40
    action->setShortcut(QKeySequence(QKeySequence::Close));
×
41
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
×
42
    addAction(action);
×
43

44
    m_treeFlags = FixtureTreeWidget::UniverseNumber |
×
45
                  FixtureTreeWidget::HeadsNumber |
46
                  FixtureTreeWidget::Manufacturer |
47
                  FixtureTreeWidget::Model |
48
                  FixtureTreeWidget::ShowGroups;
49

50
    m_tree = new FixtureTreeWidget(m_doc, m_treeFlags, this);
×
51
    m_mainLayout->addWidget(m_tree);
×
52

53
    connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
×
54
            this, SLOT(slotItemDoubleClicked()));
55

56
    connect(m_tree, SIGNAL(itemSelectionChanged()),
×
57
            this, SLOT(slotSelectionChanged()));
58
}
×
59

60
FixtureSelection::~FixtureSelection()
×
61
{
62
}
×
63

64
int FixtureSelection::exec()
×
65
{
66
    //fillTree();
67
    m_tree->updateTree();
×
68
    if (m_tree->topLevelItemCount() == 0)
×
69
    {
70
        m_tree->setHeaderLabel(tr("No fixtures available"));
×
71
        QTreeWidgetItem* item = new QTreeWidgetItem(m_tree);
×
72
        item->setText(0, tr("Go to the Fixture Manager and add some fixtures first."));
×
73
        m_tree->resizeColumnToContents(0);
×
74
        m_tree->setEnabled(false);
×
75
        m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
×
76
    }
77
    return QDialog::exec();
×
78
}
79

80
/****************************************************************************
81
 * Selected fixtures
82
 ****************************************************************************/
83

84
QList <quint32> FixtureSelection::selection() const
×
85
{
86
    return m_selectedFixtures;
×
87
}
88

89
QList <GroupHead> FixtureSelection::selectedHeads() const
×
90
{
91
    return m_selectedHeads;
×
92
}
93

94
/****************************************************************************
95
 * Multi-selection
96
 ****************************************************************************/
97

98
void FixtureSelection::setMultiSelection(bool multi)
×
99
{
100
    if (multi == true)
×
101
        m_tree->setSelectionMode(QAbstractItemView::ExtendedSelection);
×
102
    else
103
        m_tree->setSelectionMode(QAbstractItemView::SingleSelection);
×
104
}
×
105

106
/****************************************************************************
107
 * Selection mode
108
 ****************************************************************************/
109

110
void FixtureSelection::setSelectionMode(SelectionMode mode)
×
111
{
112
    m_selectionMode = mode;
×
113
    if (mode == Fixtures)
×
114
    {
115
        m_tree->setRootIsDecorated(false);
×
116
        m_tree->setItemsExpandable(false);
×
117
        m_treeFlags = m_treeFlags & (~FixtureTreeWidget::ShowHeads);
×
118
    }
119
    else
120
    {
121
        m_tree->setRootIsDecorated(true);
×
122
        m_tree->setItemsExpandable(true);
×
123
        m_treeFlags = m_treeFlags | FixtureTreeWidget::ShowHeads;
×
124
    }
125
    m_tree->setFlags(m_treeFlags);
×
126
}
×
127

128
/****************************************************************************
129
 * Disabled items
130
 ****************************************************************************/
131

132
void FixtureSelection::setDisabledFixtures(const QList <quint32>& disabled)
×
133
{
134
    m_tree->setDisabledFixtures(disabled);
×
135
}
×
136

137
void FixtureSelection::setDisabledHeads(const QList <GroupHead>& disabled)
×
138
{
139
    m_tree->setDisabledHeads(disabled);
×
140
}
×
141

142
/****************************************************************************
143
 * Tree
144
 ****************************************************************************/
145

146
void FixtureSelection::slotItemDoubleClicked()
×
147
{
148
    if (m_tree->selectedItems().isEmpty() == false)
×
149
        accept();
×
150
}
×
151

152
void FixtureSelection::slotSelectionChanged()
×
153
{
154
    if (m_tree->selectedItems().size() > 0)
×
155
        m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
×
156
    else
157
        m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
×
158
}
×
159

160
void FixtureSelection::accept()
×
161
{
162
    m_selectedFixtures = m_tree->selectedFixtures();
×
163
    m_selectedHeads = m_tree->selectedHeads();
×
164

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