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

mcallegari / qlcplus / 12610410059

04 Jan 2025 12:23PM UTC coverage: 31.5% (-0.2%) from 31.664%
12610410059

push

github

web-flow
Merge pull request #1492 from 8-Lambda-8/master

Wizard for VC Widgets

5 of 259 new or added lines in 2 files covered. (1.93%)

12 existing lines in 1 file now uncovered.

14090 of 44730 relevant lines covered (31.5%)

26824.76 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 "vcwidget.h"
35
#include "vcbutton.h"
36
#include "vcslider.h"
37
#include "vcxypad.h"
38
#include "vcframe.h"
39
#include "fixture.h"
40
#include "chaser.h"
41
#include "scene.h"
42
#include "doc.h"
43

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

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

55
#define KFunctionName               0
56
#define KFunctionOddEven            1
57

58
#define KWidgetName                 0
59

60
#define SETTINGS_GEOMETRY "functionwizard/geometry"
61

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

69
    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));";
×
70
    m_wizardLogo->setStyleSheet(trbgSS);
×
71
    m_introText->setStyleSheet(trbgSS);
×
72

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

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

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

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

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

91
    checkTabsAndButtons();
×
92
}
×
93

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

99
    m_paletteList.clear();
×
100
}
×
101

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

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

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

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

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

123
    addWidgetsToVirtualConsole();
×
124

125
    m_doc->setModified();
×
126

127
    QDialog::accept();
×
128
}
×
129

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

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

169
/****************************************************************************
170
 * Fixtures
171
 ****************************************************************************/
172

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

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

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

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

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

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

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

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

NEW
248
void FunctionWizard::slotPageCheckboxChanged()
×
249
{
NEW
250
    updateWidgetsTree();
×
NEW
251
}
×
252

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

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

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

270
    return list;
×
271
}
272

273
/********************************************************************
274
 * Functions
275
 ********************************************************************/
276

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

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

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

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

299
    m_allFuncsTree->clear();
×
300
    m_resFuncsTree->clear();
×
301

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

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

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

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

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

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

353
    m_allFuncsTree->resizeColumnToContents(KFunctionName);
×
354

355
    connect(m_allFuncsTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
×
356
            this, SLOT(slotFunctionItemChanged(QTreeWidgetItem*,int)));
357
}
×
358

359
QTreeWidgetItem *FunctionWizard::getFunctionGroupItem(const Function *func)
×
360
{
361
    for (int i = 0; i < m_resFuncsTree->topLevelItemCount(); i++)
×
362
    {
363
        QTreeWidgetItem *item = m_resFuncsTree->topLevelItem(i);
×
364
        int grpType = item->data(KFunctionName, Qt::UserRole).toInt();
×
365
        if (grpType == func->type())
×
366
            return item;
×
367
    }
368
    // if we're here then the group doesn't exist. Create it
369
    QTreeWidgetItem* newGrp = new QTreeWidgetItem(m_resFuncsTree);
×
370
    newGrp->setText(KFixtureColumnName, Function::typeToString(func->type()));
×
371
    newGrp->setIcon(KFixtureColumnName, func->getIcon());
×
372
    newGrp->setData(KFunctionName, Qt::UserRole, func->type());
×
373
    newGrp->setExpanded(true);
×
374
    return newGrp;
×
375
}
376

377
void FunctionWizard::updateResultFunctionsTree()
×
378
{
379
    m_resFuncsTree->clear();
×
380
    m_paletteList.clear();
×
381

382
    for (int i = 0; i < m_allFuncsTree->topLevelItemCount(); i++)
×
383
    {
384
        QTreeWidgetItem *funcGrpItem = m_allFuncsTree->topLevelItem(i);
×
385
        Q_ASSERT(funcGrpItem != NULL);
386

387
        if (funcGrpItem->childCount() == 0)
×
388
            continue;
×
389

390
        // retrieve the list of fixtures involved in this group
391
        QList <Fixture *> fxList;
×
392
        QTreeWidgetItem *fxiGrpItem = m_fixtureTree->topLevelItem(i);
×
393

394
        for (int f = 0; f < fxiGrpItem->childCount(); f++)
×
395
        {
396
            QTreeWidgetItem *fItem = fxiGrpItem->child(f);
×
397
            quint32 fxID = fItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
398
            Fixture *fixture = m_doc->fixture(fxID);
×
399
            if (fixture != NULL)
×
400
                fxList.append(fixture);
×
401
        }
402

403
        // iterate through the function group children to see which are checked
404
        for (int c = 0; c < funcGrpItem->childCount(); c++)
×
405
        {
406
            QTreeWidgetItem *funcItem = funcGrpItem->child(c);
×
407
            if (funcItem->checkState(KFunctionName) == Qt::Checked)
×
408
            {
409
                int type = funcItem->data(KFunctionName, Qt::UserRole).toInt();
×
410
                int subType = PaletteGenerator::All;
411
                if (funcItem->checkState(KFunctionOddEven) == Qt::Checked)
×
412
                    subType = PaletteGenerator::OddEven;
413
                PaletteGenerator *palette = new PaletteGenerator(m_doc, fxList,
414
                                                                 (PaletteGenerator::PaletteType)type,
415
                                                                 (PaletteGenerator::PaletteSubType)subType);
×
416
                m_paletteList.append(palette);
×
417

418
                foreach (Scene *scene, palette->scenes())
×
419
                {
420
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(scene));
×
421
                    item->setText(KFunctionName, scene->name());
×
422
                    item->setIcon(KFunctionName, scene->getIcon());
×
423
                }
424
                foreach (Chaser *chaser, palette->chasers())
×
425
                {
426
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(chaser));
×
427
                    item->setText(KFunctionName, chaser->name());
×
428
                    item->setIcon(KFunctionName, chaser->getIcon());
×
429
                }
430
                foreach (RGBMatrix *matrix, palette->matrices())
×
431
                {
432
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(matrix));
×
433
                    item->setText(KFunctionName, matrix->name());
×
434
                    item->setIcon(KFunctionName, matrix->getIcon());
×
435
                }
436
            }
437
        }
438
    }
439
}
×
440

441
void FunctionWizard::slotFunctionItemChanged(QTreeWidgetItem *item, int col)
×
442
{
443
    Q_UNUSED(col)
444
    Q_UNUSED(item)
445

446
    updateResultFunctionsTree();
×
NEW
447
    updateWidgetsTree();
×
448

449
    checkTabsAndButtons();
×
450
}
×
451

452
/********************************************************************
453
 * Widgets
454
 ********************************************************************/
455

NEW
456
void FunctionWizard::addWidgetItem(QTreeWidgetItem *grpItem, QString name, int type,
×
457
                             QTreeWidgetItem *fxGrpItem, quint32 *channels)
458
{
NEW
459
    if (grpItem == NULL)
×
460
        return;
461

NEW
462
    QTreeWidgetItem *item = new QTreeWidgetItem(grpItem);
×
NEW
463
    item->setText(KWidgetName, name );
×
NEW
464
    item->setCheckState(KWidgetName, Qt::Unchecked);
×
NEW
465
    item->setData(KWidgetName, Qt::UserRole, type);
×
NEW
466
    item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void*)fxGrpItem));
×
NEW
467
    item->setData(KWidgetName, Qt::UserRole + 2, QVariant::fromValue(channels[0]));
×
NEW
468
    item->setIcon(KWidgetName, VCWidget::typeToIcon(type));
×
NEW
469
    if(name.toLower().contains("speed")) item->setIcon(KWidgetName, QIcon(":/knob.png"));
×
470
    
471
}
472

NEW
473
void FunctionWizard::checkPanTilt(QTreeWidgetItem *grpItem, 
×
474
                            QTreeWidgetItem *fxGrpItem, qint32* channels){
475
        
476
    //Check if all required Channels are set
NEW
477
    if(channels[0] < 0) return;
×
NEW
478
    if(channels[2] < 0) return;
×
NEW
479
    if(channels[1] > 0 && channels[3] < 0) return;
×
480
    
NEW
481
    quint32 PanTilt[4] = {};
×
NEW
482
    for (size_t i = 0; i < 4; i++) PanTilt[i] = channels[i];    
×
483

NEW
484
    addWidgetItem(grpItem, "XY PAD", VCWidget::XYPadWidget, fxGrpItem, PanTilt);
×
485

NEW
486
    channels[0] = -1;
×
NEW
487
    channels[1] = -1;
×
NEW
488
    channels[2] = -1;
×
NEW
489
    channels[3] = -1;
×
490

491
}
492

NEW
493
void FunctionWizard::checkRGB(QTreeWidgetItem *grpItem, 
×
494
                            QTreeWidgetItem *fxGrpItem, qint32* channels){
495
    
496
    //Check if all required Channels are set
NEW
497
    for (size_t i = 0; i < 3; i++) if(channels[i] < 0) return;
×
498

NEW
499
    quint32 RGB[3] = {};
×
NEW
500
    for (size_t i = 0; i < 3; i++) RGB[i] = channels[i];
×
501

NEW
502
    addWidgetItem(grpItem, "RGB - Click & Go", VCWidget::SliderWidget, fxGrpItem, RGB);
×
503

504
    RGB[0] = -1;
505
    RGB[1] = -1;
506
    RGB[2] = -1;
507

508
}
509

NEW
510
void FunctionWizard::addChannelsToTree(QTreeWidgetItem *frame, QTreeWidgetItem *fxGrpItem, QList<quint32> channels)
×
511
{
NEW
512
    QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
NEW
513
    quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
NEW
514
    Fixture *fxi = m_doc->fixture(fxID);
×
515
    Q_ASSERT(fxi != NULL);
516

NEW
517
    qint32 lastPanTilt[] = {-1, -1, -1, -1};
×
NEW
518
    qint32 lastRGB[] = {-1, -1, -1};
×
519

520
    
NEW
521
    for (auto &&ch : channels)
×
522
    //for (quint32 ch = 0; ch < fxi->channels(); ch++)
523
    {
NEW
524
        const QLCChannel *channel(fxi->channel(ch));
×
525
        Q_ASSERT(channel != NULL);
526

NEW
527
        switch (channel->group())
×
528
        {
NEW
529
        case QLCChannel::Pan: {
×
NEW
530
            if (channel->preset() == QLCChannel::PositionPan)
×
NEW
531
                lastPanTilt[0] = ch;
×
NEW
532
            if (channel->preset() == QLCChannel::PositionPanFine)
×
NEW
533
                lastPanTilt[1] = ch;
×
534

NEW
535
            checkPanTilt(frame, fxGrpItem, lastPanTilt);
×
536
        }
537
        break;
NEW
538
        case QLCChannel::Tilt: {
×
NEW
539
            if (channel->preset() == QLCChannel::PositionTilt)
×
NEW
540
                lastPanTilt[2] = ch;
×
NEW
541
            if (channel->preset() == QLCChannel::PositionTiltFine)
×
NEW
542
                lastPanTilt[3] = ch;
×
543

NEW
544
            checkPanTilt(frame, fxGrpItem, lastPanTilt);
×
545
        }
546
        break;
547

548
        // Glick & Go's
NEW
549
        case QLCChannel::Gobo:
×
550
        case QLCChannel::Shutter:
551
        case QLCChannel::Prism:
552
        case QLCChannel::Beam:
553
        case QLCChannel::Effect:
554
        case QLCChannel::Colour:
NEW
555
            addWidgetItem(frame, QLCChannel::groupToString(channel->group()) + " - Click & Go",
×
556
                          VCWidget::SliderWidget, fxGrpItem, &ch);
NEW
557
            break;
×
558

NEW
559
        case QLCChannel::Intensity: {
×
NEW
560
            QLCChannel::PrimaryColour col = channel->colour();
×
561
            switch (col)
562
            {
NEW
563
            case QLCChannel::Red: {
×
NEW
564
                lastRGB[0] = ch;
×
NEW
565
                checkRGB(frame, fxGrpItem, lastRGB);
×
566
            }
567
            break;
NEW
568
            case QLCChannel::Green: {
×
NEW
569
                lastRGB[1] = ch;
×
NEW
570
                checkRGB(frame, fxGrpItem, lastRGB);
×
571
            }
572
            break;
NEW
573
            case QLCChannel::Blue: {
×
NEW
574
                lastRGB[2] = ch;
×
NEW
575
                checkRGB(frame, fxGrpItem, lastRGB);
×
576
            }
577
            break;
NEW
578
            default: {
×
NEW
579
                addWidgetItem(frame, channel->name() + " - Intensity", VCWidget::SliderWidget,
×
580
                              fxGrpItem, &ch);
581
            }
NEW
582
            break;
×
583
            }
584
        }
585
        break;
NEW
586
        case QLCChannel::Speed:
×
NEW
587
            addWidgetItem(frame,
×
NEW
588
                          channel->name() + " - " + QLCChannel::groupToString(channel->group()),
×
589
                          VCWidget::SliderWidget, fxGrpItem, &ch);
NEW
590
            break;
×
591
            break;
NEW
592
        default:
×
NEW
593
            addWidgetItem(frame,
×
NEW
594
                          channel->name() + " - " + QLCChannel::groupToString(channel->group()),
×
595
                          VCWidget::SliderWidget, fxGrpItem, &ch);
NEW
596
            break;
×
597
            break;
598
        }
599
    }
NEW
600
}
×
601

UNCOV
602
void FunctionWizard::updateWidgetsTree()
×
603
{
604
    m_widgetsTree->clear();
×
605

606
    // Populate palette Widgets
UNCOV
607
    foreach (PaletteGenerator *palette, m_paletteList)
×
608
    {
609
        QTreeWidgetItem *frame = new QTreeWidgetItem(m_widgetsTree);
×
610
        frame->setText(KWidgetName, palette->fullName());
×
611
        if (palette->type() == PaletteGenerator::Animation)
×
612
        {
613
            frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SoloFrameWidget));
×
614
            frame->setData(KWidgetName, Qt::UserRole, VCWidget::SoloFrameWidget);
×
615
        }
616
        else
617
        {
618
            frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
619
            frame->setData(KWidgetName, Qt::UserRole, VCWidget::FrameWidget);
×
620
        }
621
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)palette));
×
622
        frame->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
623
        frame->setCheckState(KWidgetName, Qt::Unchecked);
×
624

625
        QTreeWidgetItem *soloFrameItem = NULL;
626
        if (palette->scenes().count() > 0)
×
627
        {
628
            soloFrameItem = new QTreeWidgetItem(frame);
×
629
            soloFrameItem->setText(KWidgetName, tr("Presets solo frame"));
×
630
            soloFrameItem->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SoloFrameWidget));
×
631
            soloFrameItem->setFlags(soloFrameItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
632
            soloFrameItem->setCheckState(KWidgetName, Qt::Unchecked);
×
633
            soloFrameItem->setData(KWidgetName, Qt::UserRole, VCWidget::SoloFrameWidget);
×
634
        }
635
        foreach (Scene *scene, palette->scenes())
×
636
        {
637
            QTreeWidgetItem *item = NULL;
638
            if (soloFrameItem != NULL)
×
639
                item = new QTreeWidgetItem(soloFrameItem);
×
640
            else
641
                item = new QTreeWidgetItem(frame);
×
642
            QString toRemove = " - " + palette->model();
×
643
            item->setText(KWidgetName, scene->name().remove(toRemove));
×
644
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
645
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
646
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
647
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)scene));
×
648

649
        }
650
        foreach (Chaser *chaser, palette->chasers())
×
651
        {
652
            QTreeWidgetItem *item = new QTreeWidgetItem(frame);
×
653
            QString toRemove = " - " + palette->model();
×
654
            item->setText(KWidgetName, chaser->name().remove(toRemove));
×
655
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::CueListWidget));
×
656
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
657
            item->setData(KWidgetName, Qt::UserRole, VCWidget::CueListWidget);
×
658
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)chaser));
×
659
        }
660

661
        foreach (RGBMatrix *matrix, palette->matrices())
×
662
        {
663
            QTreeWidgetItem *item = NULL;
664
            if (soloFrameItem != NULL)
×
665
                item = new QTreeWidgetItem(soloFrameItem);
×
666
            else
667
                item = new QTreeWidgetItem(frame);
×
668
            QString toRemove = " - " + palette->model();
×
669
            item->setText(KWidgetName, matrix->name().remove(toRemove));
×
670
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
671
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
672
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
673
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)matrix));
×
674
        }
675

676
        if (palette->scenes().count() > 0)
×
677
        {
678
            int pType = palette->type();
×
679
            QTreeWidgetItem *item = new QTreeWidgetItem(frame);
×
680
            if (pType == PaletteGenerator::PrimaryColors ||
×
681
                pType == PaletteGenerator::SixteenColors)
682
                    item->setText(KWidgetName, tr("Click & Go RGB"));
×
683
            else if (pType == PaletteGenerator::Gobos ||
×
684
                     pType == PaletteGenerator::Shutter ||
×
685
                     pType == PaletteGenerator::ColourMacro)
686
                        item->setText(KWidgetName, tr("Click & Go Macro"));
×
687

688
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SliderWidget));
×
689
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
690
            item->setData(KWidgetName, Qt::UserRole, VCWidget::SliderWidget);
×
691
            Scene *firstScene = palette->scenes().at(0);
×
692
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)firstScene));
×
693
        }
694
    }
695

696
    // Populate Fixture channel Widgets
NEW
697
    if (m_checkBoxAll->checkState() == 0 && m_checkBoxHeads->checkState() == 0 &&
×
NEW
698
        m_checkBoxFixtures->checkState() == 0)
×
699
        return;
700

NEW
701
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
702
    {
NEW
703
        QTreeWidgetItem *fxGrpItem = m_fixtureTree->topLevelItem(i);
×
704
        Q_ASSERT(fxGrpItem != NULL);
705

NEW
706
        if (fxGrpItem->childCount() == 0)
×
NEW
707
            continue;
×
708

NEW
709
        QTreeWidgetItem *frame = new QTreeWidgetItem(m_widgetsTree);
×
NEW
710
        frame->setText(KWidgetName, "Channels - " + fxGrpItem->text(KFixtureColumnName));
×
NEW
711
        frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
NEW
712
        frame->setData(KWidgetName, Qt::UserRole, VCWidget::FrameWidget);
×
NEW
713
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)NULL));
×
NEW
714
        frame->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
NEW
715
        frame->setCheckState(KWidgetName, Qt::Unchecked);
×
NEW
716
        frame->setExpanded(true);
×
717

718
        // since groups contain fixture of the same type, get the first
719
        // child and create categories on its capabilities
NEW
720
        QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
NEW
721
        quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
NEW
722
        Fixture* fxi = m_doc->fixture(fxID);
×
723
        Q_ASSERT(fxi != NULL);
724

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

NEW
727
        quint8 fixtureCount = fxGrpItem->childCount();
×
NEW
728
        quint8 headCount = fxi->heads();
×
729

NEW
730
        QList<quint32> HeadChannels = fxi->head(0).channels();
×
NEW
731
        QList<quint32> noHeadChannels;
×
NEW
732
        for (size_t i = 0; i < fxi->channels(); i++)
×
733
        {
NEW
734
            noHeadChannels.append(i);
×
735
        }
NEW
736
        for (int h = 0; h < fxi->heads(); h++)
×
737
        {
NEW
738
            for (auto &&ch : fxi->head(h).channels())
×
739
            {
NEW
740
                noHeadChannels.removeAll(ch);
×
741
            }
742
        }
743

NEW
744
        QList<quint32> allChannels = HeadChannels;
×
745
        allChannels.append(noHeadChannels);
746

747
        quint16 pageCount = 0;
748

NEW
749
        QString pageName = "%1 Pages - ";
×
NEW
750
        if (m_checkBoxFixtures->checkState())
×
751
        {
NEW
752
            pageName.append("[F]");
×
NEW
753
            pageCount = fixtureCount;
×
754
        }
755
        else
756
            fixtureCount = 0;
NEW
757
        if (headCount > 1 && m_checkBoxHeads->checkState() == 2)
×
758
        {
NEW
759
            if (pageCount > 0)
×
760
            {
NEW
761
                pageCount *= headCount;
×
NEW
762
                pageName.append("/");
×
763
            }
764
            else
NEW
765
                pageCount = headCount;
×
NEW
766
            pageName.append("[H]");
×
767
        }
768
        else
769
            headCount = 0;
770

NEW
771
        if (pageCount < 2)
×
772
        {
773
            // No Pages
NEW
774
            addChannelsToTree(frame, fxGrpItem, allChannels);
×
NEW
775
            continue;
×
776
        }
777

NEW
778
        if (m_checkBoxAll->checkState() == 2)
×
779
        {
NEW
780
            QTreeWidgetItem *page = new QTreeWidgetItem(frame);
×
NEW
781
            page->setText(KWidgetName, "Page - All");
×
NEW
782
            page->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
NEW
783
            page->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
NEW
784
            page->setCheckState(KWidgetName, Qt::Unchecked);
×
NEW
785
            page->setExpanded(true);
×
786

NEW
787
            addChannelsToTree(page, fxGrpItem, allChannels);
×
788
        }
789

NEW
790
        pageName = pageName.arg(pageCount);
×
791

NEW
792
        QTreeWidgetItem *page = new QTreeWidgetItem(frame);
×
NEW
793
        page->setText(KWidgetName, pageName);
×
NEW
794
        page->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
NEW
795
        page->setData(KWidgetName, Qt::UserRole + 1, fixtureCount); // FixturePageCount
×
NEW
796
        page->setData(KWidgetName, Qt::UserRole + 2, headCount);    // HeadPageCount
×
NEW
797
        page->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
NEW
798
        page->setCheckState(KWidgetName, Qt::Unchecked);
×
NEW
799
        page->setExpanded(true);
×
800

NEW
801
        addChannelsToTree(page, fxGrpItem,
×
NEW
802
                          (headCount > 1 && m_checkBoxHeads->checkState() == 2) ? HeadChannels
×
803
                                                                                : allChannels);
804
    }
805
}
806

807
VCWidget *FunctionWizard::createWidget(int type, VCWidget *parent, int xpos, int ypos,
×
808
                                       Function *func, int pType, QTreeWidgetItem *fxGrpItem,
809
                                       quint32 chan, qint32 fixtureNr, qint32 headId)
810
{
811
    VirtualConsole *vc = VirtualConsole::instance();
×
812
    VCWidget *widget = NULL;
813

814
    if (parent == NULL)
×
815
        return NULL;
816

817
    switch(type)
×
818
    {
819
        case VCWidget::FrameWidget:
×
820
        {
821
            VCFrame* frame = new VCFrame(parent, m_doc, true);
×
822
            vc->setupWidget(frame, parent);
×
823
            frame->move(QPoint(xpos, ypos));
×
824
            widget = frame;
825
        }
826
        break;
×
827
        case VCWidget::SoloFrameWidget:
×
828
        {
829
            VCSoloFrame* frame = new VCSoloFrame(parent, m_doc, true);
×
830
            vc->setupWidget(frame, parent);
×
831
            frame->move(QPoint(xpos, ypos));
×
832
            widget = frame;
833
        }
834
        break;
×
835
        case VCWidget::ButtonWidget:
×
836
        {
837
            VCButton* button = new VCButton(parent, m_doc);
×
838
            vc->setupWidget(button, parent);
×
839
            button->move(QPoint(xpos, ypos));
×
840
            if (func != NULL)
×
841
                button->setFunction(func->id());
×
842

843
            widget = button;
844
        }
845
        break;
846
        case VCWidget::CueListWidget:
×
847
        {
848
            VCCueList* cuelist = new VCCueList(parent, m_doc);
×
849
            vc->setupWidget(cuelist, parent);
×
850
            cuelist->move(QPoint(xpos, ypos));
×
851
            if (func != NULL)
×
852
                cuelist->setChaser(func->id());
×
NEW
853
            cuelist->resize(QSize(300, m_sliderHeightSpin->value()));
×
854

855
            widget = cuelist;
856
        }
UNCOV
857
        break;
×
858
        case VCWidget::SliderWidget:
×
859
        {
860
            VCSlider* slider = new VCSlider(parent, m_doc);
×
861
            vc->setupWidget(slider, parent);
×
862
            slider->move(QPoint(xpos, ypos));
×
863
            // Click & Go Slider in Pallette Frames
UNCOV
864
            if (func != NULL)
×
865
            {
866
                Scene *scene = qobject_cast<Scene*> (func);
867
                foreach (SceneValue scv, scene->values())
×
868
                    slider->addLevelChannel(scv.fxi, scv.channel);
×
869

870
                if (pType == PaletteGenerator::PrimaryColors ||
×
871
                    pType == PaletteGenerator::SixteenColors)
872
                        slider->setClickAndGoType(ClickAndGoWidget::RGB);
×
873
                else
874
                    slider->setClickAndGoType(ClickAndGoWidget::Preset);
×
875
                slider->setSliderMode(VCSlider::Level);
×
876
            }
877
            else
878
            {
879
                // get channel of first Fixture
NEW
880
                int fxID = fxGrpItem->child(0)->data(KFixtureColumnName, Qt::UserRole).toInt();
×
NEW
881
                Fixture *fixture = m_doc->fixture(fxID);
×
NEW
882
                const QLCChannel *channel = fixture->channel(chan);
×
883

NEW
884
                bool isRGB = channel->colour()==QLCChannel::Red;
×
885

NEW
886
                for (int c = 0; c < fxGrpItem->childCount(); c++)
×
887
                {
NEW
888
                    if (fixtureNr >= 0 && c != fixtureNr)
×
NEW
889
                        continue;
×
890

NEW
891
                    QTreeWidgetItem *fxItem = fxGrpItem->child(c);
×
NEW
892
                    int fxi = fxItem->data(KFixtureColumnName, Qt::UserRole).toInt();
×
NEW
893
                    Fixture *fixture = m_doc->fixture(fxID);
×
NEW
894
                    qint16 chanIndex = fixture->head(0).channels().indexOf(chan);
×
NEW
895
                    for (qint32 h = 0; h < fixture->heads(); h++)
×
896
                    {
NEW
897
                        if (headId >= 0 && h != headId)
×
NEW
898
                            continue;
×
899

900
                        quint32 headChannel = chan;
NEW
901
                        if (chanIndex >= 0) // check if channel is in head
×
NEW
902
                            headChannel = fixture->head(h).channels().at(chanIndex);
×
903

NEW
904
                        slider->addLevelChannel(fxi, headChannel);
×
NEW
905
                        if (isRGB)
×
906
                        {
NEW
907
                            slider->addLevelChannel(fxi, headChannel + 1);
×
NEW
908
                            slider->addLevelChannel(fxi, headChannel + 2);
×
909
                        }
910
                    }
911
                }
912
                
NEW
913
                if(isRGB){
×
NEW
914
                    slider->setClickAndGoType(ClickAndGoWidget::RGB);
×
915
                }
NEW
916
                else if(channel->group() == QLCChannel::Intensity)
×
917
                {
NEW
918
                    slider->setClickAndGoType(ClickAndGoWidget::None);
×
919
                }
920
                else
921
                {
NEW
922
                    slider->setClickAndGoType(ClickAndGoWidget::Preset);
×
923
                }
924
                
NEW
925
                if(channel->group()==QLCChannel::Speed)
×
NEW
926
                    slider->setWidgetStyle(VCSlider::WKnob);
×
927

NEW
928
                if ((fixtureNr >= 0 || headId >= 0) && m_checkBoxAll->checkState() == Qt::Checked)
×
NEW
929
                    slider->setChannelsMonitorEnabled(true);
×
930

NEW
931
                slider->setSliderMode(VCSlider::Level); 
×
932
            }
933

NEW
934
            slider->resize(QSize(m_sliderWidthSpin->value(), m_sliderHeightSpin->value()));
×
935

936
            widget = slider;
937
        }
UNCOV
938
        break;
×
NEW
939
        case VCWidget::XYPadWidget:
×
940
        {
NEW
941
            VCXYPad* XYPad = new VCXYPad(parent, m_doc);
×
NEW
942
            vc->setupWidget(XYPad, parent);
×
NEW
943
            XYPad->move(QPoint(xpos, ypos));
×
944

NEW
945
            for (int c = 0; c < fxGrpItem->childCount(); c++)
×
946
            {
NEW
947
                if (fixtureNr >= 0 && c != fixtureNr)
×
NEW
948
                    continue;
×
949

NEW
950
                QTreeWidgetItem *fxItem = fxGrpItem->child(c);
×
NEW
951
                int fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toInt();
×
NEW
952
                Fixture *fixture = m_doc->fixture(fxID);
×
NEW
953
                for (qint32 h = 0; h < fixture->heads(); h++)
×
954
                {
NEW
955
                    if (headId >= 0 && h != headId)
×
NEW
956
                        continue;
×
957

NEW
958
                    VCXYPadFixture fxi = VCXYPadFixture(m_doc);
×
NEW
959
                    fxi.setHead(GroupHead(fxID, h));
×
NEW
960
                    XYPad->appendFixture(fxi);
×
961
                }
962
            }
NEW
963
            XYPad->resize(QSize(m_sliderHeightSpin->value(), m_sliderHeightSpin->value()));
×
964
                      
965
            widget = XYPad;
966
        }
NEW
967
        break;
×
968
        default:
969
        break;
970
    }
971

972
    // Set Function
UNCOV
973
    if (widget != NULL && func != NULL)
×
974
    {
975
        if (func->type() == Function::SceneType && type == VCWidget::ButtonWidget)
×
976
        {
977
            Scene *scene = qobject_cast<Scene*> (func);
978

979
            if (pType == PaletteGenerator::PrimaryColors ||
×
980
                pType == PaletteGenerator::SixteenColors ||
×
981
                pType == PaletteGenerator::ColourMacro)
×
982
            {
983
                QColor col = scene->colorValue();
×
984
                if (col.isValid())
×
985
                    widget->setBackgroundColor(col);
×
986
            }
987
            else if (pType == PaletteGenerator::Gobos)
×
988
            {
989
                foreach (SceneValue scv, scene->values())
×
990
                {
991
                    Fixture *fixture = m_doc->fixture(scv.fxi);
×
992
                    if (fixture == NULL)
×
993
                        continue;
×
994

995
                    const QLCChannel* channel(fixture->channel(scv.channel));
×
996
                    if (channel->group() == QLCChannel::Gobo)
×
997
                    {
998
                        QLCCapability *cap = channel->searchCapability(scv.value);
×
999
                        if (cap->resource(0).isValid())
×
1000
                        {
1001
                            widget->setBackgroundImage(cap->resource(0).toString());
×
1002
                            break;
×
1003
                        }
1004
                    }
1005
                }
1006
            }
1007
        }
1008
    }
1009

1010
    return widget;
1011
}
1012

1013
QSize FunctionWizard::recursiveCreateWidget(QTreeWidgetItem *item, VCWidget *parent, int type)
×
1014
{
UNCOV
1015
    QSize groupSize(100, 50);
×
1016
    int subX = 10, subY = 40;
1017

1018
    for (int c = 0; c < item->childCount(); c++)
×
1019
    {
1020
        QTreeWidgetItem *childItem = item->child(c);
×
1021

1022
        if (childItem->checkState(KWidgetName) == Qt::Checked ||
×
1023
            childItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1024
        {
1025
            int cType = childItem->data(KWidgetName, Qt::UserRole).toInt();
×
1026
            Function *func = NULL;
1027
            QTreeWidgetItem *fxGrpItem  = NULL;
1028
            quint32 channel = 0;
NEW
1029
            if(type)
×
NEW
1030
                func = (Function *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1031
            else
1032
            {
NEW
1033
                fxGrpItem = (QTreeWidgetItem *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
NEW
1034
                channel = childItem->data(KWidgetName, Qt::UserRole + 2).toUInt();
×
1035

1036
            }
1037

NEW
1038
            if (childItem->text(KWidgetName).contains("Page"))
×
1039
            {
1040
                VCFrame *frame = (VCFrame *)parent;
NEW
1041
                frame->setMultipageMode(true);
×
1042

NEW
1043
                if (childItem->childCount() > 0)
×
1044
                {
NEW
1045
                    if (childItem->text(KWidgetName).contains("All"))
×
1046
                    {
1047
                        //         v page v
NEW
1048
                        childItem->setData(KWidgetName, Qt::UserRole + 1, -1); // all fixtures
×
NEW
1049
                        childItem->setData(KWidgetName, Qt::UserRole + 2, -1); // all heads
×
1050
                        
NEW
1051
                        groupSize = recursiveCreateWidget(childItem, parent, type);                         
×
1052
                        //                   v frame v
NEW
1053
                        childItem->parent()->setData(KWidgetName, Qt::UserRole + 3, groupSize);
×
NEW
1054
                        frame->shortcuts().at(frame->currentPage())->setName("All");
×
NEW
1055
                        frame->setTotalPagesNumber(frame->totalPagesNumber() + 1);
×
NEW
1056
                        frame->slotNextPage();
×
NEW
1057
                        continue;
×
1058
                    }
1059
                    else
1060
                    {
NEW
1061
                        qint32 fxPages = childItem->data(KWidgetName, Qt::UserRole + 1).toInt();
×
NEW
1062
                        qint32 headPages = childItem->data(KWidgetName, Qt::UserRole + 2).toInt();
×
NEW
1063
                        qint32 f = fxPages ? 0 : -1;
×
1064

NEW
1065
                        for (; f < fxPages; f++)
×
1066
                        {
NEW
1067
                            qint32 h = headPages ? 0 : -1;
×
NEW
1068
                            for (; h < headPages; h++)
×
1069
                            {
1070
                                // page
NEW
1071
                                childItem->setData(KWidgetName, Qt::UserRole + 1, f); // fixture
×
NEW
1072
                                childItem->setData(KWidgetName, Qt::UserRole + 2, h); // head
×
1073

NEW
1074
                                QSize size = recursiveCreateWidget(childItem, parent, type);
×
NEW
1075
                                groupSize = childItem->parent()
×
NEW
1076
                                                ->data(KWidgetName, Qt::UserRole + 3)
×
NEW
1077
                                                .toSize();
×
1078

NEW
1079
                                if (size.width() > groupSize.width())
×
1080
                                    groupSize.setWidth(size.width());
NEW
1081
                                if (size.height() > groupSize.height())
×
1082
                                    groupSize.setHeight(size.height());
1083

NEW
1084
                                QString pageName = "";
×
NEW
1085
                                if (f >= 0)
×
NEW
1086
                                    pageName.append(QString("F%1").arg(f));
×
1087

NEW
1088
                                if (h >= 0)
×
NEW
1089
                                    pageName.append(QString("%1H%2").arg((f >= 0) ? "/" : "").arg(h));
×
1090

NEW
1091
                                frame->shortcuts().at(frame->currentPage())->setName(pageName);
×
NEW
1092
                                frame->setTotalPagesNumber(frame->totalPagesNumber() + 1);
×
NEW
1093
                                frame->slotNextPage();
×
1094
                            }
1095
                        }
NEW
1096
                        frame->setTotalPagesNumber(frame->totalPagesNumber() - 1);
×
NEW
1097
                        frame->slotSetPage(0);
×
NEW
1098
                        frame->updatePageCombo();
×
1099
                    }
1100
                }
NEW
1101
                continue;
×
1102
            }
1103

1104
            qint32 fxNr = -1;
1105
            qint32 headId = -1;
NEW
1106
            if(childItem->parent()->text(KWidgetName).contains("Page")){
×
NEW
1107
                fxNr = childItem->parent()->data(KWidgetName, Qt::UserRole + 1).toInt();
×
NEW
1108
                headId = childItem->parent()->data(KWidgetName, Qt::UserRole + 2).toInt();
×
1109
            }
1110

1111

NEW
1112
            VCWidget *childWidget = createWidget(cType, parent, subX, subY, func, type, fxGrpItem,
×
1113
                                                 channel, fxNr, headId);
UNCOV
1114
            if (childWidget != NULL)
×
1115
            {
NEW
1116
                if(childWidget->type()==VCWidget::SliderWidget)
×
NEW
1117
                    childWidget->setCaption(childItem->text(KWidgetName).split(" - ")[0]);
×
1118
                else
NEW
1119
                    childWidget->setCaption(childItem->text(KWidgetName));
×
1120

NEW
1121
                QTextStream cout(stdout, QIODevice::WriteOnly);
×
NEW
1122
                cout << childItem->text(KWidgetName) << Qt::endl;
×
1123
                //cout << "p:"<<parent->type() << " spin:" << m_lineCntSpin->value() << " per:" <<wPerLine << Qt::endl;
1124

1125
                if (childItem->childCount() > 0)
×
1126
                {
NEW
1127
                    childWidget->resize(QSize(2000, 1000));
×
1128

1129
                    QSize size = recursiveCreateWidget(childItem, childWidget, type);
×
1130

1131
                    childWidget->resize(size);
×
1132

1133
                }
1134

1135
                if (subX + childWidget->width() > groupSize.width())
×
1136
                    groupSize.setWidth(subX + childWidget->width() + 10);
×
1137
                if (subY + childWidget->height() > groupSize.height())
×
1138
                    groupSize.setHeight(subY + childWidget->height() + 10);
×
1139

NEW
1140
                int wPerLine = parent->type()==VCWidget::SoloFrameWidget ? 4 : m_lineCntSpin->value();
×
NEW
1141
                if (c > 0 && (c + 1)%wPerLine == 0)
×
1142
                {
1143
                    subX = 10;
1144
                    subY += childWidget->height() + 10;
×
1145
                }
1146
                else
1147
                    subX += childWidget->width() + 10;
×
1148
            }
1149
        }
1150
    }
1151

1152
    return groupSize;
×
1153
}
1154

1155

1156

1157
void FunctionWizard::addWidgetsToVirtualConsole()
×
1158
{
1159
    int xPos = 10;
1160
    int yPos = 10;
1161

1162
    VirtualConsole *vc = VirtualConsole::instance();
×
1163
    VCFrame *mainFrame = vc->contents();
×
1164
    Q_ASSERT(mainFrame != NULL);
1165

1166
    for (int i = 0; i < m_widgetsTree->topLevelItemCount(); i++)
×
1167
    {
1168
        QTreeWidgetItem *wItem = m_widgetsTree->topLevelItem(i);
×
1169

1170
        if (wItem->checkState(KWidgetName) == Qt::Checked ||
×
1171
            wItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1172
        {
1173
            int wType = wItem->data(KWidgetName, Qt::UserRole).toInt();
×
1174
            VCWidget *widget = createWidget(wType, mainFrame, xPos, yPos);
×
1175
            if (widget == NULL)
×
1176
                continue;
×
1177

NEW
1178
            widget->resize(QSize(2000, 1000));
×
1179

1180
            int pType = 0;
NEW
1181
            if(!wItem->text(KWidgetName).contains("Channels"))
×
1182
            {
NEW
1183
                PaletteGenerator *pal = (PaletteGenerator *) wItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
NEW
1184
                pType = pal->type();
×
1185
            }
1186

1187
            widget->setCaption(wItem->text(KWidgetName));
×
1188

1189
            QSize size = recursiveCreateWidget(wItem, widget, pType);
×
1190

1191
            widget->resize(size);
×
1192
            xPos += widget->width() + 10;
×
1193
        }
1194
    }
1195
}
×
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