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

mcallegari / qlcplus / 12611954629

04 Jan 2025 04:17PM UTC coverage: 31.468% (-0.5%) from 31.963%
12611954629

Pull #1649

github

web-flow
Merge d17d3ec9b into 3ed321c32
Pull Request #1649: Function Wizard: create Effects

2 of 53 new or added lines in 2 files covered. (3.77%)

2597 existing lines in 15 files now uncovered.

14093 of 44785 relevant lines covered (31.47%)

26791.82 hits per line

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

0.0
/ui/src/functionwizard.cpp
1
/*
2
  Q Light Controller
3
  functionwizard.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 <QMessageBox>
21
#include <QString>
22
#include <QDebug>
23
#include <QHash>
24
#include <QAction>
25
#include <QSettings>
26

27
#include "palettegenerator.h"
28
#include "fixtureselection.h"
29
#include "functionwizard.h"
30
#include "virtualconsole.h"
31
#include "vcsoloframe.h"
32
#include "vccuelist.h"
33
#include "rgbmatrix.h"
34
#include "efx.h"
35
#include "vcwidget.h"
36
#include "vcbutton.h"
37
#include "vcslider.h"
38
#include "vcxypad.h"
39
#include "vcframe.h"
40
#include "fixture.h"
41
#include "chaser.h"
42
#include "scene.h"
43
#include "doc.h"
44

45
#include "qlcfixturedef.h"
46
#include "qlcfixturehead.h"
47
#include "qlccapability.h"
48
#include "qlcchannel.h"
49
#include "vcframepageshortcut.h"
50

51
#define KFixtureColumnName          0
52
#define KFixtureColumnCaps          1
53
#define KFixtureColumnManufacturer  2
54
#define KFixtureColumnModel         3
55

56
#define KFunctionName               0
57
#define KFunctionOddEven            1
58

59
#define KWidgetName                 0
60

61
#define SETTINGS_GEOMETRY "functionwizard/geometry"
62

UNCOV
63
FunctionWizard::FunctionWizard(QWidget* parent, Doc* doc)
×
64
    : QDialog(parent)
65
    , m_doc(doc)
×
66
{
67
    Q_ASSERT(doc != NULL);
68
    setupUi(this);
×
69

UNCOV
70
    QString trbgSS = "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 0), stop:1 rgba(255, 255, 255, 0));";
×
71
    m_wizardLogo->setStyleSheet(trbgSS);
×
72
    m_introText->setStyleSheet(trbgSS);
×
73

74
    QAction* action = new QAction(this);
×
UNCOV
75
    action->setShortcut(QKeySequence(QKeySequence::Close));
×
76
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
×
UNCOV
77
    addAction(action);
×
78

79
    m_fixtureTree->sortItems(KFixtureColumnName, Qt::AscendingOrder);
×
80

81
    QSettings settings;
×
UNCOV
82
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
×
83
    if (geometrySettings.isValid() == true)
×
UNCOV
84
        restoreGeometry(geometrySettings.toByteArray());
×
85

86
    connect(m_nextButton, SIGNAL(clicked()),
×
87
            this, SLOT(slotNextPageClicked()));
88

89
    connect(m_tabWidget, SIGNAL(currentChanged(int)),
×
90
            this, SLOT(slotTabClicked()));
91

92
    checkTabsAndButtons();
×
UNCOV
93
}
×
94

95
FunctionWizard::~FunctionWizard()
×
96
{
97
    QSettings settings;
×
98
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
99

100
    m_paletteList.clear();
×
UNCOV
101
}
×
102

103
void FunctionWizard::slotNextPageClicked()
×
104
{
UNCOV
105
    int newIdx = m_tabWidget->currentIndex() + 1;
×
106
    if (newIdx == 4)
×
107
        return;
108

UNCOV
109
    m_tabWidget->setCurrentIndex(newIdx);
×
110
    checkTabsAndButtons();
×
111
}
112

113
void FunctionWizard::slotTabClicked()
×
114
{
115
    checkTabsAndButtons();
×
UNCOV
116
}
×
117

118
void FunctionWizard::accept()
×
119
{
120

121
    foreach (PaletteGenerator *palette, m_paletteList)
×
UNCOV
122
        palette->addToDoc();
×
123

UNCOV
124
    addWidgetsToVirtualConsole();
×
125

126
    m_doc->setModified();
×
127

128
    QDialog::accept();
×
UNCOV
129
}
×
130

UNCOV
131
void FunctionWizard::checkTabsAndButtons()
×
132
{
UNCOV
133
    switch(m_tabWidget->currentIndex())
×
134
    {
135
        case 0:
×
136
        {
UNCOV
137
            m_nextButton->setEnabled(true);
×
138
            m_tabWidget->setTabEnabled(2, false);
×
139
            m_tabWidget->setTabEnabled(3, false);
×
140
        }
141
        break;
×
UNCOV
142
        case 1:
×
143
        {
144
            if (m_allFuncsTree->topLevelItemCount() == 0)
×
145
            {
UNCOV
146
                m_nextButton->setEnabled(false);
×
UNCOV
147
                m_tabWidget->setTabEnabled(2, false);
×
148
            }
149
            else
150
            {
UNCOV
151
                m_nextButton->setEnabled(true);
×
UNCOV
152
                m_tabWidget->setTabEnabled(2, true);
×
153
            }
154
        }
155
        break;
UNCOV
156
        case 2:
×
157
        {
158
            m_nextButton->setEnabled(m_widgetsTree->topLevelItemCount() > 0);            
×
159
        }
UNCOV
160
        break;
×
UNCOV
161
        case 3:
×
162
            m_nextButton->setEnabled(false);
×
163
        break;
×
164
    }
165

166
    // enable VC Widget Page if tree not empty
167
    m_tabWidget->setTabEnabled(3, m_widgetsTree->topLevelItemCount() > 0);
×
168
}
×
169

170
/****************************************************************************
171
 * Fixtures
172
 ****************************************************************************/
173

UNCOV
174
QTreeWidgetItem *FunctionWizard::getFixtureGroupItem(QString manufacturer, QString model)
×
175
{
UNCOV
176
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
177
    {
UNCOV
178
        QTreeWidgetItem *item = m_fixtureTree->topLevelItem(i);
×
179
        if (item->text(KFixtureColumnManufacturer) == manufacturer &&
×
UNCOV
180
            item->text(KFixtureColumnModel) == model)
×
181
                return item;
×
182
    }
183
    // if we're here then the group doesn't exist. Create it
184
    QTreeWidgetItem* newGrp = new QTreeWidgetItem(m_fixtureTree);
×
UNCOV
185
    newGrp->setText(KFixtureColumnName, tr("%1 group").arg(model));
×
UNCOV
186
    newGrp->setIcon(KFixtureColumnName, QIcon(":/group.png"));
×
187
    newGrp->setText(KFixtureColumnManufacturer, manufacturer);
×
188
    newGrp->setText(KFixtureColumnModel, model);
×
189
    newGrp->setExpanded(true);
×
190
    return newGrp;
×
191
}
192

193
void FunctionWizard::addFixture(quint32 fxi_id)
×
194
{
UNCOV
195
    Fixture* fxi = m_doc->fixture(fxi_id);
×
196
    Q_ASSERT(fxi != NULL);
197

198
    QStringList caps = PaletteGenerator::getCapabilities(fxi);
×
199

UNCOV
200
    if (caps.join(", ").isEmpty())
×
201
    {
UNCOV
202
        QMessageBox::warning(this, tr("Error"), tr("%1 has no capability supported by this wizard.").arg(fxi->name()));
×
203
        return;
204
    }
205
    else
206
    {
UNCOV
207
        QTreeWidgetItem *groupItem = getFixtureGroupItem(fxi->fixtureDef()->manufacturer(), fxi->fixtureDef()->model());
×
208
        Q_ASSERT(groupItem != NULL);
209

210
        QTreeWidgetItem* item = new QTreeWidgetItem(groupItem);
×
UNCOV
211
        item->setText(KFixtureColumnName, fxi->name());
×
UNCOV
212
        item->setIcon(KFixtureColumnName, fxi->getIconFromType());
×
213
        item->setData(KFixtureColumnName, Qt::UserRole, fxi_id);
×
214
        item->setText(KFixtureColumnCaps, caps.join(", "));
×
215
    }
216
    m_fixtureTree->resizeColumnToContents(KFixtureColumnName);
×
217
}
218

219
void FunctionWizard::slotAddClicked()
×
220
{
UNCOV
221
    FixtureSelection fs(this, m_doc);
×
222
    fs.setMultiSelection(true);
×
UNCOV
223
    fs.setDisabledFixtures(fixtureIds());
×
224
    if (fs.exec() == QDialog::Accepted)
×
225
    {
226
        QListIterator <quint32> it(fs.selection());
×
227
        while (it.hasNext() == true)
×
UNCOV
228
            addFixture(it.next());
×
229

230
        if (m_fixtureTree->topLevelItemCount() > 0)
×
231
        {
UNCOV
232
            updateAvailableFunctionsTree();
×
233
            updateWidgetsTree();
×
234
        }
235
    }
236
    checkTabsAndButtons();
×
237
}
×
238

239
void FunctionWizard::slotRemoveClicked()
×
240
{
241
    QListIterator <QTreeWidgetItem*> it(m_fixtureTree->selectedItems());
×
242
    while (it.hasNext() == true)
×
243
        delete it.next();
×
244
    
245
    updateWidgetsTree();
×
246
    checkTabsAndButtons();
×
UNCOV
247
}
×
248

UNCOV
249
void FunctionWizard::slotPageCheckboxChanged()
×
250
{
251
    updateWidgetsTree();
×
UNCOV
252
}
×
253

UNCOV
254
QList <quint32> FunctionWizard::fixtureIds() const
×
255
{
256
    QList <quint32> list;
UNCOV
257
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
258
    {
UNCOV
259
        QTreeWidgetItem* item(m_fixtureTree->topLevelItem(i));
×
260
        Q_ASSERT(item != NULL);
261

UNCOV
262
        for (int j = 0; j < item->childCount(); j++)
×
263
        {
UNCOV
264
            QTreeWidgetItem *child = item->child(j);
×
265
            Q_ASSERT(child != NULL);
266

UNCOV
267
            list << child->data(KFixtureColumnName, Qt::UserRole).toInt();
×
268
        }
269
    }
270

UNCOV
271
    return list;
×
272
}
273

274
/********************************************************************
275
 * Functions
276
 ********************************************************************/
277

278
void FunctionWizard::addFunctionsGroup(QTreeWidgetItem *fxGrpItem, QTreeWidgetItem *grpItem,
×
279
                                       QString name, PaletteGenerator::PaletteType type)
280
{
281
    if (grpItem == NULL)
×
282
        return;
283

UNCOV
284
    QTreeWidgetItem *item = new QTreeWidgetItem(grpItem);
×
285
    item->setText(KFunctionName, name);
×
UNCOV
286
    item->setCheckState(KFunctionName, Qt::Unchecked);
×
UNCOV
287
    item->setData(KFunctionName, Qt::UserRole, type);
×
288

289
    if (fxGrpItem != NULL && fxGrpItem->childCount() > 1)
×
290
    {
291
        item->setCheckState(KFunctionOddEven, Qt::Unchecked);
×
292
    }
293
}
294

295
void FunctionWizard::updateAvailableFunctionsTree()
×
296
{
297
    disconnect(m_allFuncsTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
×
298
            this, SLOT(slotFunctionItemChanged(QTreeWidgetItem*,int)));
299

UNCOV
300
    m_allFuncsTree->clear();
×
UNCOV
301
    m_resFuncsTree->clear();
×
302

303
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
304
    {
305
        QTreeWidgetItem *fxGrpItem = m_fixtureTree->topLevelItem(i);
×
306
        Q_ASSERT(fxGrpItem != NULL);
307

308
        if (fxGrpItem->childCount() == 0)
×
UNCOV
309
            continue;
×
310

UNCOV
311
        QTreeWidgetItem *grpItem = new QTreeWidgetItem(m_allFuncsTree);
×
312
        grpItem->setText(KFunctionName, fxGrpItem->text(KFixtureColumnName));
×
313
        grpItem->setIcon(KFunctionName, fxGrpItem->icon(KFixtureColumnName));
×
314
        grpItem->setExpanded(true);
×
315

316
        // since groups contain fixture of the same type, get the first
317
        // child and create categories on its capabilities
UNCOV
318
        QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
319
        quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
UNCOV
320
        Fixture* fxi = m_doc->fixture(fxID);
×
321
        Q_ASSERT(fxi != NULL);
322

323
        QStringList caps = PaletteGenerator::getCapabilities(fxi);
×
324

UNCOV
325
        foreach (QString cap, caps)
×
326
        {
327
            if (cap == KQLCChannelRGB || cap == KQLCChannelCMY)
×
328
            {
329
                addFunctionsGroup(fxGrpItem, grpItem,
×
330
                                  PaletteGenerator::typetoString(PaletteGenerator::PrimaryColors),
×
331
                                  PaletteGenerator::PrimaryColors);
NEW
332
                addFunctionsGroup(fxGrpItem, grpItem,
×
NEW
333
                                  PaletteGenerator::typetoString(PaletteGenerator::SixteenColors),
×
334
                                  PaletteGenerator::SixteenColors);
NEW
335
                addFunctionsGroup(fxGrpItem, grpItem,
×
NEW
336
                                  PaletteGenerator::typetoString(PaletteGenerator::Animation),
×
337
                                  PaletteGenerator::Animation);
NEW
338
                addFunctionsGroup(fxGrpItem, grpItem,
×
NEW
339
                                  PaletteGenerator::typetoString(PaletteGenerator::Effect),
×
340
                                  PaletteGenerator::Effect);
341
            }
342
            else if (cap == QLCChannel::groupToString(QLCChannel::Pan))
×
343
            {
344
                addFunctionsGroup(fxGrpItem, grpItem,
×
UNCOV
345
                                  PaletteGenerator::typetoString(PaletteGenerator::Effect),
×
346
                                  PaletteGenerator::Effect);
347
            }
348
            else if (cap == QLCChannel::groupToString(QLCChannel::Gobo))
×
UNCOV
349
                addFunctionsGroup(fxGrpItem, grpItem,
×
350
                                  PaletteGenerator::typetoString(PaletteGenerator::Gobos),
×
351
                                  PaletteGenerator::Gobos);
352
            else if (cap == QLCChannel::groupToString(QLCChannel::Shutter))
×
UNCOV
353
                addFunctionsGroup(fxGrpItem, grpItem,
×
UNCOV
354
                                  PaletteGenerator::typetoString(PaletteGenerator::Shutter),
×
355
                                  PaletteGenerator::Shutter);
UNCOV
356
            else if (cap == QLCChannel::groupToString(QLCChannel::Colour))
×
357
                addFunctionsGroup(fxGrpItem, grpItem,
×
UNCOV
358
                                  PaletteGenerator::typetoString(PaletteGenerator::ColourMacro),
×
359
                                  PaletteGenerator::ColourMacro);
360
        }
361
    }
362

363
    m_allFuncsTree->resizeColumnToContents(KFunctionName);
×
364

365
    connect(m_allFuncsTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
×
366
            this, SLOT(slotFunctionItemChanged(QTreeWidgetItem*,int)));
367
}
×
368

369
QTreeWidgetItem *FunctionWizard::getFunctionGroupItem(const Function *func)
×
370
{
UNCOV
371
    for (int i = 0; i < m_resFuncsTree->topLevelItemCount(); i++)
×
372
    {
373
        QTreeWidgetItem *item = m_resFuncsTree->topLevelItem(i);
×
374
        int grpType = item->data(KFunctionName, Qt::UserRole).toInt();
×
375
        if (grpType == func->type())
×
376
            return item;
×
377
    }
378
    // if we're here then the group doesn't exist. Create it
UNCOV
379
    QTreeWidgetItem* newGrp = new QTreeWidgetItem(m_resFuncsTree);
×
UNCOV
380
    newGrp->setText(KFixtureColumnName, Function::typeToString(func->type()));
×
381
    newGrp->setIcon(KFixtureColumnName, func->getIcon());
×
UNCOV
382
    newGrp->setData(KFunctionName, Qt::UserRole, func->type());
×
383
    newGrp->setExpanded(true);
×
384
    return newGrp;
×
385
}
386

UNCOV
387
void FunctionWizard::updateResultFunctionsTree()
×
388
{
UNCOV
389
    m_resFuncsTree->clear();
×
UNCOV
390
    m_paletteList.clear();
×
391

392
    for (int i = 0; i < m_allFuncsTree->topLevelItemCount(); i++)
×
393
    {
UNCOV
394
        QTreeWidgetItem *funcGrpItem = m_allFuncsTree->topLevelItem(i);
×
395
        Q_ASSERT(funcGrpItem != NULL);
396

UNCOV
397
        if (funcGrpItem->childCount() == 0)
×
398
            continue;
×
399

400
        // retrieve the list of fixtures involved in this group
401
        QList <Fixture *> fxList;
×
402
        QTreeWidgetItem *fxiGrpItem = m_fixtureTree->topLevelItem(i);
×
403

404
        for (int f = 0; f < fxiGrpItem->childCount(); f++)
×
405
        {
UNCOV
406
            QTreeWidgetItem *fItem = fxiGrpItem->child(f);
×
UNCOV
407
            quint32 fxID = fItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
408
            Fixture *fixture = m_doc->fixture(fxID);
×
UNCOV
409
            if (fixture != NULL)
×
410
                fxList.append(fixture);
×
411
        }
412

413
        // iterate through the function group children to see which are checked
UNCOV
414
        for (int c = 0; c < funcGrpItem->childCount(); c++)
×
415
        {
UNCOV
416
            QTreeWidgetItem *funcItem = funcGrpItem->child(c);
×
UNCOV
417
            if (funcItem->checkState(KFunctionName) == Qt::Checked)
×
418
            {
419
                int type = funcItem->data(KFunctionName, Qt::UserRole).toInt();
×
420
                int subType = PaletteGenerator::All;
UNCOV
421
                if (funcItem->checkState(KFunctionOddEven) == Qt::Checked)
×
422
                    subType = PaletteGenerator::OddEven;
423
                PaletteGenerator *palette = new PaletteGenerator(m_doc, fxList,
424
                                                                 (PaletteGenerator::PaletteType)type,
425
                                                                 (PaletteGenerator::PaletteSubType)subType);
×
426
                m_paletteList.append(palette);
×
427

428
                foreach (Scene *scene, palette->scenes())
×
429
                {
430
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(scene));
×
431
                    item->setText(KFunctionName, scene->name());
×
432
                    item->setIcon(KFunctionName, scene->getIcon());
×
433
                }
434
                foreach (Chaser *chaser, palette->chasers())
×
435
                {
436
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(chaser));
×
437
                    item->setText(KFunctionName, chaser->name());
×
438
                    item->setIcon(KFunctionName, chaser->getIcon());
×
439
                }
NEW
440
                foreach (RGBMatrix *matrix, palette->matrices())
×
441
                {
NEW
442
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(matrix));
×
NEW
443
                    item->setText(KFunctionName, matrix->name());
×
NEW
444
                    item->setIcon(KFunctionName, matrix->getIcon());
×
445
                }
UNCOV
446
                foreach (EFX *effect, palette->effects())
×
447
                {
UNCOV
448
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(effect));
×
449
                    item->setText(KFunctionName, effect->name());
×
UNCOV
450
                    item->setIcon(KFunctionName, effect->getIcon());
×
451
                }
452
            }
453
        }
454
    }
UNCOV
455
}
×
456

UNCOV
457
void FunctionWizard::slotFunctionItemChanged(QTreeWidgetItem *item, int col)
×
458
{
459
    Q_UNUSED(col)
460
    Q_UNUSED(item)
461

462
    updateResultFunctionsTree();
×
UNCOV
463
    updateWidgetsTree();
×
464

UNCOV
465
    checkTabsAndButtons();
×
UNCOV
466
}
×
467

468
/********************************************************************
469
 * Widgets
470
 ********************************************************************/
471

472
void FunctionWizard::addWidgetItem(QTreeWidgetItem *grpItem, QString name, int type,
×
473
                             QTreeWidgetItem *fxGrpItem, quint32 *channels)
474
{
475
    if (grpItem == NULL)
×
476
        return;
477

478
    QTreeWidgetItem *item = new QTreeWidgetItem(grpItem);
×
479
    item->setText(KWidgetName, name );
×
UNCOV
480
    item->setCheckState(KWidgetName, Qt::Unchecked);
×
UNCOV
481
    item->setData(KWidgetName, Qt::UserRole, type);
×
UNCOV
482
    item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void*)fxGrpItem));
×
483
    item->setData(KWidgetName, Qt::UserRole + 2, QVariant::fromValue(channels[0]));
×
484
    item->setIcon(KWidgetName, VCWidget::typeToIcon(type));
×
UNCOV
485
    if(name.toLower().contains("speed")) item->setIcon(KWidgetName, QIcon(":/knob.png"));
×
486
    
487
}
488

UNCOV
489
void FunctionWizard::checkPanTilt(QTreeWidgetItem *grpItem,
×
490
                            QTreeWidgetItem *fxGrpItem, qint32* channels)
491
{
492
    //Check if all required Channels are set
493
    if (channels[0] < 0) return;
×
494
    if (channels[2] < 0) return;
×
495
    if (channels[1] > 0 && channels[3] < 0) return;
×
496
    
497
    quint32 panTiltChannels[4] = {};
×
498
    for (size_t i = 0; i < 4; i++)
×
UNCOV
499
        panTiltChannels[i] = channels[i];
×
500

UNCOV
501
    addWidgetItem(grpItem, "XY PAD", VCWidget::XYPadWidget, fxGrpItem, panTiltChannels);
×
502

503
    channels[0] = -1;
×
504
    channels[1] = -1;
×
UNCOV
505
    channels[2] = -1;
×
506
    channels[3] = -1;
×
507
}
508

509
void FunctionWizard::checkRGB(QTreeWidgetItem *grpItem, 
×
510
                            QTreeWidgetItem *fxGrpItem, qint32* channels)
511
{
512
    // Check if all required Channels are set
UNCOV
513
    for (size_t i = 0; i < 3; i++) if(channels[i] < 0) return;
×
514

515
    quint32 RGB[3] = {};
×
UNCOV
516
    for (size_t i = 0; i < 3; i++)
×
517
        RGB[i] = channels[i];
×
518

519
    addWidgetItem(grpItem, "RGB - Click & Go", VCWidget::SliderWidget, fxGrpItem, RGB);
×
520

521
    RGB[0] = -1;
522
    RGB[1] = -1;
523
    RGB[2] = -1;
524
}
525

526
void FunctionWizard::addChannelsToTree(QTreeWidgetItem *frame, QTreeWidgetItem *fxGrpItem, QList<quint32> channels)
×
527
{
UNCOV
528
    QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
529
    quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
530
    Fixture *fxi = m_doc->fixture(fxID);
×
531
    Q_ASSERT(fxi != NULL);
532

533
    qint32 lastPanTilt[] = {-1, -1, -1, -1};
×
534
    qint32 lastRGB[] = {-1, -1, -1};
×
535

536
    
537
    for (auto &&ch : channels)
×
538
    //for (quint32 ch = 0; ch < fxi->channels(); ch++)
539
    {
NEW
540
        const QLCChannel *channel(fxi->channel(ch));
×
541
        Q_ASSERT(channel != NULL);
542

NEW
543
        switch (channel->group())
×
544
        {
NEW
545
        case QLCChannel::Pan: {
×
NEW
546
            if (channel->preset() == QLCChannel::PositionPan)
×
NEW
547
                lastPanTilt[0] = ch;
×
NEW
548
            if (channel->preset() == QLCChannel::PositionPanFine)
×
NEW
549
                lastPanTilt[1] = ch;
×
550

NEW
551
            checkPanTilt(frame, fxGrpItem, lastPanTilt);
×
552
        }
553
        break;
554
        case QLCChannel::Tilt: {
×
555
            if (channel->preset() == QLCChannel::PositionTilt)
×
UNCOV
556
                lastPanTilt[2] = ch;
×
557
            if (channel->preset() == QLCChannel::PositionTiltFine)
×
558
                lastPanTilt[3] = ch;
×
559

UNCOV
560
            checkPanTilt(frame, fxGrpItem, lastPanTilt);
×
561
        }
562
        break;
563

564
        // Glick & Go's
565
        case QLCChannel::Gobo:
×
566
        case QLCChannel::Shutter:
567
        case QLCChannel::Prism:
568
        case QLCChannel::Beam:
569
        case QLCChannel::Effect:
570
        case QLCChannel::Colour:
571
            addWidgetItem(frame, QLCChannel::groupToString(channel->group()) + " - Click & Go",
×
572
                          VCWidget::SliderWidget, fxGrpItem, &ch);
UNCOV
573
            break;
×
574

UNCOV
575
        case QLCChannel::Intensity: {
×
576
            QLCChannel::PrimaryColour col = channel->colour();
×
577
            switch (col)
578
            {
579
            case QLCChannel::Red: {
×
UNCOV
580
                lastRGB[0] = ch;
×
UNCOV
581
                checkRGB(frame, fxGrpItem, lastRGB);
×
582
            }
583
            break;
UNCOV
584
            case QLCChannel::Green: {
×
585
                lastRGB[1] = ch;
×
UNCOV
586
                checkRGB(frame, fxGrpItem, lastRGB);
×
587
            }
588
            break;
589
            case QLCChannel::Blue: {
×
590
                lastRGB[2] = ch;
×
591
                checkRGB(frame, fxGrpItem, lastRGB);
×
592
            }
593
            break;
594
            default: {
×
595
                addWidgetItem(frame, channel->name() + " - Intensity", VCWidget::SliderWidget,
×
596
                              fxGrpItem, &ch);
597
            }
598
            break;
×
599
            }
600
        }
601
        break;
602
        case QLCChannel::Speed:
×
603
            addWidgetItem(frame,
×
UNCOV
604
                          channel->name() + " - " + QLCChannel::groupToString(channel->group()),
×
605
                          VCWidget::SliderWidget, fxGrpItem, &ch);
606
            break;
×
607
            break;
608
        default:
×
609
            addWidgetItem(frame,
×
UNCOV
610
                          channel->name() + " - " + QLCChannel::groupToString(channel->group()),
×
611
                          VCWidget::SliderWidget, fxGrpItem, &ch);
UNCOV
612
            break;
×
613
            break;
614
        }
615
    }
616
}
×
617

618
void FunctionWizard::updateWidgetsTree()
×
619
{
620
    m_widgetsTree->clear();
×
621

622
    // Populate palette Widgets
UNCOV
623
    foreach (PaletteGenerator *palette, m_paletteList)
×
624
    {
UNCOV
625
        QTreeWidgetItem *frame = new QTreeWidgetItem(m_widgetsTree);
×
626
        frame->setText(KWidgetName, palette->fullName());
×
627
        if (palette->type() == PaletteGenerator::Animation)
×
628
        {
629
            frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SoloFrameWidget));
×
UNCOV
630
            frame->setData(KWidgetName, Qt::UserRole, VCWidget::SoloFrameWidget);
×
631
        }
632
        else
633
        {
UNCOV
634
            frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
635
            frame->setData(KWidgetName, Qt::UserRole, VCWidget::FrameWidget);
×
636
        }
637
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)palette));
×
UNCOV
638
        frame->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
639
        frame->setCheckState(KWidgetName, Qt::Unchecked);
×
640

641
        QTreeWidgetItem *soloFrameItem = NULL;
UNCOV
642
        if (palette->scenes().count() > 0)
×
643
        {
UNCOV
644
            soloFrameItem = new QTreeWidgetItem(frame);
×
UNCOV
645
            soloFrameItem->setText(KWidgetName, tr("Presets solo frame"));
×
UNCOV
646
            soloFrameItem->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SoloFrameWidget));
×
UNCOV
647
            soloFrameItem->setFlags(soloFrameItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
UNCOV
648
            soloFrameItem->setCheckState(KWidgetName, Qt::Unchecked);
×
649
            soloFrameItem->setData(KWidgetName, Qt::UserRole, VCWidget::SoloFrameWidget);
×
650
        }
651
        foreach (Scene *scene, palette->scenes())
×
652
        {
653
            QTreeWidgetItem *item = NULL;
UNCOV
654
            if (soloFrameItem != NULL)
×
655
                item = new QTreeWidgetItem(soloFrameItem);
×
656
            else
657
                item = new QTreeWidgetItem(frame);
×
UNCOV
658
            QString toRemove = " - " + palette->model();
×
659
            item->setText(KWidgetName, scene->name().remove(toRemove));
×
660
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
661
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
UNCOV
662
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
663
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)scene));
×
664

665
        }
UNCOV
666
        foreach (Chaser *chaser, palette->chasers())
×
667
        {
668
            QTreeWidgetItem *item = new QTreeWidgetItem(frame);
×
669
            QString toRemove = " - " + palette->model();
×
UNCOV
670
            item->setText(KWidgetName, chaser->name().remove(toRemove));
×
671
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::CueListWidget));
×
672
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
UNCOV
673
            item->setData(KWidgetName, Qt::UserRole, VCWidget::CueListWidget);
×
674
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)chaser));
×
675
        }
676

677
        foreach (RGBMatrix *matrix, palette->matrices())
×
678
        {
679
            QTreeWidgetItem *item = NULL;
UNCOV
680
            if (soloFrameItem != NULL)
×
UNCOV
681
                item = new QTreeWidgetItem(soloFrameItem);
×
682
            else
UNCOV
683
                item = new QTreeWidgetItem(frame);
×
UNCOV
684
            QString toRemove = " - " + palette->model();
×
UNCOV
685
            item->setText(KWidgetName, matrix->name().remove(toRemove));
×
UNCOV
686
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
UNCOV
687
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
UNCOV
688
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
689
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)matrix));
×
690
        }
UNCOV
691
        foreach (EFX *effect, palette->effects())
×
692
        {
693
            QTreeWidgetItem *item = NULL;
694
            if (soloFrameItem != NULL)
×
UNCOV
695
                item = new QTreeWidgetItem(soloFrameItem);
×
696
            else
UNCOV
697
                item = new QTreeWidgetItem(frame);
×
698
            QString toRemove = " - " + palette->model();
×
699
            item->setText(KWidgetName, effect->name().remove(toRemove));
×
UNCOV
700
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
701
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
702
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
UNCOV
703
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)effect));
×
704
        }
705

UNCOV
706
        if (palette->scenes().count() > 0)
×
707
        {
UNCOV
708
            int pType = palette->type();
×
709
            QTreeWidgetItem *item = new QTreeWidgetItem(frame);
×
UNCOV
710
            if (pType == PaletteGenerator::PrimaryColors ||
×
711
                pType == PaletteGenerator::SixteenColors)
UNCOV
712
                    item->setText(KWidgetName, tr("Click & Go RGB"));
×
713
            else if (pType == PaletteGenerator::Gobos ||
×
UNCOV
714
                     pType == PaletteGenerator::Shutter ||
×
715
                     pType == PaletteGenerator::ColourMacro)
UNCOV
716
                        item->setText(KWidgetName, tr("Click & Go Macro"));
×
717

UNCOV
718
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SliderWidget));
×
719
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
720
            item->setData(KWidgetName, Qt::UserRole, VCWidget::SliderWidget);
×
721
            Scene *firstScene = palette->scenes().at(0);
×
722
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)firstScene));
×
723
        }
724
    }
725

726
    // Populate Fixture channel Widgets
UNCOV
727
    if (m_checkBoxAll->checkState() == 0 && m_checkBoxHeads->checkState() == 0 &&
×
728
        m_checkBoxFixtures->checkState() == 0)
×
729
        return;
730

731
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
732
    {
UNCOV
733
        QTreeWidgetItem *fxGrpItem = m_fixtureTree->topLevelItem(i);
×
734
        Q_ASSERT(fxGrpItem != NULL);
735

736
        if (fxGrpItem->childCount() == 0)
×
UNCOV
737
            continue;
×
738

UNCOV
739
        QTreeWidgetItem *frame = new QTreeWidgetItem(m_widgetsTree);
×
UNCOV
740
        frame->setText(KWidgetName, "Channels - " + fxGrpItem->text(KFixtureColumnName));
×
741
        frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
UNCOV
742
        frame->setData(KWidgetName, Qt::UserRole, VCWidget::FrameWidget);
×
UNCOV
743
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)NULL));
×
UNCOV
744
        frame->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
UNCOV
745
        frame->setCheckState(KWidgetName, Qt::Unchecked);
×
746
        frame->setExpanded(true);
×
747

748
        // since groups contain fixture of the same type, get the first
749
        // child and create categories on its capabilities
750
        QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
UNCOV
751
        quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
752
        Fixture* fxi = m_doc->fixture(fxID);
×
753
        Q_ASSERT(fxi != NULL);
754

755
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)fxi));
×
756

757
        quint8 fixtureCount = fxGrpItem->childCount();
×
758
        quint8 headCount = fxi->heads();
×
759

760
        QList<quint32> headChannels = fxi->head(0).channels();
×
UNCOV
761
        QList<quint32> noHeadChannels;
×
762
        for (size_t i = 0; i < fxi->channels(); i++)
×
763
        {
764
            noHeadChannels.append(i);
×
765
        }
766
        for (int h = 0; h < fxi->heads(); h++)
×
767
        {
768
            for (auto &&ch : fxi->head(h).channels())
×
769
            {
770
                noHeadChannels.removeAll(ch);
×
771
            }
772
        }
773

774
        QList<quint32> allChannels = headChannels;
×
775
        allChannels.append(noHeadChannels);
776

777
        quint16 pageCount = 0;
UNCOV
778
        QString pageName = "%1 Pages - ";
×
779

UNCOV
780
        if (m_checkBoxFixtures->checkState())
×
781
        {
UNCOV
782
            pageName.append("[F]");
×
UNCOV
783
            pageCount = fixtureCount;
×
784
        }
785
        else
786
            fixtureCount = 0;
UNCOV
787
        if (headCount > 1 && m_checkBoxHeads->checkState() == 2)
×
788
        {
UNCOV
789
            if (pageCount > 0)
×
790
            {
UNCOV
791
                pageCount *= headCount;
×
UNCOV
792
                pageName.append("/");
×
793
            }
794
            else
UNCOV
795
                pageCount = headCount;
×
UNCOV
796
            pageName.append("[H]");
×
797
        }
798
        else
799
            headCount = 0;
800

UNCOV
801
        if (pageCount < 2)
×
802
        {
803
            // No Pages
UNCOV
804
            addChannelsToTree(frame, fxGrpItem, allChannels);
×
UNCOV
805
            continue;
×
806
        }
807

UNCOV
808
        if (m_checkBoxAll->checkState() == 2)
×
809
        {
UNCOV
810
            QTreeWidgetItem *page = new QTreeWidgetItem(frame);
×
UNCOV
811
            page->setText(KWidgetName, "Page - All");
×
UNCOV
812
            page->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
UNCOV
813
            page->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
UNCOV
814
            page->setCheckState(KWidgetName, Qt::Unchecked);
×
UNCOV
815
            page->setExpanded(true);
×
816

UNCOV
817
            addChannelsToTree(page, fxGrpItem, allChannels);
×
818
        }
819

UNCOV
820
        pageName = pageName.arg(pageCount);
×
821

UNCOV
822
        QTreeWidgetItem *page = new QTreeWidgetItem(frame);
×
UNCOV
823
        page->setText(KWidgetName, pageName);
×
UNCOV
824
        page->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
UNCOV
825
        page->setData(KWidgetName, Qt::UserRole + 1, fixtureCount); // FixturePageCount
×
UNCOV
826
        page->setData(KWidgetName, Qt::UserRole + 2, headCount);    // HeadPageCount
×
UNCOV
827
        page->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
UNCOV
828
        page->setCheckState(KWidgetName, Qt::Unchecked);
×
UNCOV
829
        page->setExpanded(true);
×
830

UNCOV
831
        addChannelsToTree(page, fxGrpItem,
×
UNCOV
832
                          (headCount > 1 && m_checkBoxHeads->checkState() == 2) ? headChannels
×
833
                                                                                : allChannels);
834
    }
835
}
836

UNCOV
837
VCWidget *FunctionWizard::createWidget(int type, VCWidget *parent, int xpos, int ypos,
×
838
                                       Function *func, int pType, QTreeWidgetItem *fxGrpItem,
839
                                       quint32 chan, qint32 fixtureNr, qint32 headId)
840
{
UNCOV
841
    VirtualConsole *vc = VirtualConsole::instance();
×
842
    VCWidget *widget = NULL;
843

UNCOV
844
    if (parent == NULL)
×
845
        return NULL;
846

UNCOV
847
    switch(type)
×
848
    {
UNCOV
849
        case VCWidget::FrameWidget:
×
850
        {
UNCOV
851
            VCFrame* frame = new VCFrame(parent, m_doc, true);
×
UNCOV
852
            vc->setupWidget(frame, parent);
×
UNCOV
853
            frame->move(QPoint(xpos, ypos));
×
854
            widget = frame;
855
        }
UNCOV
856
        break;
×
UNCOV
857
        case VCWidget::SoloFrameWidget:
×
858
        {
UNCOV
859
            VCSoloFrame* frame = new VCSoloFrame(parent, m_doc, true);
×
UNCOV
860
            vc->setupWidget(frame, parent);
×
UNCOV
861
            frame->move(QPoint(xpos, ypos));
×
862
            widget = frame;
863
        }
UNCOV
864
        break;
×
UNCOV
865
        case VCWidget::ButtonWidget:
×
866
        {
UNCOV
867
            VCButton* button = new VCButton(parent, m_doc);
×
UNCOV
868
            vc->setupWidget(button, parent);
×
UNCOV
869
            button->move(QPoint(xpos, ypos));
×
UNCOV
870
            if (func != NULL)
×
UNCOV
871
                button->setFunction(func->id());
×
872

873
            widget = button;
874
        }
875
        break;
UNCOV
876
        case VCWidget::CueListWidget:
×
877
        {
UNCOV
878
            VCCueList* cuelist = new VCCueList(parent, m_doc);
×
UNCOV
879
            vc->setupWidget(cuelist, parent);
×
UNCOV
880
            cuelist->move(QPoint(xpos, ypos));
×
UNCOV
881
            if (func != NULL)
×
UNCOV
882
                cuelist->setChaser(func->id());
×
UNCOV
883
            cuelist->resize(QSize(300, m_sliderHeightSpin->value()));
×
884

885
            widget = cuelist;
886
        }
UNCOV
887
        break;
×
UNCOV
888
        case VCWidget::SliderWidget:
×
889
        {
UNCOV
890
            VCSlider* slider = new VCSlider(parent, m_doc);
×
UNCOV
891
            vc->setupWidget(slider, parent);
×
UNCOV
892
            slider->move(QPoint(xpos, ypos));
×
893
            // Click & Go Slider in Pallette Frames
UNCOV
894
            if (func != NULL)
×
895
            {
896
                Scene *scene = qobject_cast<Scene*> (func);
UNCOV
897
                foreach (SceneValue scv, scene->values())
×
UNCOV
898
                    slider->addLevelChannel(scv.fxi, scv.channel);
×
899

UNCOV
900
                if (pType == PaletteGenerator::PrimaryColors ||
×
901
                    pType == PaletteGenerator::SixteenColors)
UNCOV
902
                        slider->setClickAndGoType(ClickAndGoWidget::RGB);
×
903
                else
UNCOV
904
                    slider->setClickAndGoType(ClickAndGoWidget::Preset);
×
UNCOV
905
                slider->setSliderMode(VCSlider::Level);
×
906
            }
907
            else
908
            {
909
                // get channel of first Fixture
UNCOV
910
                int fxID = fxGrpItem->child(0)->data(KFixtureColumnName, Qt::UserRole).toInt();
×
UNCOV
911
                Fixture *fixture = m_doc->fixture(fxID);
×
UNCOV
912
                const QLCChannel *channel = fixture->channel(chan);
×
913

UNCOV
914
                bool isRGB = channel->colour()==QLCChannel::Red;
×
915

UNCOV
916
                for (int c = 0; c < fxGrpItem->childCount(); c++)
×
917
                {
UNCOV
918
                    if (fixtureNr >= 0 && c != fixtureNr)
×
UNCOV
919
                        continue;
×
920

UNCOV
921
                    QTreeWidgetItem *fxItem = fxGrpItem->child(c);
×
UNCOV
922
                    int fxi = fxItem->data(KFixtureColumnName, Qt::UserRole).toInt();
×
UNCOV
923
                    Fixture *fixture = m_doc->fixture(fxID);
×
UNCOV
924
                    qint16 chanIndex = fixture->head(0).channels().indexOf(chan);
×
UNCOV
925
                    for (qint32 h = 0; h < fixture->heads(); h++)
×
926
                    {
UNCOV
927
                        if (headId >= 0 && h != headId)
×
UNCOV
928
                            continue;
×
929

930
                        quint32 headChannel = chan;
UNCOV
931
                        if (chanIndex >= 0) // check if channel is in head
×
UNCOV
932
                            headChannel = fixture->head(h).channels().at(chanIndex);
×
933

UNCOV
934
                        slider->addLevelChannel(fxi, headChannel);
×
UNCOV
935
                        if (isRGB)
×
936
                        {
UNCOV
937
                            slider->addLevelChannel(fxi, headChannel + 1);
×
UNCOV
938
                            slider->addLevelChannel(fxi, headChannel + 2);
×
939
                        }
940
                    }
941
                }
942
                
UNCOV
943
                if (isRGB)
×
944
                {
UNCOV
945
                    slider->setClickAndGoType(ClickAndGoWidget::RGB);
×
946
                }
UNCOV
947
                else if (channel->group() == QLCChannel::Intensity)
×
948
                {
UNCOV
949
                    slider->setClickAndGoType(ClickAndGoWidget::None);
×
950
                }
951
                else
952
                {
UNCOV
953
                    slider->setClickAndGoType(ClickAndGoWidget::Preset);
×
954
                }
955
                
UNCOV
956
                if (channel->group() == QLCChannel::Speed)
×
UNCOV
957
                    slider->setWidgetStyle(VCSlider::WKnob);
×
958

UNCOV
959
                if ((fixtureNr >= 0 || headId >= 0) && m_checkBoxAll->checkState() == Qt::Checked)
×
UNCOV
960
                    slider->setChannelsMonitorEnabled(true);
×
961

UNCOV
962
                slider->setSliderMode(VCSlider::Level); 
×
963
            }
964

UNCOV
965
            slider->resize(QSize(m_sliderWidthSpin->value(), m_sliderHeightSpin->value()));
×
966

967
            widget = slider;
968
        }
UNCOV
969
        break;
×
UNCOV
970
        case VCWidget::XYPadWidget:
×
971
        {
UNCOV
972
            VCXYPad* XYPad = new VCXYPad(parent, m_doc);
×
UNCOV
973
            vc->setupWidget(XYPad, parent);
×
UNCOV
974
            XYPad->move(QPoint(xpos, ypos));
×
975

UNCOV
976
            for (int c = 0; c < fxGrpItem->childCount(); c++)
×
977
            {
UNCOV
978
                if (fixtureNr >= 0 && c != fixtureNr)
×
UNCOV
979
                    continue;
×
980

UNCOV
981
                QTreeWidgetItem *fxItem = fxGrpItem->child(c);
×
UNCOV
982
                int fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toInt();
×
UNCOV
983
                Fixture *fixture = m_doc->fixture(fxID);
×
UNCOV
984
                for (qint32 h = 0; h < fixture->heads(); h++)
×
985
                {
UNCOV
986
                    if (headId >= 0 && h != headId)
×
UNCOV
987
                        continue;
×
988

UNCOV
989
                    VCXYPadFixture fxi = VCXYPadFixture(m_doc);
×
UNCOV
990
                    fxi.setHead(GroupHead(fxID, h));
×
UNCOV
991
                    XYPad->appendFixture(fxi);
×
992
                }
993
            }
UNCOV
994
            XYPad->resize(QSize(m_sliderHeightSpin->value(), m_sliderHeightSpin->value()));
×
995
                      
996
            widget = XYPad;
997
        }
UNCOV
998
        break;
×
999
        default:
1000
        break;
1001
    }
1002

1003
    // Set Function
UNCOV
1004
    if (widget != NULL && func != NULL)
×
1005
    {
UNCOV
1006
        if (func->type() == Function::SceneType && type == VCWidget::ButtonWidget)
×
1007
        {
1008
            Scene *scene = qobject_cast<Scene*> (func);
1009

UNCOV
1010
            if (pType == PaletteGenerator::PrimaryColors ||
×
UNCOV
1011
                pType == PaletteGenerator::SixteenColors ||
×
UNCOV
1012
                pType == PaletteGenerator::ColourMacro)
×
1013
            {
UNCOV
1014
                QColor col = scene->colorValue();
×
UNCOV
1015
                if (col.isValid())
×
UNCOV
1016
                    widget->setBackgroundColor(col);
×
1017
            }
UNCOV
1018
            else if (pType == PaletteGenerator::Gobos)
×
1019
            {
UNCOV
1020
                foreach (SceneValue scv, scene->values())
×
1021
                {
UNCOV
1022
                    Fixture *fixture = m_doc->fixture(scv.fxi);
×
UNCOV
1023
                    if (fixture == NULL)
×
UNCOV
1024
                        continue;
×
1025

UNCOV
1026
                    const QLCChannel* channel(fixture->channel(scv.channel));
×
UNCOV
1027
                    if (channel->group() == QLCChannel::Gobo)
×
1028
                    {
UNCOV
1029
                        QLCCapability *cap = channel->searchCapability(scv.value);
×
UNCOV
1030
                        if (cap->resource(0).isValid())
×
1031
                        {
UNCOV
1032
                            widget->setBackgroundImage(cap->resource(0).toString());
×
UNCOV
1033
                            break;
×
1034
                        }
1035
                    }
1036
                }
1037
            }
1038
        }
1039
    }
1040

1041
    return widget;
1042
}
1043

UNCOV
1044
QSize FunctionWizard::recursiveCreateWidget(QTreeWidgetItem *item, VCWidget *parent, int type)
×
1045
{
UNCOV
1046
    QSize groupSize(100, 50);
×
1047
    int subX = 10, subY = 40;
1048

UNCOV
1049
    for (int c = 0; c < item->childCount(); c++)
×
1050
    {
UNCOV
1051
        QTreeWidgetItem *childItem = item->child(c);
×
1052

UNCOV
1053
        if (childItem->checkState(KWidgetName) == Qt::Checked ||
×
UNCOV
1054
            childItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1055
        {
UNCOV
1056
            int cType = childItem->data(KWidgetName, Qt::UserRole).toInt();
×
1057
            Function *func = NULL;
1058
            QTreeWidgetItem *fxGrpItem  = NULL;
1059
            quint32 channel = 0;
1060

UNCOV
1061
            if (type)
×
1062
            {
UNCOV
1063
                func = (Function *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1064
            }
1065
            else
1066
            {
UNCOV
1067
                fxGrpItem = (QTreeWidgetItem *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
UNCOV
1068
                channel = childItem->data(KWidgetName, Qt::UserRole + 2).toUInt();
×
1069
            }
1070

UNCOV
1071
            if (childItem->text(KWidgetName).contains("Page"))
×
1072
            {
1073
                VCFrame *frame = (VCFrame *)parent;
UNCOV
1074
                frame->setMultipageMode(true);
×
1075

UNCOV
1076
                if (childItem->childCount() > 0)
×
1077
                {
UNCOV
1078
                    if (childItem->text(KWidgetName).contains("All"))
×
1079
                    {
1080
                        // v page v
UNCOV
1081
                        childItem->setData(KWidgetName, Qt::UserRole + 1, -1); // all fixtures
×
UNCOV
1082
                        childItem->setData(KWidgetName, Qt::UserRole + 2, -1); // all heads
×
1083
                        
UNCOV
1084
                        groupSize = recursiveCreateWidget(childItem, parent, type);                         
×
1085
                        // v frame v
UNCOV
1086
                        childItem->parent()->setData(KWidgetName, Qt::UserRole + 3, groupSize);
×
UNCOV
1087
                        frame->shortcuts().at(frame->currentPage())->setName("All");
×
UNCOV
1088
                        frame->setTotalPagesNumber(frame->totalPagesNumber() + 1);
×
UNCOV
1089
                        frame->slotNextPage();
×
UNCOV
1090
                        continue;
×
1091
                    }
1092
                    else
1093
                    {
UNCOV
1094
                        qint32 fxPages = childItem->data(KWidgetName, Qt::UserRole + 1).toInt();
×
UNCOV
1095
                        qint32 headPages = childItem->data(KWidgetName, Qt::UserRole + 2).toInt();
×
UNCOV
1096
                        qint32 f = fxPages ? 0 : -1;
×
1097

UNCOV
1098
                        for (; f < fxPages; f++)
×
1099
                        {
UNCOV
1100
                            qint32 h = headPages ? 0 : -1;
×
UNCOV
1101
                            for (; h < headPages; h++)
×
1102
                            {
1103
                                // page
UNCOV
1104
                                childItem->setData(KWidgetName, Qt::UserRole + 1, f); // fixture
×
UNCOV
1105
                                childItem->setData(KWidgetName, Qt::UserRole + 2, h); // head
×
1106

UNCOV
1107
                                QSize size = recursiveCreateWidget(childItem, parent, type);
×
UNCOV
1108
                                groupSize = childItem->parent()
×
UNCOV
1109
                                                ->data(KWidgetName, Qt::UserRole + 3)
×
UNCOV
1110
                                                .toSize();
×
1111

UNCOV
1112
                                if (size.width() > groupSize.width())
×
1113
                                    groupSize.setWidth(size.width());
UNCOV
1114
                                if (size.height() > groupSize.height())
×
1115
                                    groupSize.setHeight(size.height());
1116

UNCOV
1117
                                QString pageName = "";
×
UNCOV
1118
                                if (f >= 0)
×
UNCOV
1119
                                    pageName.append(QString("F%1").arg(f));
×
1120

UNCOV
1121
                                if (h >= 0)
×
UNCOV
1122
                                    pageName.append(QString("%1H%2").arg((f >= 0) ? "/" : "").arg(h));
×
1123

UNCOV
1124
                                frame->shortcuts().at(frame->currentPage())->setName(pageName);
×
UNCOV
1125
                                frame->setTotalPagesNumber(frame->totalPagesNumber() + 1);
×
UNCOV
1126
                                frame->slotNextPage();
×
1127
                            }
1128
                        }
UNCOV
1129
                        frame->setTotalPagesNumber(frame->totalPagesNumber() - 1);
×
UNCOV
1130
                        frame->slotSetPage(0);
×
UNCOV
1131
                        frame->updatePageCombo();
×
1132
                    }
1133
                }
UNCOV
1134
                continue;
×
1135
            }
1136

1137
            qint32 fxNr = -1;
1138
            qint32 headId = -1;
UNCOV
1139
            if (childItem->parent()->text(KWidgetName).contains("Page"))
×
1140
            {
UNCOV
1141
                fxNr = childItem->parent()->data(KWidgetName, Qt::UserRole + 1).toInt();
×
UNCOV
1142
                headId = childItem->parent()->data(KWidgetName, Qt::UserRole + 2).toInt();
×
1143
            }
1144

UNCOV
1145
            VCWidget *childWidget = createWidget(cType, parent, subX, subY, func, type, fxGrpItem,
×
1146
                                                 channel, fxNr, headId);
UNCOV
1147
            if (childWidget != NULL)
×
1148
            {
UNCOV
1149
                if (childWidget->type() == VCWidget::SliderWidget)
×
UNCOV
1150
                    childWidget->setCaption(childItem->text(KWidgetName).split(" - ")[0]);
×
1151
                else
UNCOV
1152
                    childWidget->setCaption(childItem->text(KWidgetName));
×
1153

1154
                //qDebug() << childItem->text(KWidgetName);
1155
                //qDebug << "p:"<<parent->type() << " spin:" << m_lineCntSpin->value() << " per:" <<wPerLine << Qt::endl;
1156

UNCOV
1157
                if (childItem->childCount() > 0)
×
1158
                {
UNCOV
1159
                    childWidget->resize(QSize(2000, 1000));
×
UNCOV
1160
                    QSize size = recursiveCreateWidget(childItem, childWidget, type);
×
UNCOV
1161
                    childWidget->resize(size);
×
1162
                }
1163

UNCOV
1164
                if (subX + childWidget->width() > groupSize.width())
×
UNCOV
1165
                    groupSize.setWidth(subX + childWidget->width() + 10);
×
UNCOV
1166
                if (subY + childWidget->height() > groupSize.height())
×
UNCOV
1167
                    groupSize.setHeight(subY + childWidget->height() + 10);
×
1168

UNCOV
1169
                int wPerLine = parent->type() == VCWidget::SoloFrameWidget ? 4 : m_lineCntSpin->value();
×
UNCOV
1170
                if (c > 0 && (c + 1)%wPerLine == 0)
×
1171
                {
1172
                    subX = 10;
UNCOV
1173
                    subY += childWidget->height() + 10;
×
1174
                }
1175
                else
UNCOV
1176
                    subX += childWidget->width() + 10;
×
1177
            }
1178
        }
1179
    }
1180

UNCOV
1181
    return groupSize;
×
1182
}
1183

UNCOV
1184
void FunctionWizard::addWidgetsToVirtualConsole()
×
1185
{
1186
    int xPos = 10;
1187
    int yPos = 10;
1188

UNCOV
1189
    VirtualConsole *vc = VirtualConsole::instance();
×
UNCOV
1190
    VCFrame *mainFrame = vc->contents();
×
1191
    Q_ASSERT(mainFrame != NULL);
1192

UNCOV
1193
    for (int i = 0; i < m_widgetsTree->topLevelItemCount(); i++)
×
1194
    {
UNCOV
1195
        QTreeWidgetItem *wItem = m_widgetsTree->topLevelItem(i);
×
1196

UNCOV
1197
        if (wItem->checkState(KWidgetName) == Qt::Checked ||
×
UNCOV
1198
            wItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1199
        {
UNCOV
1200
            int wType = wItem->data(KWidgetName, Qt::UserRole).toInt();
×
UNCOV
1201
            VCWidget *widget = createWidget(wType, mainFrame, xPos, yPos);
×
UNCOV
1202
            if (widget == NULL)
×
UNCOV
1203
                continue;
×
1204

UNCOV
1205
            widget->resize(QSize(2000, 1000));
×
1206

1207
            int pType = 0;
UNCOV
1208
            if (!wItem->text(KWidgetName).contains("Channels"))
×
1209
            {
UNCOV
1210
                PaletteGenerator *pal = (PaletteGenerator *) wItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
UNCOV
1211
                pType = pal->type();
×
1212
            }
1213

UNCOV
1214
            widget->setCaption(wItem->text(KWidgetName));
×
1215

UNCOV
1216
            QSize size = recursiveCreateWidget(wItem, widget, pType);
×
1217

UNCOV
1218
            widget->resize(size);
×
UNCOV
1219
            xPos += widget->width() + 10;
×
1220
        }
1221
    }
UNCOV
1222
}
×
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