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

mcallegari / qlcplus / 8870345498

28 Apr 2024 08:58PM UTC coverage: 32.074% (-0.002%) from 32.076%
8870345498

push

github

web-flow
Merge pull request #1539 from hjtappe/qmlui-vc-not-implemented

qmlui VC "not implemented" widgets

15393 of 47992 relevant lines covered (32.07%)

22939.36 hits per line

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

88.12
/ui/src/addfixture.cpp
1
/*
2
  Q Light Controller
3
  addfixture.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 <QDialogButtonBox>
21
#include <QTreeWidgetItem>
22
#include <QTreeWidget>
23
#include <QPushButton>
24
#include <QMessageBox>
25
#include <QHeaderView>
26
#include <QByteArray>
27
#include <QSettings>
28
#include <QLineEdit>
29
#include <QComboBox>
30
#include <QSpinBox>
31
#include <QLabel>
32
#include <QDebug>
33
#include <QAction>
34

35
#include "qlcfixturedefcache.h"
36
#include "qlcfixturemode.h"
37
#include "qlcfixturedef.h"
38

39
#include "addresstool.h"
40
#include "addfixture.h"
41
#include "apputil.h"
42
#include "doc.h"
43

44
#define SETTINGS_GEOMETRY "addfixture/geometry"
45

46
#define KColumnName 0
47

48
AddFixture::AddFixture(QWidget* parent, const Doc* doc, const Fixture* fxi)
7✔
49
    : QDialog(parent)
50
    , m_doc(doc)
7✔
51
{
52
    m_addressValue = 0;
7✔
53
    m_universeValue = 0;
7✔
54
    m_amountValue = 1;
7✔
55
    m_gapValue = 0;
7✔
56
    m_channelsValue = 1;
7✔
57
    m_fixtureDef = NULL;
7✔
58
    m_mode = NULL;
7✔
59
    m_fxiCount = 0;
7✔
60
    m_fixtureID = Fixture::invalidId();
7✔
61
    m_invalidAddressFlag = false;
7✔
62

63
    setupUi(this);
7✔
64
    m_addrErrorLabel->hide();
7✔
65

66
    QAction* action = new QAction(this);
7✔
67
    action->setShortcut(QKeySequence(QKeySequence::Close));
7✔
68
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
7✔
69
    addAction(action);
7✔
70

71
    connect(m_tree, SIGNAL(itemSelectionChanged()),
7✔
72
            this, SLOT(slotSelectionChanged()));
73
    connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
7✔
74
            this, SLOT(slotTreeDoubleClicked(QTreeWidgetItem*)));
75
    connect(m_modeCombo, SIGNAL(activated(const QString&)),
7✔
76
            this, SLOT(slotModeActivated(const QString&)));
77
    connect(m_universeCombo, SIGNAL(activated(int)),
7✔
78
            this, SLOT(slotUniverseActivated(int)));
79
    connect(m_addressSpin, SIGNAL(valueChanged(int)),
7✔
80
            this, SLOT(slotAddressChanged(int)));
81
    connect(m_channelsSpin, SIGNAL(valueChanged(int)),
7✔
82
            this, SLOT(slotChannelsChanged(int)));
83
    connect(m_nameEdit, SIGNAL(textEdited(const QString&)),
7✔
84
            this, SLOT(slotNameEdited(const QString&)));
85
    connect(m_gapSpin, SIGNAL(valueChanged(int)),
7✔
86
            this, SLOT(slotGapSpinChanged(int)));
87
    connect(m_amountSpin, SIGNAL(valueChanged(int)),
7✔
88
            this, SLOT(slotAmountSpinChanged(int)));
89
    connect(m_searchEdit, SIGNAL(textChanged(QString)),
7✔
90
            this, SLOT(slotSearchFilterChanged(QString)));
91
    connect(m_diptoolButton, SIGNAL(clicked()),
7✔
92
            this, SLOT(slotDiptoolButtonClicked()));
93

94
    /* Fill fixture definition tree (and select a fixture def) */
95
    if (fxi != NULL)
7✔
96
    {
97
        fillTree(fxi->fixtureDef()->manufacturer(), fxi->fixtureDef()->model());
2✔
98
        m_fixtureID = fxi->id();
2✔
99
    }
100
    else
101
        fillTree(KXMLFixtureGeneric, KXMLFixtureGeneric);
5✔
102

103
    m_fixturesCount->setText(tr("Fixtures found: %1").arg(m_fxiCount));
7✔
104

105
    /* Fill universe combo with available universes */
106
    m_universeCombo->addItems(m_doc->inputOutputMap()->universeNames());
7✔
107

108
    /* Simulate first selection and find the next free address */
109
    slotSelectionChanged();
7✔
110

111
    if (fxi != NULL)
7✔
112
    {
113
        // Universe
114
        m_universeCombo->setCurrentIndex(fxi->universe());
2✔
115
        slotUniverseActivated(fxi->universe());
2✔
116

117
        m_addressSpin->setValue(fxi->address() + 1);
2✔
118
        m_addressValue = fxi->address();
2✔
119

120
        m_multipleGroup->setEnabled(false);
2✔
121

122
        // Name
123
        m_nameEdit->setText(fxi->name());
2✔
124
        slotNameEdited(fxi->name());
2✔
125
        m_nameEdit->setModified(true); // Prevent auto-naming
2✔
126

127
        // Mode
128
        int index = m_modeCombo->findText(fxi->fixtureMode()->name());
2✔
129
        if (index != -1)
2✔
130
        {
131
            m_channelsSpin->setValue(fxi->channels());
2✔
132
            m_modeCombo->setCurrentIndex(index);
2✔
133
            slotModeActivated(m_modeCombo->itemText(index));
2✔
134
        }
135
    }
136
    else
137
    {
138
        slotUniverseActivated(0);
5✔
139
        findAddress();
5✔
140

141
        m_channelsSpin->setValue(1);
5✔
142
    }
143

144
    QSettings settings;
14✔
145
    QVariant var = settings.value(SETTINGS_GEOMETRY);
21✔
146
    if (var.isValid() == true)
7✔
147
        restoreGeometry(var.toByteArray());
6✔
148
    AppUtil::ensureWidgetIsVisible(this);
7✔
149
}
7✔
150

151
AddFixture::~AddFixture()
7✔
152
{
153
    QSettings settings;
14✔
154
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
7✔
155

156
    QList<QVariant> expanded;
7✔
157
    QTreeWidgetItem * root = m_tree->invisibleRootItem();
7✔
158

159
    for (int i=0; i < root->childCount(); i++)
980✔
160
    {
161
        QTreeWidgetItem * manuf = root->child(i);
973✔
162
        if (manuf->isExpanded())
973✔
163
        {
164
            expanded << manuf->text(KColumnName);
13✔
165
        }
166
    }
167

168
    settings.setValue(SETTINGS_EXPANDED, expanded);
7✔
169
}
7✔
170

171
/*****************************************************************************
172
 * Value getters
173
 *****************************************************************************/
174

175
QLCFixtureDef* AddFixture::fixtureDef() const
5✔
176
{
177
    return m_fixtureDef;
5✔
178
}
179

180
QLCFixtureMode *AddFixture::mode() const
5✔
181
{
182
    return m_mode;
5✔
183
}
184

185
QString AddFixture::name() const
5✔
186
{
187
    return m_nameValue;
5✔
188
}
189

190
quint32 AddFixture::address() const
5✔
191
{
192
    return m_addressValue;
5✔
193
}
194

195
quint32 AddFixture::universe() const
5✔
196
{
197
    return m_universeValue;
5✔
198
}
199

200
int AddFixture::amount() const
5✔
201
{
202
    return m_amountValue;
5✔
203
}
204

205
quint32 AddFixture::gap() const
5✔
206
{
207
    return m_gapValue;
5✔
208
}
209

210
quint32 AddFixture::channels() const
5✔
211
{
212
    return m_channelsValue;
5✔
213
}
214

215
bool AddFixture::invalidAddress()
×
216
{
217
    return m_invalidAddressFlag;
×
218
}
219

220
/*****************************************************************************
221
 * Fillers
222
 *****************************************************************************/
223

224
void AddFixture::fillTree(const QString& selectManufacturer,
7✔
225
                          const QString& selectModel)
226
{
227
    QTreeWidgetItem* parent = NULL;
7✔
228
    QTreeWidgetItem* child;
229
    QString manuf;
14✔
230
    QString model;
14✔
231
    QList<QVariant> expanded;
14✔
232

233
    QSettings settings;
14✔
234
    QVariant var = settings.value(SETTINGS_EXPANDED);
21✔
235
    if (var.isValid() == true)
7✔
236
    {
237
        expanded = var.toList();
6✔
238
    }
239

240
    /* Clear the tree of any previous data */
241
    m_tree->clear();
7✔
242

243
    QString filter = m_searchEdit->text().toLower();
14✔
244

245
    /* Add all known fixture definitions to the tree */
246
    QStringListIterator it(m_doc->fixtureDefCache()->manufacturers());
21✔
247
    while (it.hasNext() == true)
980✔
248
    {
249
        bool manufAdded = false;
973✔
250

251
        manuf = it.next();
973✔
252
        if (manuf == KXMLFixtureGeneric)
973✔
253
            continue;
7✔
254

255
        QStringListIterator modit(m_doc->fixtureDefCache()->models(manuf));
2,898✔
256
        while (modit.hasNext() == true)
11,627✔
257
        {
258
            model = modit.next();
10,661✔
259

260
            if (filter.isEmpty() == false &&
31,983✔
261
                manuf.toLower().contains(filter) == false &&
21,322✔
262
                model.toLower().contains(filter) == false)
10,661✔
263
                    continue;
×
264

265
            if (manufAdded == false)
10,661✔
266
            {
267
                parent = new QTreeWidgetItem(m_tree);
966✔
268
                parent->setText(KColumnName, manuf);
966✔
269
                manufAdded = true;
966✔
270
            }
271
            child = new QTreeWidgetItem(parent);
10,661✔
272
            child->setText(KColumnName, model);
10,661✔
273

274
            if (manuf == selectManufacturer &&
10,729✔
275
                    model == selectModel)
68✔
276
            {
277
                parent->setExpanded(true);
1✔
278
                m_tree->setCurrentItem(child);
1✔
279
            }
280
            else if (expanded.indexOf(manuf) != -1)
10,660✔
281
            {
282
                parent->setExpanded(true);
276✔
283
            }
284
            m_fxiCount++;
10,661✔
285
        }
286
    }
287

288
    /* Sort the tree A-Z BEFORE appending a generic entries */
289
    m_tree->sortItems(0, Qt::AscendingOrder);
7✔
290

291
    /* Create a parent for the generic devices */
292
    parent = new QTreeWidgetItem(m_tree);
7✔
293
    parent->setText(KColumnName, KXMLFixtureGeneric);
7✔
294
    QStringListIterator modit(m_doc->fixtureDefCache()->models(KXMLFixtureGeneric));
21✔
295
    while (modit.hasNext() == true)
28✔
296
    {
297
        model = modit.next();
21✔
298
        child = new QTreeWidgetItem(parent);
21✔
299
        child->setText(KColumnName, model);
21✔
300

301
        if (selectManufacturer == KXMLFixtureGeneric &&
39✔
302
                model == selectModel)
18✔
303
        {
304
            parent->setExpanded(true);
×
305
            m_tree->setCurrentItem(child);
×
306
        }
307
        else if (expanded.indexOf(manuf) != -1)
21✔
308
        {
309
            parent->setExpanded(true);
×
310
        }
311
        m_fxiCount++;
21✔
312
    }
313

314
    /* Create a child for generic dimmer device */
315
    child = new QTreeWidgetItem(parent);
7✔
316
    child->setText(KColumnName, KXMLFixtureGeneric);
7✔
317

318
    parent->sortChildren(0, Qt::AscendingOrder);
7✔
319

320
    /* Select generic dimmer by default */
321
    if (selectManufacturer == KXMLFixtureGeneric &&
20✔
322
            selectModel == KXMLFixtureGeneric)
13✔
323
    {
324
        parent->setExpanded(true);
6✔
325
        m_tree->setCurrentItem(child);
6✔
326
    }
327
}
7✔
328

329
void AddFixture::fillModeCombo(const QString& text)
17✔
330
{
331
    m_modeCombo->clear();
17✔
332

333
    if (m_fixtureDef == NULL)
17✔
334
    {
335
        m_modeCombo->setEnabled(false);
14✔
336
        m_modeCombo->addItem(text);
14✔
337
        m_modeCombo->setCurrentIndex(0);
14✔
338
        m_mode = NULL;
14✔
339
    }
340
    else
341
    {
342
        m_modeCombo->setEnabled(true);
3✔
343

344
        QListIterator <QLCFixtureMode*> it(m_fixtureDef->modes());
6✔
345
        while (it.hasNext() == true)
12✔
346
            m_modeCombo->addItem(it.next()->name());
9✔
347

348
        /* Select the first mode by default */
349
        m_modeCombo->setCurrentIndex(0);
3✔
350
        slotModeActivated(m_modeCombo->currentText());
3✔
351
    }
352
}
17✔
353

354
void AddFixture::findAddress()
5✔
355
{
356
    /* Find the next free address space for x fixtures, each taking y
357
       channels, leaving z channels gap in-between. */
358
    quint32 address = findAddress((m_channelsValue + m_gapValue) * m_amountValue,
10✔
359
                                  m_doc->fixtures(),
5✔
360
                                  m_doc->inputOutputMap()->universesCount());
5✔
361

362
    /* Set the address only if the channel space was really found */
363
    if (address != QLCChannel::invalid())
5✔
364
    {
365
        m_universeCombo->setCurrentIndex(address >> 9);
5✔
366
        m_addressSpin->setValue((address & 0x01FF) + 1);
5✔
367
    }
368
}
5✔
369

370
quint32 AddFixture::findAddress(quint32 numChannels,
21✔
371
                                QList<Fixture*> const& fixtures,
372
                                quint32 maxUniverses)
373
{
374
    /* Try to find contiguous space from one universe at a time */
375
    for (quint32 universe = 0; universe < maxUniverses; universe++)
30✔
376
    {
377
        quint32 ch = findAddress(universe, numChannels, fixtures);
28✔
378
        if (ch != QLCChannel::invalid())
28✔
379
            return ch;
19✔
380
    }
381

382
    return QLCChannel::invalid();
2✔
383
}
384

385
quint32 AddFixture::findAddress(quint32 universe, quint32 numChannels,
52✔
386
                                QList<Fixture*> const& fixtures, quint32 currentFixture)
387
{
388
    quint32 freeSpace = 0;
52✔
389
    quint32 maxChannels = 512;
52✔
390

391
    /* Construct a map of unallocated channels */
392
    int map[maxChannels];
52✔
393
    std::fill(map, map + maxChannels, 0);
×
394

395
    QListIterator <Fixture*> fxit(fixtures);
104✔
396
    while (fxit.hasNext() == true)
131✔
397
    {
398
        Fixture* fxi(fxit.next());
79✔
399
        Q_ASSERT(fxi != NULL);
79✔
400

401
        if (fxi->universe() != universe)
79✔
402
            continue;
44✔
403

404
        if (fxi->id() == currentFixture && currentFixture != Fixture::invalidId())
35✔
405
            continue;
3✔
406

407
        for (quint32 ch = 0; ch < fxi->channels(); ch++)
442✔
408
            map[(fxi->universeAddress() & 0x01FF) + ch] = 1;
410✔
409
    }
410

411
    /* Try to find the next contiguous free address space */
412
    for (quint32 addr = 0; addr < maxChannels; addr++)
6,082✔
413
    {
414
        if (map[addr] == 0)
6,073✔
415
            freeSpace++;
5,798✔
416
        else
417
            freeSpace = 0;
275✔
418

419
        if (freeSpace == numChannels)
6,073✔
420
            return (addr - freeSpace + 1) | (universe << 9);
43✔
421
    }
422

423
    return QLCChannel::invalid();
61✔
424
}
425

426
void AddFixture::updateMaximumAmount()
28✔
427
{
428
    m_amountSpin->setRange(1, (513 - m_addressSpin->value()) /
28✔
429
                           (m_channelsSpin->value() + m_gapSpin->value()));
28✔
430
}
28✔
431

432
bool AddFixture::checkAddressAvailability(int value, int channels)
13✔
433
{
434
    qDebug() << "Check availability for address: " << value;
13✔
435
    for (int i = 0; i < channels; i++)
60✔
436
    {
437
        quint32 fid = m_doc->fixtureForAddress(value + i);
47✔
438
        if (fid != Fixture::invalidId() && fid != m_fixtureID)
47✔
439
            return false;
×
440
    }
441
    return true;
13✔
442
}
443

444
/*****************************************************************************
445
 * Slots
446
 *****************************************************************************/
447

448
void AddFixture::slotModeActivated(const QString& modeName)
5✔
449
{
450
    if (m_fixtureDef == NULL)
5✔
451
        return;
×
452

453
    m_mode = m_fixtureDef->mode(modeName);
5✔
454
    if (m_mode == NULL)
5✔
455
    {
456
        /* Generic dimmers don't have modes, so bail out */
457
        // slotSelectionChanged();
458
        return;
×
459
    }
460

461
    m_channelsSpin->setValue(m_mode->channels().size());
5✔
462

463
    /* Show all selected mode channels in the list */
464
    m_channelList->clear();
5✔
465
    for (int i = 0; i < m_mode->channels().size(); i++)
44✔
466
    {
467
        QLCChannel* channel = m_mode->channel(i);
39✔
468
        Q_ASSERT(channel != NULL);
39✔
469

470
        new QListWidgetItem(
471
            QString("%1: %2").arg(i + 1).arg(channel->name()),
78✔
472
            m_channelList);
39✔
473
    }
474
}
475

476
void AddFixture::slotUniverseActivated(int universe)
7✔
477
{
478
    m_universeValue = universe;
7✔
479

480
    /* Adjust the available address range */
481
    slotChannelsChanged(m_channelsValue);
7✔
482

483
    quint32 addr = findAddress(universe, m_channelsSpin->value(), m_doc->fixtures(), m_fixtureID);
7✔
484
    if (addr != QLCChannel::invalid())
7✔
485
        m_addressSpin->setValue((addr & 0x01FF) + 1);
7✔
486
    else
487
        m_addressSpin->setValue(1);
×
488
}
7✔
489

490
void AddFixture::slotAddressChanged(int value)
2✔
491
{
492
    m_addressValue = value - 1;
2✔
493

494
    /* Set the maximum number of fixtures */
495
    updateMaximumAmount();
2✔
496

497
    checkOverlapping();
2✔
498
}
2✔
499

500
void AddFixture::slotChannelsChanged(int value)
11✔
501
{
502
    m_channelsValue = value;
11✔
503

504
    /* Set the maximum possible address so that channels cannot overflow
505
       beyond DMX's range of 512 channels */
506
    m_addressSpin->setRange(1, 513 - value);
11✔
507

508
    /* Set the maximum number of fixtures */
509
    updateMaximumAmount();
11✔
510

511
    checkOverlapping();
11✔
512
}
11✔
513

514
void AddFixture::slotNameEdited(const QString &text)
19✔
515
{
516
    /* If the user clears the text in the name field,
517
       start substituting the name with the model again. */
518
    if (text.length() == 0)
19✔
519
        m_nameEdit->setModified(false);
2✔
520
    else
521
        m_nameEdit->setModified(true);
17✔
522
    m_nameValue = text;
19✔
523
}
19✔
524

525
void AddFixture::slotAmountSpinChanged(int value)
×
526
{
527
    m_amountValue = value;
×
528

529
    checkOverlapping();
×
530
}
×
531

532
void AddFixture::slotGapSpinChanged(int value)
×
533
{
534
    m_gapValue = value;
×
535

536
    /* Set the maximum number of fixtures */
537
    updateMaximumAmount();
×
538

539
    checkOverlapping();
×
540
}
×
541

542
void AddFixture::slotSearchFilterChanged(QString)
×
543
{
544
    m_tree->blockSignals(true);
×
545
    fillTree("", "");
×
546
    m_tree->blockSignals(false);
×
547
}
×
548

549
void AddFixture::slotSelectionChanged()
17✔
550
{
551
    /* If there is no valid selection (user has selected only a
552
       manufacturer or nothing at all) don't let him press OK. */
553
    QTreeWidgetItem* item = m_tree->currentItem();
17✔
554
    if (item == NULL || item->parent() == NULL)
17✔
555
    {
556
        /* Reset the selected fixture pointer */
557
        m_fixtureDef = NULL;
2✔
558

559
        /* Since there is no m_fixtureDef, mode combo is cleared */
560
        fillModeCombo();
2✔
561

562
        /* Clear the name box unless it has been modified by user */
563
        if (m_nameEdit->isModified() == false)
2✔
564
        {
565
            m_nameEdit->setText(QString());
2✔
566
            slotNameEdited(QString());
2✔
567
            m_nameEdit->setModified(false);
2✔
568
        }
569
        m_nameEdit->setEnabled(false);
2✔
570

571
        m_channelsSpin->setValue(0);
2✔
572
        m_channelList->clear();
2✔
573
        m_addressSpin->setEnabled(false);
2✔
574
        m_universeCombo->setEnabled(false);
2✔
575

576
        m_multipleGroup->setEnabled(false);
2✔
577
        m_amountSpin->setEnabled(false);
2✔
578
        m_gapSpin->setEnabled(false);
2✔
579
        m_channelsSpin->setEnabled(false);
2✔
580

581
        m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
2✔
582

583
        return;
2✔
584
    }
585

586
    /* Item & its parent should be valid here */
587
    QString manuf(item->parent()->text(KColumnName));
30✔
588
    QString model(item->text(KColumnName));
30✔
589
    if (manuf == KXMLFixtureGeneric && model == KXMLFixtureGeneric)
15✔
590
    {
591
        /* Generic dimmer selected. User enters number of channels. */
592
        if (m_fixtureID != Fixture::invalidId())
13✔
593
        {
594
            Fixture *fxi = m_doc->fixture(m_fixtureID);
1✔
595
            if (fxi != NULL)
1✔
596
            {
597
                m_fixtureDef = fxi->fixtureDef();
1✔
598
                m_mode = fxi->fixtureMode();
1✔
599

600
                if (m_fixtureDef->manufacturer() != manuf || m_fixtureDef->model() != model)
1✔
601
                {
602
                    m_fixtureDef = NULL;
×
603
                }
604
            }
605
            else
606
            {
607
                m_fixtureDef = NULL;
×
608
            }
609
        }
610
        else
611
        {
612
            m_fixtureDef = NULL;
12✔
613
        }
614
        fillModeCombo();
13✔
615
        m_modeCombo->setEnabled(false);
13✔
616
        m_channelsSpin->setValue(1);
13✔
617
        m_channelsSpin->setEnabled(true);
13✔
618
        m_channelList->clear();
13✔
619

620
        /* Set the model name as the fixture's friendly name ONLY
621
           if the user hasn't modified the friendly name field. */
622
        if (m_nameEdit->isModified() == false)
13✔
623
        {
624
            m_nameEdit->setText(tr("Dimmers"));
13✔
625
            slotNameEdited(m_nameEdit->text());
13✔
626
            m_nameEdit->setModified(false);
13✔
627
        }
628
        m_nameEdit->setEnabled(true);
13✔
629
    }
630
    else
631
    {
632
        /* Specific fixture definition selected. */
633
        m_fixtureDef = m_doc->fixtureDefCache()->fixtureDef(manuf, model);
2✔
634
        Q_ASSERT(m_fixtureDef != NULL);
2✔
635

636
        /* Put fixture def's modes to the mode combo */
637
        fillModeCombo();
2✔
638

639
        /* Fixture def contains number of channels, so disable the
640
           spin box to prevent user from modifying it. */
641
        m_channelsSpin->setEnabled(false);
2✔
642

643
        /* Set the model name as the fixture's friendly name ONLY
644
           if the user hasn't modified the friendly name field. */
645
        if (m_nameEdit->isModified() == false)
2✔
646
        {
647
            m_nameEdit->setText(m_fixtureDef->model());
2✔
648
            slotNameEdited(m_nameEdit->text());
2✔
649
            m_nameEdit->setModified(false);
2✔
650
        }
651
        m_nameEdit->setEnabled(true);
2✔
652
    }
653

654
    /* Set the maximum number of fixtures */
655
    updateMaximumAmount();
15✔
656

657
    /* Guide the user to edit the friendly name field */
658
    m_nameEdit->setSelection(0, m_nameEdit->text().length());
15✔
659
    m_nameEdit->setFocus();
15✔
660

661
    m_addressSpin->setEnabled(true);
15✔
662
    m_universeCombo->setEnabled(true);
15✔
663

664
    m_multipleGroup->setEnabled(true);
15✔
665
    m_amountSpin->setEnabled(true);
15✔
666
    m_gapSpin->setEnabled(true);
15✔
667

668
    /* Recalculate the first available address for the newly selected fixture */
669
    quint32 addr = findAddress(m_universeValue, m_channelsSpin->value(), m_doc->fixtures(), m_fixtureID);
15✔
670
    if (addr != QLCChannel::invalid())
15✔
671
        m_addressSpin->setValue((addr & 0x01FF) + 1);
15✔
672
    else
673
        m_addressSpin->setValue(1);
×
674

675
    /* OK is again possible */
676
    m_buttonBox->setStandardButtons(QDialogButtonBox::Ok |
15✔
677
                                    QDialogButtonBox::Cancel);
678
}
679

680
void AddFixture::slotTreeDoubleClicked(QTreeWidgetItem* item)
×
681
{
682
    /* Select and accept (click OK for the user) */
683
    slotSelectionChanged();
×
684
    if (item != NULL && item->parent() != NULL)
×
685
        accept();
×
686
}
×
687

688
void AddFixture::slotDiptoolButtonClicked()
×
689
{
690
    AddressTool at(this, m_addressSpin->value());
×
691
    at.exec();
×
692
    m_addressSpin->setValue(at.getAddress());
×
693
}
×
694

695
void AddFixture::checkOverlapping()
13✔
696
{
697
    for (int i = 0; i < m_amountValue; ++i)
26✔
698
    {
699
        int address = m_addressValue + i * (m_gapValue + m_channelsValue);
13✔
700
        int absAddress = (address & 0x01FF) | (m_universeValue << 9);
13✔
701
        if (checkAddressAvailability(absAddress, m_channelsValue) == false)
13✔
702
        {
703
            // Show overlapping error
704
            m_addrErrorLabel->show();
×
705
            m_invalidAddressFlag = true;
×
706
            return;
×
707
        }
708
    }
709

710
    m_addrErrorLabel->hide();
13✔
711
    m_invalidAddressFlag = false;
13✔
712
}
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