• 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/vcclockproperties.cpp
1
/*
2
  Q Light Controller Plus
3
  vcclockproperties.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 <QTimeEdit>
21

22
#include "vcclockproperties.h"
23
#include "functionselection.h"
24
#include "inputselectionwidget.h"
25

26
#define KColumnName     0
27
#define KColumnTime     1
28

29
VCClockProperties::VCClockProperties(VCClock *clock, Doc *doc)
×
30
    : QDialog(clock)
31
    , m_clock(clock)
32
    , m_doc(doc)
×
33
{
34
    Q_ASSERT(clock != NULL);
×
35

36
    setupUi(this);
×
37

38
    m_playInputWidget = new InputSelectionWidget(m_doc, this);
×
39
    m_playInputWidget->setTitle(tr("Play/Pause control"));
×
40
    m_playInputWidget->setCustomFeedbackVisibility(true);
×
41
    m_playInputWidget->setKeySequence(m_clock->playKeySequence());
×
42
    m_playInputWidget->setInputSource(m_clock->inputSource(VCClock::playInputSourceId));
×
43
    m_playInputWidget->setWidgetPage(m_clock->page());
×
44
    m_playInputWidget->show();
×
45
    m_externalInputLayout->addWidget(m_playInputWidget);
×
46

47
    m_resetInputWidget = new InputSelectionWidget(m_doc, this);
×
48
    m_resetInputWidget->setTitle(tr("Reset control"));
×
49
    m_resetInputWidget->setCustomFeedbackVisibility(true);
×
50
    m_resetInputWidget->setKeySequence(m_clock->resetKeySequence());
×
51
    m_resetInputWidget->setInputSource(m_clock->inputSource(VCClock::resetInputSourceId));
×
52
    m_resetInputWidget->setWidgetPage(m_clock->page());
×
53
    m_resetInputWidget->show();
×
54
    m_externalInputLayout->addWidget(m_resetInputWidget);
×
55

56
    m_noControlLabel->hide();
×
57

58
    switch(m_clock->clockType())
×
59
    {
60
        case VCClock::Stopwatch:
×
61
            m_stopWatchRadio->setChecked(true);
×
62
        break;
×
63
        case VCClock::Countdown:
×
64
        {
65
            m_countdownRadio->setChecked(true);
×
66
            m_hoursSpin->setValue(m_clock->getHours());
×
67
            m_minutesSpin->setValue(m_clock->getMinutes());
×
68
            m_secondsSpin->setValue(m_clock->getSeconds());
×
69
        }
70
        break;
×
71
        case VCClock::Clock:
×
72
        {
73
            m_clockRadio->setChecked(true);
×
74
            m_playInputWidget->hide();
×
75
            m_resetInputWidget->hide();
×
76
            m_noControlLabel->show();
×
77
        }
78
        break;
×
79
        default:
×
80
            m_clockRadio->setChecked(true);
×
81
        break;
×
82
    }
83

NEW
84
    foreach (VCClockSchedule sch, m_clock->schedules())
×
85
        addScheduleItem(sch);
×
86

87
    connect(m_clockRadio, SIGNAL(clicked()),
×
88
            this, SLOT(slotTypeSelectChanged()));
89
    connect(m_countdownRadio, SIGNAL(clicked()),
×
90
            this, SLOT(slotTypeSelectChanged()));
91
    connect(m_stopWatchRadio, SIGNAL(clicked()),
×
92
            this, SLOT(slotTypeSelectChanged()));
93
    connect(m_addScheduleBtn, SIGNAL(clicked()),
×
94
            this, SLOT(slotAddSchedule()));
95
    connect(m_removeScheduleBtn, SIGNAL(clicked()),
×
96
            this, SLOT(slotRemoveSchedule()));
97
}
×
98

99
VCClockProperties::~VCClockProperties()
×
100
{
101

102
}
×
103

104
void VCClockProperties::addScheduleItem(VCClockSchedule schedule)
×
105
{
106
    quint32 fid = schedule.function();
×
107
    if (fid == Function::invalidId())
×
108
        return;
×
109

110
    Function *func = m_doc->function(fid);
×
111
    if (func != NULL)
×
112
    {
113
        QTreeWidgetItem *item = new QTreeWidgetItem(m_scheduleTree);
×
114
        item->setText(KColumnName, func->name());
×
115
        item->setIcon(KColumnName, func->getIcon());
×
116
        item->setData(KColumnName, Qt::UserRole, func->id());
×
117
        QTimeEdit *timeEdit = new QTimeEdit();
×
118
        timeEdit->setDisplayFormat("HH:mm:ss");
×
119
        timeEdit->setTime(schedule.time().time());
×
120
        m_scheduleTree->setItemWidget(item, KColumnTime, timeEdit);
×
121
    }
122
    m_scheduleTree->resizeColumnToContents(KColumnName);
×
123
}
124

125
void VCClockProperties::accept()
×
126
{
127
    if (m_clockRadio->isChecked())
×
128
        m_clock->setClockType(VCClock::Clock);
×
129
    else if (m_stopWatchRadio->isChecked())
×
130
        m_clock->setClockType(VCClock::Stopwatch);
×
131
    else if (m_countdownRadio->isChecked())
×
132
    {
133
        m_clock->setClockType(VCClock::Countdown);
×
134
        m_clock->setCountdown(m_hoursSpin->value(), m_minutesSpin->value(), m_secondsSpin->value());
×
135
    }
136

137
    m_clock->removeAllSchedule();
×
138
    for (int i = 0; i < m_scheduleTree->topLevelItemCount(); i++)
×
139
    {
140
        QTreeWidgetItem *item = m_scheduleTree->topLevelItem(i);
×
141
        VCClockSchedule sch;
×
142
        sch.setFunction(item->data(KColumnName, Qt::UserRole).toUInt());
×
143
        QTimeEdit *timeEdit = (QTimeEdit *)m_scheduleTree->itemWidget(item, KColumnTime);
×
144
        if (timeEdit != NULL)
×
145
        {
146
            QDateTime dt;
×
147
            dt.setTime(timeEdit->time());
×
148
            sch.setTime(dt);
×
149
        }
150
        m_clock->addSchedule(sch);
×
151
    }
152

153
    /* Key sequences */
154
    m_clock->setPlayKeySequence(m_playInputWidget->keySequence());
×
155
    m_clock->setResetKeySequence(m_resetInputWidget->keySequence());
×
156

157
    /* Input sources */
158
    m_clock->setInputSource(m_playInputWidget->inputSource(), VCClock::playInputSourceId);
×
159
    m_clock->setInputSource(m_resetInputWidget->inputSource(), VCClock::resetInputSourceId);
×
160

161
    QDialog::accept();
×
162
}
×
163

164
void VCClockProperties::slotTypeSelectChanged()
×
165
{
166
    if (m_clockRadio->isChecked())
×
167
    {
168
        m_resetInputWidget->hide();
×
169
        m_playInputWidget->hide();
×
170
        m_noControlLabel->show();
×
171
    }
172
    else
173
    {
174
        m_resetInputWidget->show();
×
175
        m_playInputWidget->show();
×
176
        m_noControlLabel->hide();
×
177
    }
178
}
×
179

180
void VCClockProperties::slotAddSchedule()
×
181
{
182
    FunctionSelection fs(this, m_doc);
×
183

184
    if (fs.exec() == QDialog::Accepted)
×
185
    {
186
        /* Append selected functions */
187
        QListIterator <quint32> it(fs.selection());
×
188
        while (it.hasNext() == true)
×
189
        {
190
            VCClockSchedule sch;
×
191
            sch.setFunction(it.next());
×
192
            sch.setTime(QDateTime());
×
193
            addScheduleItem(sch);
×
194
        }
195
    }
196
}
×
197

198
void VCClockProperties::slotRemoveSchedule()
×
199
{
200
    QListIterator <QTreeWidgetItem *> it(m_scheduleTree->selectedItems());
×
201

202
    while (it.hasNext() == true)
×
203
    {
204
        int index = m_scheduleTree->indexOfTopLevelItem(it.next());
×
205
        m_scheduleTree->takeTopLevelItem(index);
×
206
    }
207
}
×
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