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

mcallegari / qlcplus / 14809507932

03 May 2025 09:13AM UTC coverage: 31.879% (+0.03%) from 31.845%
14809507932

push

github

web-flow
Merge pull request #1745 from mcallegari/qmluiqt6

Port QML UI to Qt6

2 of 9 new or added lines in 3 files covered. (22.22%)

3720 existing lines in 174 files now uncovered.

16422 of 51513 relevant lines covered (31.88%)

19079.9 hits per line

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

0.0
/ui/src/showmanager/showeditor.cpp
1
/*
2
  Q Light Controller
3
  showeditor.cpp
4

5
  Copyright (c) Massimo Callegari
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 <QLineEdit>
23
#include <QLabel>
24
#include <QDebug>
25

26
#include "chaserstep.h"
27
#include "showeditor.h"
28
#include "chaser.h"
29
#include "track.h"
30
#include "scene.h"
31
#include "show.h"
32
#include "doc.h"
33

34
#define NAME_COL  0
35
#define STEPS_COL 1
36
#define TIME_COL  2
37
#define DUR_COL   3
38

39
#define PROP_ID Qt::UserRole
40

41
ShowEditor::ShowEditor(QWidget* parent, Show* show, Doc* doc)
×
42
    : QWidget(parent)
43
    , m_doc(doc)
×
44
    , m_show(show)
×
45
{
UNCOV
46
    Q_ASSERT(doc != NULL);
×
UNCOV
47
    Q_ASSERT(show != NULL);
×
48

49
    setupUi(this);
×
50
    m_tree->setRootIsDecorated(true);
×
51
    m_tree->setSortingEnabled(false);
×
52
    m_tree->setSelectionMode(QAbstractItemView::SingleSelection);
×
53
    m_tree->header()->setSectionResizeMode(QHeaderView::Interactive);
×
54

55
    connect(m_nameEdit, SIGNAL(textEdited(const QString&)),
×
56
            this, SLOT(slotNameEdited(const QString&)));
57
    connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd()));
×
58
    connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove()));
×
59

60
    // for now just disabled the add/remove buttons
61
    m_add->setVisible(false);
×
62
    m_remove->setVisible(false);
×
63

64
    m_nameEdit->setText(m_show->name());
×
65
    m_nameEdit->setSelection(0, m_nameEdit->text().length());
×
66

67
    updateFunctionList();
×
68

69
    // Set focus to the editor
70
    m_nameEdit->setFocus();
×
71
}
×
72

73
ShowEditor::~ShowEditor()
×
74
{
75
}
×
76

77
void ShowEditor::slotNameEdited(const QString& text)
×
78
{
79
    m_show->setName(text);
×
80
}
×
81

82
void ShowEditor::slotAdd()
×
83
{
84

85
}
×
86

87
void ShowEditor::slotRemove()
×
88
{
89

90
}
×
91

92
void ShowEditor::updateFunctionList()
×
93
{
UNCOV
94
    quint32 totalDuration = 0;
×
UNCOV
95
    QHash <quint32, QTreeWidgetItem*>scenesMap;
×
96

97
    m_tree->clear();
×
98

99
    if (m_show == NULL)
×
100
    {
UNCOV
101
        qDebug() << Q_FUNC_INFO << "Invalid show!";
×
UNCOV
102
        return;
×
103
    }
104

105
    QTreeWidgetItem* masterItem = new QTreeWidgetItem(m_tree);
×
106
    masterItem->setText(NAME_COL, m_show->name());
×
107
    masterItem->setData(NAME_COL, PROP_ID, m_show->id());
×
108
    masterItem->setIcon(NAME_COL, QIcon(":/show.png"));
×
109

110
    foreach (Track *track, m_show->tracks())
×
111
    {
UNCOV
112
        QTreeWidgetItem* sceneItem = NULL;
×
113
        Scene *scene = qobject_cast<Scene*>(m_doc->function(track->getSceneID()));
×
114
        if (scene != NULL)
×
115
        {
116
            sceneItem = scenesMap[scene->id()];
×
117
            if (sceneItem == NULL)
×
118
            {
119
                sceneItem = new QTreeWidgetItem(masterItem);
×
120
                sceneItem->setText(NAME_COL, scene->name());
×
121
                sceneItem->setData(NAME_COL, PROP_ID, scene->id());
×
122
                sceneItem->setIcon(NAME_COL, QIcon(":/scene.png"));
×
123
            }
124
        }
125

126
        foreach (ShowFunction *sf, track->showFunctions())
×
127
        {
128
            Function *func = m_doc->function(sf->functionID());
×
129
            if (func == NULL)
×
130
            {
UNCOV
131
                qDebug() << "Cannot find Function with ID:" << sf->functionID();
×
132
                continue;
×
133
            }
134

UNCOV
135
            QTreeWidgetItem *fItem = NULL;
×
136
            if (sceneItem == NULL)
×
137
                fItem = new QTreeWidgetItem(masterItem);
×
138
            else
139
                fItem = new QTreeWidgetItem(sceneItem);
×
140

141
            fItem->setText(NAME_COL, func->name());
×
142
            fItem->setData(NAME_COL, PROP_ID, func->id());
×
143
            fItem->setText(TIME_COL, Function::speedToString(sf->startTime()));
×
144
            fItem->setText(DUR_COL, Function::speedToString(sf->duration(m_doc)));
×
145
            if (sf->startTime() + sf->duration(m_doc) > totalDuration)
×
146
                totalDuration = sf->startTime() + sf->duration(m_doc);
×
147

148
            if (func->type() == Function::ChaserType)
×
149
            {
UNCOV
150
                Chaser *chaser = qobject_cast<Chaser*>(func);
×
151
                fItem->setIcon(NAME_COL, QIcon(":/sequence.png"));
×
152
                fItem->setText(STEPS_COL, QString("%1").arg(chaser->steps().count()));
×
153
            }
154
            else
155
                fItem->setIcon(NAME_COL, func->getIcon());
×
UNCOV
156
        }
×
UNCOV
157
    }
×
158

159
    masterItem->setText(DUR_COL, Function::speedToString(totalDuration));
×
160

161
    m_tree->expandAll();
×
162
    m_tree->header()->resizeSections(QHeaderView::ResizeToContents);
×
163
}
×
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