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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 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
    connect(m_checkBoxAll, SIGNAL(clicked()),
×
92
            this, SLOT(slotPageCheckboxChanged()));
93

94
    connect(m_checkBoxHeads, SIGNAL(clicked()),
×
95
            this, SLOT(slotPageCheckboxChanged()));
96

97
    connect(m_checkBoxFixtures, SIGNAL(clicked()),
×
98
            this, SLOT(slotPageCheckboxChanged()));
99

100
    checkTabsAndButtons();
×
101
}
×
102

103
FunctionWizard::~FunctionWizard()
×
104
{
105
    QSettings settings;
×
106
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
107

108
    m_paletteList.clear();
×
109
}
×
110

111
void FunctionWizard::slotNextPageClicked()
×
112
{
113
    int newIdx = m_tabWidget->currentIndex() + 1;
×
114
    if (newIdx == 4)
×
115
        return;
116

117
    m_tabWidget->setCurrentIndex(newIdx);
×
118
    checkTabsAndButtons();
×
119
}
120

121
void FunctionWizard::slotTabClicked()
×
122
{
123
    checkTabsAndButtons();
×
124
}
×
125

126
void FunctionWizard::accept()
×
127
{
128

129
    foreach (PaletteGenerator *palette, m_paletteList)
×
130
        palette->addToDoc();
×
131

132
    addWidgetsToVirtualConsole();
×
133

134
    m_doc->setModified();
×
135

136
    QDialog::accept();
×
137
}
×
138

139
void FunctionWizard::checkTabsAndButtons()
×
140
{
141
    switch(m_tabWidget->currentIndex())
×
142
    {
143
        case 0:
×
144
        {
145
            m_nextButton->setEnabled(true);
×
146
            m_tabWidget->setTabEnabled(2, false);
×
147
            m_tabWidget->setTabEnabled(3, false);
×
148
        }
149
        break;
×
150
        case 1:
×
151
        {
152
            if (m_allFuncsTree->topLevelItemCount() == 0)
×
153
            {
154
                m_nextButton->setEnabled(false);
×
155
                m_tabWidget->setTabEnabled(2, false);
×
156
            }
157
            else
158
            {
159
                m_nextButton->setEnabled(true);
×
160
                m_tabWidget->setTabEnabled(2, true);
×
161
            }
162
        }
163
        break;
164
        case 2:
×
165
        {
166
            m_nextButton->setEnabled(m_widgetsTree->topLevelItemCount() > 0);            
×
167
        }
168
        break;
×
169
        case 3:
×
170
            m_nextButton->setEnabled(false);
×
171
        break;
×
172
    }
173

174
    // enable VC Widget Page if tree not empty
175
    m_tabWidget->setTabEnabled(3, m_widgetsTree->topLevelItemCount() > 0);
×
176
}
×
177

178
/****************************************************************************
179
 * Fixtures
180
 ****************************************************************************/
181

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

201
void FunctionWizard::addFixture(quint32 fxi_id)
×
202
{
203
    Fixture* fxi = m_doc->fixture(fxi_id);
×
204
    Q_ASSERT(fxi != NULL);
205

206
    QStringList caps = PaletteGenerator::getCapabilities(fxi);
×
207

208
    if (caps.join(", ").isEmpty())
×
209
    {
210
        QMessageBox::warning(this, tr("Error"), tr("%1 has no capability supported by this wizard.").arg(fxi->name()));
×
211
        return;
212
    }
213
    else
214
    {
215
        QTreeWidgetItem *groupItem = getFixtureGroupItem(fxi->fixtureDef()->manufacturer(), fxi->fixtureDef()->model());
×
216
        Q_ASSERT(groupItem != NULL);
217

218
        QTreeWidgetItem* item = new QTreeWidgetItem(groupItem);
×
219
        item->setText(KFixtureColumnName, fxi->name());
×
220
        item->setIcon(KFixtureColumnName, fxi->getIconFromType());
×
221
        item->setData(KFixtureColumnName, Qt::UserRole, fxi_id);
×
222
        item->setText(KFixtureColumnCaps, caps.join(", "));
×
223
    }
224
    m_fixtureTree->resizeColumnToContents(KFixtureColumnName);
×
225
}
226

227
void FunctionWizard::slotAddClicked()
×
228
{
229
    FixtureSelection fs(this, m_doc);
×
230
    fs.setMultiSelection(true);
×
231
    fs.setDisabledFixtures(fixtureIds());
×
232
    if (fs.exec() == QDialog::Accepted)
×
233
    {
234
        QListIterator <quint32> it(fs.selection());
×
235
        while (it.hasNext() == true)
×
236
            addFixture(it.next());
×
237

238
        if (m_fixtureTree->topLevelItemCount() > 0)
×
239
        {
240
            updateAvailableFunctionsTree();
×
241
            updateWidgetsTree();
×
242
        }
243
    }
244
    checkTabsAndButtons();
×
245
}
×
246

247
void FunctionWizard::slotRemoveClicked()
×
248
{
249
    QListIterator <QTreeWidgetItem*> it(m_fixtureTree->selectedItems());
×
250
    while (it.hasNext() == true)
×
251
        delete it.next();
×
252
    
253
    updateWidgetsTree();
×
254
    checkTabsAndButtons();
×
255
}
×
256

257
void FunctionWizard::slotPageCheckboxChanged()
×
258
{
259
    updateWidgetsTree();
×
260
}
×
261

262
QList <quint32> FunctionWizard::fixtureIds() const
×
263
{
264
    QList <quint32> list;
265
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
266
    {
267
        QTreeWidgetItem* item(m_fixtureTree->topLevelItem(i));
×
268
        Q_ASSERT(item != NULL);
269

270
        for (int j = 0; j < item->childCount(); j++)
×
271
        {
272
            QTreeWidgetItem *child = item->child(j);
×
273
            Q_ASSERT(child != NULL);
274

275
            list << child->data(KFixtureColumnName, Qt::UserRole).toInt();
×
276
        }
277
    }
278

279
    return list;
×
280
}
×
281

282
/********************************************************************
283
 * Functions
284
 ********************************************************************/
285

286
void FunctionWizard::addFunctionsGroup(QTreeWidgetItem *fxGrpItem, QTreeWidgetItem *grpItem,
×
287
                                       QString name, PaletteGenerator::PaletteType type)
288
{
289
    if (grpItem == NULL)
×
290
        return;
291

292
    QTreeWidgetItem *item = new QTreeWidgetItem(grpItem);
×
293
    item->setText(KFunctionName, name);
×
294
    item->setCheckState(KFunctionName, Qt::Unchecked);
×
295
    item->setData(KFunctionName, Qt::UserRole, type);
×
296

297
    if (fxGrpItem != NULL && fxGrpItem->childCount() > 1)
×
298
    {
299
        item->setCheckState(KFunctionOddEven, Qt::Unchecked);
×
300
    }
301
}
302

303
void FunctionWizard::updateAvailableFunctionsTree()
×
304
{
305
    disconnect(m_allFuncsTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
×
306
            this, SLOT(slotFunctionItemChanged(QTreeWidgetItem*,int)));
307

308
    m_allFuncsTree->clear();
×
309
    m_resFuncsTree->clear();
×
310

311
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
312
    {
313
        QTreeWidgetItem *fxGrpItem = m_fixtureTree->topLevelItem(i);
×
314
        Q_ASSERT(fxGrpItem != NULL);
315

316
        if (fxGrpItem->childCount() == 0)
×
317
            continue;
×
318

319
        QTreeWidgetItem *grpItem = new QTreeWidgetItem(m_allFuncsTree);
×
320
        grpItem->setText(KFunctionName, fxGrpItem->text(KFixtureColumnName));
×
321
        grpItem->setIcon(KFunctionName, fxGrpItem->icon(KFixtureColumnName));
×
322
        grpItem->setExpanded(true);
×
323

324
        // since groups contain fixture of the same type, get the first
325
        // child and create categories on its capabilities
326
        QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
327
        quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
328
        Fixture* fxi = m_doc->fixture(fxID);
×
329
        Q_ASSERT(fxi != NULL);
330

331
        QStringList caps = PaletteGenerator::getCapabilities(fxi);
×
332

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

362
    m_allFuncsTree->resizeColumnToContents(KFunctionName);
×
363

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

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

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

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

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

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

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

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

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

450
void FunctionWizard::slotFunctionItemChanged(QTreeWidgetItem *item, int col)
×
451
{
452
    Q_UNUSED(col)
453
    Q_UNUSED(item)
454

455
    updateResultFunctionsTree();
×
456
    updateWidgetsTree();
×
457

458
    checkTabsAndButtons();
×
459
}
×
460

461
/********************************************************************
462
 * Widgets
463
 ********************************************************************/
464

465
void FunctionWizard::addWidgetItem(QTreeWidgetItem *grpItem, QString name, int type,
×
466
                             QTreeWidgetItem *fxGrpItem, quint32 *channels)
467
{
468
    if (grpItem == NULL)
×
469
        return;
470

471
    QTreeWidgetItem *item = new QTreeWidgetItem(grpItem);
×
472
    item->setText(KWidgetName, name );
×
473
    item->setCheckState(KWidgetName, Qt::Unchecked);
×
474
    item->setData(KWidgetName, Qt::UserRole, type);
×
475
    item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void*)fxGrpItem));
×
476
    item->setData(KWidgetName, Qt::UserRole + 2, QVariant::fromValue(channels[0]));
×
477
    item->setIcon(KWidgetName, VCWidget::typeToIcon(type));
×
478
    if(name.toLower().contains("speed")) item->setIcon(KWidgetName, QIcon(":/knob.png"));
×
479
    
480
}
481

482
void FunctionWizard::checkPanTilt(QTreeWidgetItem *grpItem,
×
483
                            QTreeWidgetItem *fxGrpItem, qint32* channels)
484
{
485
    //Check if all required Channels are set
486
    if (channels[0] < 0) return;
×
487
    if (channels[2] < 0) return;
×
488
    if (channels[1] > 0 && channels[3] < 0) return;
×
489
    
490
    quint32 panTiltChannels[4] = {};
×
491
    for (size_t i = 0; i < 4; i++)
×
492
        panTiltChannels[i] = channels[i];
×
493

494
    addWidgetItem(grpItem, "XY PAD", VCWidget::XYPadWidget, fxGrpItem, panTiltChannels);
×
495

496
    channels[0] = -1;
×
497
    channels[1] = -1;
×
498
    channels[2] = -1;
×
499
    channels[3] = -1;
×
500
}
501

502
void FunctionWizard::checkRGB(QTreeWidgetItem *grpItem, 
×
503
                            QTreeWidgetItem *fxGrpItem, qint32* channels)
504
{
505
    // Check if all required Channels are set
506
    for (size_t i = 0; i < 3; i++) if(channels[i] < 0) return;
×
507

508
    quint32 RGB[3] = {};
×
509
    for (size_t i = 0; i < 3; i++)
×
510
        RGB[i] = channels[i];
×
511

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

514
    RGB[0] = -1;
515
    RGB[1] = -1;
516
    RGB[2] = -1;
517
}
518

519
void FunctionWizard::addChannelsToTree(QTreeWidgetItem *frame, QTreeWidgetItem *fxGrpItem, QList<quint32> channels)
×
520
{
521
    QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
522
    quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
523
    Fixture *fxi = m_doc->fixture(fxID);
×
524
    Q_ASSERT(fxi != NULL);
525

526
    qint32 lastPanTilt[] = {-1, -1, -1, -1};
×
527
    qint32 lastRGB[] = {-1, -1, -1};
×
528

529
    
530
    for (auto &&ch : channels)
×
531
    //for (quint32 ch = 0; ch < fxi->channels(); ch++)
532
    {
533
        const QLCChannel *channel(fxi->channel(ch));
×
534
        Q_ASSERT(channel != NULL);
535

536
        switch (channel->group())
×
537
        {
538
        case QLCChannel::Pan: {
×
539
            if (channel->preset() == QLCChannel::PositionPan)
×
540
                lastPanTilt[0] = ch;
×
541
            if (channel->preset() == QLCChannel::PositionPanFine)
×
542
                lastPanTilt[1] = ch;
×
543

544
            checkPanTilt(frame, fxGrpItem, lastPanTilt);
×
545
        }
546
        break;
547
        case QLCChannel::Tilt: {
×
548
            if (channel->preset() == QLCChannel::PositionTilt)
×
549
                lastPanTilt[2] = ch;
×
550
            if (channel->preset() == QLCChannel::PositionTiltFine)
×
551
                lastPanTilt[3] = ch;
×
552

553
            checkPanTilt(frame, fxGrpItem, lastPanTilt);
×
554
        }
555
        break;
556

557
        // Glick & Go's
558
        case QLCChannel::Gobo:
×
559
        case QLCChannel::Shutter:
560
        case QLCChannel::Prism:
561
        case QLCChannel::Beam:
562
        case QLCChannel::Effect:
563
        case QLCChannel::Colour:
564
            addWidgetItem(frame, QLCChannel::groupToString(channel->group()) + " - Click & Go",
×
565
                          VCWidget::SliderWidget, fxGrpItem, &ch);
566
            break;
×
567

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

611
void FunctionWizard::updateWidgetsTree()
×
612
{
613
    m_widgetsTree->clear();
×
614

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

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

658
        }
×
659
        foreach (Chaser *chaser, palette->chasers())
×
660
        {
661
            QTreeWidgetItem *item = new QTreeWidgetItem(frame);
×
662
            QString toRemove = " - " + palette->model();
×
663
            item->setText(KWidgetName, chaser->name().remove(toRemove));
×
664
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::CueListWidget));
×
665
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
666
            item->setData(KWidgetName, Qt::UserRole, VCWidget::CueListWidget);
×
667
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)chaser));
×
668
        }
×
669

670
        foreach (RGBMatrix *matrix, palette->matrices())
×
671
        {
672
            QTreeWidgetItem *item = NULL;
673
            if (soloFrameItem != NULL)
×
674
                item = new QTreeWidgetItem(soloFrameItem);
×
675
            else
676
                item = new QTreeWidgetItem(frame);
×
677
            QString toRemove = " - " + palette->model();
×
678
            item->setText(KWidgetName, matrix->name().remove(toRemove));
×
679
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
680
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
681
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
682
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)matrix));
×
683
        }
×
684

685
        if (palette->scenes().count() > 0)
×
686
        {
687
            int pType = palette->type();
×
688
            QTreeWidgetItem *item = new QTreeWidgetItem(frame);
×
689
            if (pType == PaletteGenerator::PrimaryColors ||
×
690
                pType == PaletteGenerator::SixteenColors)
691
                    item->setText(KWidgetName, tr("Click & Go RGB"));
×
692
            else if (pType == PaletteGenerator::Gobos ||
×
693
                     pType == PaletteGenerator::Shutter ||
×
694
                     pType == PaletteGenerator::ColourMacro)
695
                        item->setText(KWidgetName, tr("Click & Go Macro"));
×
696

697
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SliderWidget));
×
698
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
699
            item->setData(KWidgetName, Qt::UserRole, VCWidget::SliderWidget);
×
700
            Scene *firstScene = palette->scenes().at(0);
×
701
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)firstScene));
×
702
        }
703
    }
704

705
    // Populate Fixture channel Widgets
706
    if (m_checkBoxAll->checkState() == 0 && m_checkBoxHeads->checkState() == 0 &&
×
707
        m_checkBoxFixtures->checkState() == 0)
×
708
        return;
709

710
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
711
    {
712
        QTreeWidgetItem *fxGrpItem = m_fixtureTree->topLevelItem(i);
×
713
        Q_ASSERT(fxGrpItem != NULL);
714

715
        if (fxGrpItem->childCount() == 0)
×
716
            continue;
×
717

718
        QTreeWidgetItem *frame = new QTreeWidgetItem(m_widgetsTree);
×
719
        frame->setText(KWidgetName, "Channels - " + fxGrpItem->text(KFixtureColumnName));
×
720
        frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
721
        frame->setData(KWidgetName, Qt::UserRole, VCWidget::FrameWidget);
×
722
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)NULL));
×
723
        frame->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
724
        frame->setCheckState(KWidgetName, Qt::Unchecked);
×
725
        frame->setExpanded(true);
×
726

727
        // since groups contain fixture of the same type, get the first
728
        // child and create categories on its capabilities
729
        QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
730
        quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
731
        Fixture* fxi = m_doc->fixture(fxID);
×
732
        Q_ASSERT(fxi != NULL);
733

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

736
        quint8 fixtureCount = fxGrpItem->childCount();
×
737
        quint8 headCount = fxi->heads();
×
738

739
        QList<quint32> headChannels = fxi->head(0).channels();
×
740
        QList<quint32> noHeadChannels;
741
        for (size_t i = 0; i < fxi->channels(); i++)
×
742
        {
743
            noHeadChannels.append(i);
×
744
        }
745
        for (int h = 0; h < fxi->heads(); h++)
×
746
        {
747
            for (auto &&ch : fxi->head(h).channels())
×
748
            {
749
                noHeadChannels.removeAll(ch);
×
750
            }
×
751
        }
752

753
        QList<quint32> allChannels = headChannels;
×
754
        allChannels.append(noHeadChannels);
755

756
        quint16 pageCount = 0;
757
        QString pageName = "%1 Pages - ";
×
758

759
        if (m_checkBoxFixtures->checkState())
×
760
        {
761
            pageName.append("[F]");
×
762
            pageCount = fixtureCount;
×
763
        }
764
        else
765
            fixtureCount = 0;
766
        if (headCount > 1 && m_checkBoxHeads->checkState() == 2)
×
767
        {
768
            if (pageCount > 0)
×
769
            {
770
                pageCount *= headCount;
×
771
                pageName.append("/");
×
772
            }
773
            else
774
                pageCount = headCount;
×
775
            pageName.append("[H]");
×
776
        }
777
        else
778
            headCount = 0;
779

780
        if (pageCount < 2)
×
781
        {
782
            // No Pages
783
            addChannelsToTree(frame, fxGrpItem, allChannels);
×
784
            continue;
785
        }
786

787
        if (m_checkBoxAll->checkState() == 2)
×
788
        {
789
            QTreeWidgetItem *page = new QTreeWidgetItem(frame);
×
790
            page->setText(KWidgetName, "Page - All");
×
791
            page->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
792
            page->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
793
            page->setCheckState(KWidgetName, Qt::Unchecked);
×
794
            page->setExpanded(true);
×
795

796
            addChannelsToTree(page, fxGrpItem, allChannels);
×
797
        }
798

799
        pageName = pageName.arg(pageCount);
×
800

801
        QTreeWidgetItem *page = new QTreeWidgetItem(frame);
×
802
        page->setText(KWidgetName, pageName);
×
803
        page->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
804
        page->setData(KWidgetName, Qt::UserRole + 1, fixtureCount); // FixturePageCount
×
805
        page->setData(KWidgetName, Qt::UserRole + 2, headCount);    // HeadPageCount
×
806
        page->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
807
        page->setCheckState(KWidgetName, Qt::Unchecked);
×
808
        page->setExpanded(true);
×
809

810
        addChannelsToTree(page, fxGrpItem,
×
811
                          (headCount > 1 && m_checkBoxHeads->checkState() == 2) ? headChannels
×
812
                                                                                : allChannels);
813
    }
×
814
}
815

816
VCWidget *FunctionWizard::createWidget(int type, VCWidget *parent, int xpos, int ypos,
×
817
                                       Function *func, int pType, QTreeWidgetItem *fxGrpItem,
818
                                       quint32 chan, qint32 fixtureNr, qint32 headId)
819
{
820
    VirtualConsole *vc = VirtualConsole::instance();
×
821
    VCWidget *widget = NULL;
822

823
    if (parent == NULL)
×
824
        return NULL;
825

826
    switch(type)
×
827
    {
828
        case VCWidget::FrameWidget:
×
829
        {
830
            VCFrame* frame = new VCFrame(parent, m_doc, true);
×
831
            vc->setupWidget(frame, parent);
×
832
            frame->move(QPoint(xpos, ypos));
×
833
            widget = frame;
834
        }
835
        break;
×
836
        case VCWidget::SoloFrameWidget:
×
837
        {
838
            VCSoloFrame* frame = new VCSoloFrame(parent, m_doc, true);
×
839
            vc->setupWidget(frame, parent);
×
840
            frame->move(QPoint(xpos, ypos));
×
841
            widget = frame;
842
        }
843
        break;
×
844
        case VCWidget::ButtonWidget:
×
845
        {
846
            VCButton* button = new VCButton(parent, m_doc);
×
847
            vc->setupWidget(button, parent);
×
848
            button->move(QPoint(xpos, ypos));
×
849
            if (func != NULL)
×
850
                button->setFunction(func->id());
×
851

852
            widget = button;
853
        }
854
        break;
855
        case VCWidget::CueListWidget:
×
856
        {
857
            VCCueList* cuelist = new VCCueList(parent, m_doc);
×
858
            vc->setupWidget(cuelist, parent);
×
859
            cuelist->move(QPoint(xpos, ypos));
×
860
            if (func != NULL)
×
861
                cuelist->setChaser(func->id());
×
862
            cuelist->resize(QSize(300, m_sliderHeightSpin->value()));
×
863

864
            widget = cuelist;
865
        }
866
        break;
×
867
        case VCWidget::SliderWidget:
×
868
        {
869
            VCSlider* slider = new VCSlider(parent, m_doc);
×
870
            vc->setupWidget(slider, parent);
×
871
            slider->move(QPoint(xpos, ypos));
×
872
            // Click & Go Slider in Pallette Frames
873
            if (func != NULL)
×
874
            {
875
                Scene *scene = qobject_cast<Scene*> (func);
876
                foreach (SceneValue scv, scene->values())
×
877
                    slider->addLevelChannel(scv.fxi, scv.channel);
×
878

879
                if (pType == PaletteGenerator::PrimaryColors ||
×
880
                    pType == PaletteGenerator::SixteenColors)
881
                        slider->setClickAndGoType(ClickAndGoWidget::RGB);
×
882
                else
883
                    slider->setClickAndGoType(ClickAndGoWidget::Preset);
×
884
                slider->setSliderMode(VCSlider::Level);
×
885
            }
886
            else
887
            {
888
                // get channel of first Fixture
889
                int fxID = fxGrpItem->child(0)->data(KFixtureColumnName, Qt::UserRole).toInt();
×
890
                Fixture *fixture = m_doc->fixture(fxID);
×
891
                const QLCChannel *channel = fixture->channel(chan);
×
892

893
                bool isRGB = channel->colour()==QLCChannel::Red;
×
894

895
                for (int c = 0; c < fxGrpItem->childCount(); c++)
×
896
                {
897
                    if (fixtureNr >= 0 && c != fixtureNr)
×
898
                        continue;
×
899

900
                    QTreeWidgetItem *fxItem = fxGrpItem->child(c);
×
901
                    int fxi = fxItem->data(KFixtureColumnName, Qt::UserRole).toInt();
×
902
                    Fixture *fixture = m_doc->fixture(fxID);
×
903
                    qint16 chanIndex = fixture->head(0).channels().indexOf(chan);
×
904
                    for (qint32 h = 0; h < fixture->heads(); h++)
×
905
                    {
906
                        if (headId >= 0 && h != headId)
×
907
                            continue;
×
908

909
                        quint32 headChannel = chan;
910
                        if (chanIndex >= 0) // check if channel is in head
×
911
                            headChannel = fixture->head(h).channels().at(chanIndex);
×
912

913
                        slider->addLevelChannel(fxi, headChannel);
×
914
                        if (isRGB)
×
915
                        {
916
                            slider->addLevelChannel(fxi, headChannel + 1);
×
917
                            slider->addLevelChannel(fxi, headChannel + 2);
×
918
                        }
919
                    }
920
                }
921
                
922
                if (isRGB)
×
923
                {
924
                    slider->setClickAndGoType(ClickAndGoWidget::RGB);
×
925
                }
926
                else if (channel->group() == QLCChannel::Intensity)
×
927
                {
928
                    slider->setClickAndGoType(ClickAndGoWidget::None);
×
929
                }
930
                else
931
                {
932
                    slider->setClickAndGoType(ClickAndGoWidget::Preset);
×
933
                }
934
                
935
                if (channel->group() == QLCChannel::Speed)
×
936
                    slider->setWidgetStyle(VCSlider::WKnob);
×
937

938
                if ((fixtureNr >= 0 || headId >= 0) && m_checkBoxAll->checkState() == Qt::Checked)
×
939
                    slider->setChannelsMonitorEnabled(true);
×
940

941
                slider->setSliderMode(VCSlider::Level); 
×
942
            }
943

944
            slider->resize(QSize(m_sliderWidthSpin->value(), m_sliderHeightSpin->value()));
×
945

946
            widget = slider;
947
        }
948
        break;
×
949
        case VCWidget::XYPadWidget:
×
950
        {
951
            VCXYPad* XYPad = new VCXYPad(parent, m_doc);
×
952
            vc->setupWidget(XYPad, parent);
×
953
            XYPad->move(QPoint(xpos, ypos));
×
954

955
            for (int c = 0; c < fxGrpItem->childCount(); c++)
×
956
            {
957
                if (fixtureNr >= 0 && c != fixtureNr)
×
958
                    continue;
×
959

960
                QTreeWidgetItem *fxItem = fxGrpItem->child(c);
×
961
                int fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toInt();
×
962
                Fixture *fixture = m_doc->fixture(fxID);
×
963
                for (qint32 h = 0; h < fixture->heads(); h++)
×
964
                {
965
                    if (headId >= 0 && h != headId)
×
966
                        continue;
×
967

968
                    VCXYPadFixture fxi = VCXYPadFixture(m_doc);
×
969
                    fxi.setHead(GroupHead(fxID, h));
×
970
                    XYPad->appendFixture(fxi);
×
971
                }
×
972
            }
973
            XYPad->resize(QSize(m_sliderHeightSpin->value(), m_sliderHeightSpin->value()));
×
974
                      
975
            widget = XYPad;
976
        }
977
        break;
×
978
        default:
979
        break;
980
    }
981

982
    // Set Function
983
    if (widget != NULL && func != NULL)
×
984
    {
985
        if (func->type() == Function::SceneType && type == VCWidget::ButtonWidget)
×
986
        {
987
            Scene *scene = qobject_cast<Scene*> (func);
988

989
            if (pType == PaletteGenerator::PrimaryColors ||
×
990
                pType == PaletteGenerator::SixteenColors ||
×
991
                pType == PaletteGenerator::ColourMacro)
×
992
            {
993
                QColor col = scene->colorValue();
×
994
                if (col.isValid())
×
995
                    widget->setBackgroundColor(col);
×
996
            }
997
            else if (pType == PaletteGenerator::Gobos)
×
998
            {
999
                foreach (SceneValue scv, scene->values())
×
1000
                {
1001
                    Fixture *fixture = m_doc->fixture(scv.fxi);
×
1002
                    if (fixture == NULL)
×
1003
                        continue;
1004

1005
                    const QLCChannel* channel(fixture->channel(scv.channel));
×
1006
                    if (channel->group() == QLCChannel::Gobo)
×
1007
                    {
1008
                        QLCCapability *cap = channel->searchCapability(scv.value);
×
1009
                        if (cap->resource(0).isValid())
×
1010
                        {
1011
                            widget->setBackgroundImage(cap->resource(0).toString());
×
1012
                            break;
1013
                        }
1014
                    }
1015
                }
×
1016
            }
1017
        }
1018
    }
1019

1020
    return widget;
1021
}
1022

1023
QSize FunctionWizard::recursiveCreateWidget(QTreeWidgetItem *item, VCWidget *parent, int type)
×
1024
{
1025
    QSize groupSize(100, 50);
×
1026
    int subX = 10, subY = 40;
1027

1028
    for (int c = 0; c < item->childCount(); c++)
×
1029
    {
1030
        QTreeWidgetItem *childItem = item->child(c);
×
1031

1032
        if (childItem->checkState(KWidgetName) == Qt::Checked ||
×
1033
            childItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1034
        {
1035
            int cType = childItem->data(KWidgetName, Qt::UserRole).toInt();
×
1036
            Function *func = NULL;
1037
            QTreeWidgetItem *fxGrpItem  = NULL;
1038
            quint32 channel = 0;
1039

1040
            if (type)
×
1041
            {
1042
                func = (Function *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1043
            }
1044
            else
1045
            {
1046
                fxGrpItem = (QTreeWidgetItem *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1047
                channel = childItem->data(KWidgetName, Qt::UserRole + 2).toUInt();
×
1048
            }
1049

1050
            if (childItem->text(KWidgetName).contains("Page"))
×
1051
            {
1052
                VCFrame *frame = (VCFrame *)parent;
1053
                frame->setMultipageMode(true);
×
1054

1055
                if (childItem->childCount() > 0)
×
1056
                {
1057
                    if (childItem->text(KWidgetName).contains("All"))
×
1058
                    {
1059
                        // v page v
1060
                        childItem->setData(KWidgetName, Qt::UserRole + 1, -1); // all fixtures
×
1061
                        childItem->setData(KWidgetName, Qt::UserRole + 2, -1); // all heads
×
1062
                        
1063
                        groupSize = recursiveCreateWidget(childItem, parent, type);                         
×
1064
                        // v frame v
1065
                        childItem->parent()->setData(KWidgetName, Qt::UserRole + 3, groupSize);
×
1066
                        frame->shortcuts().at(frame->currentPage())->setName("All");
×
1067
                        frame->setTotalPagesNumber(frame->totalPagesNumber() + 1);
×
1068
                        frame->slotNextPage();
×
1069
                        continue;
×
1070
                    }
1071
                    else
1072
                    {
1073
                        qint32 fxPages = childItem->data(KWidgetName, Qt::UserRole + 1).toInt();
×
1074
                        qint32 headPages = childItem->data(KWidgetName, Qt::UserRole + 2).toInt();
×
1075
                        qint32 f = fxPages ? 0 : -1;
×
1076

1077
                        for (; f < fxPages; f++)
×
1078
                        {
1079
                            qint32 h = headPages ? 0 : -1;
×
1080
                            for (; h < headPages; h++)
×
1081
                            {
1082
                                // page
1083
                                childItem->setData(KWidgetName, Qt::UserRole + 1, f); // fixture
×
1084
                                childItem->setData(KWidgetName, Qt::UserRole + 2, h); // head
×
1085

1086
                                QSize size = recursiveCreateWidget(childItem, parent, type);
×
1087
                                groupSize = childItem->parent()
1088
                                                ->data(KWidgetName, Qt::UserRole + 3)
×
1089
                                                .toSize();
×
1090

1091
                                if (size.width() > groupSize.width())
×
1092
                                    groupSize.setWidth(size.width());
1093
                                if (size.height() > groupSize.height())
×
1094
                                    groupSize.setHeight(size.height());
1095

1096
                                QString pageName = "";
×
1097
                                if (f >= 0)
×
1098
                                    pageName.append(QString("F%1").arg(f));
×
1099

1100
                                if (h >= 0)
×
1101
                                    pageName.append(QString("%1H%2").arg((f >= 0) ? "/" : "").arg(h));
×
1102

1103
                                frame->shortcuts().at(frame->currentPage())->setName(pageName);
×
1104
                                frame->setTotalPagesNumber(frame->totalPagesNumber() + 1);
×
1105
                                frame->slotNextPage();
×
1106
                            }
×
1107
                        }
1108
                        frame->setTotalPagesNumber(frame->totalPagesNumber() - 1);
×
1109
                        frame->slotSetPage(0);
×
1110
                        frame->updatePageCombo();
×
1111
                    }
1112
                }
1113
                continue;
×
1114
            }
×
1115

1116
            qint32 fxNr = -1;
1117
            qint32 headId = -1;
1118
            if (childItem->parent()->text(KWidgetName).contains("Page"))
×
1119
            {
1120
                fxNr = childItem->parent()->data(KWidgetName, Qt::UserRole + 1).toInt();
×
1121
                headId = childItem->parent()->data(KWidgetName, Qt::UserRole + 2).toInt();
×
1122
            }
1123

1124
            VCWidget *childWidget = createWidget(cType, parent, subX, subY, func, type, fxGrpItem,
×
1125
                                                 channel, fxNr, headId);
1126
            if (childWidget != NULL)
×
1127
            {
1128
                if (childWidget->type() == VCWidget::SliderWidget)
×
1129
                    childWidget->setCaption(childItem->text(KWidgetName).split(" - ")[0]);
×
1130
                else
1131
                    childWidget->setCaption(childItem->text(KWidgetName));
×
1132

1133
                //qDebug() << childItem->text(KWidgetName);
1134
                //qDebug << "p:"<<parent->type() << " spin:" << m_lineCntSpin->value() << " per:" <<wPerLine << Qt::endl;
1135

1136
                if (childItem->childCount() > 0)
×
1137
                {
1138
                    childWidget->resize(QSize(2000, 1000));
×
1139
                    QSize size = recursiveCreateWidget(childItem, childWidget, type);
×
1140
                    childWidget->resize(size);
×
1141
                }
1142

1143
                if (subX + childWidget->width() > groupSize.width())
×
1144
                    groupSize.setWidth(subX + childWidget->width() + 10);
×
1145
                if (subY + childWidget->height() > groupSize.height())
×
1146
                    groupSize.setHeight(subY + childWidget->height() + 10);
×
1147

1148
                int wPerLine = parent->type() == VCWidget::SoloFrameWidget ? 4 : m_lineCntSpin->value();
×
1149
                if (c > 0 && (c + 1)%wPerLine == 0)
×
1150
                {
1151
                    subX = 10;
1152
                    subY += childWidget->height() + 10;
×
1153
                }
1154
                else
1155
                    subX += childWidget->width() + 10;
×
1156
            }
1157
        }
1158
    }
1159

1160
    return groupSize;
×
1161
}
1162

1163
void FunctionWizard::addWidgetsToVirtualConsole()
×
1164
{
1165
    int xPos = 10;
1166
    int yPos = 10;
1167

1168
    VirtualConsole *vc = VirtualConsole::instance();
×
1169
    VCFrame *mainFrame = vc->contents();
×
1170
    Q_ASSERT(mainFrame != NULL);
1171

1172
    for (int i = 0; i < m_widgetsTree->topLevelItemCount(); i++)
×
1173
    {
1174
        QTreeWidgetItem *wItem = m_widgetsTree->topLevelItem(i);
×
1175

1176
        if (wItem->checkState(KWidgetName) == Qt::Checked ||
×
1177
            wItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1178
        {
1179
            int wType = wItem->data(KWidgetName, Qt::UserRole).toInt();
×
1180
            VCWidget *widget = createWidget(wType, mainFrame, xPos, yPos);
×
1181
            if (widget == NULL)
×
1182
                continue;
×
1183

1184
            widget->resize(QSize(2000, 1000));
×
1185

1186
            int pType = 0;
1187
            if (!wItem->text(KWidgetName).contains("Channels"))
×
1188
            {
1189
                PaletteGenerator *pal = (PaletteGenerator *) wItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1190
                pType = pal->type();
×
1191
            }
1192

1193
            widget->setCaption(wItem->text(KWidgetName));
×
1194

1195
            QSize size = recursiveCreateWidget(wItem, widget, pType);
×
1196

1197
            widget->resize(size);
×
1198
            xPos += widget->width() + 10;
×
1199
        }
1200
    }
1201
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc