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

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

40
    setupUi(this);
×
41

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

47
    m_treeFlags = FixtureTreeWidget::UniverseNumber |
×
48
                  FixtureTreeWidget::HeadsNumber |
49
                  FixtureTreeWidget::Manufacturer |
50
                  FixtureTreeWidget::Model |
51
                  FixtureTreeWidget::ShowGroups;
52

53
    m_tree = new FixtureTreeWidget(m_doc, m_treeFlags, this);
×
54
    m_mainLayout->addWidget(m_tree);
×
55

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

UNCOV
61
    connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
×
62
            this, SLOT(slotItemDoubleClicked()));
63

64
    connect(m_tree, SIGNAL(itemSelectionChanged()),
×
65
            this, SLOT(slotSelectionChanged()));
66
}
×
67

68
FixtureSelection::~FixtureSelection()
×
69
{
NEW
70
    QSettings settings;
×
NEW
71
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
UNCOV
72
}
×
73

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

90
/****************************************************************************
91
 * Selected fixtures
92
 ****************************************************************************/
93

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

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

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

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

116
/****************************************************************************
117
 * Selection mode
118
 ****************************************************************************/
119

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

138
/****************************************************************************
139
 * Disabled items
140
 ****************************************************************************/
141

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

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

152
/****************************************************************************
153
 * Tree
154
 ****************************************************************************/
155

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

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

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

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