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

mcallegari / qlcplus / 12611701099

04 Jan 2025 03:35PM UTC coverage: 31.502%. Remained the same
12611701099

push

github

mcallegari
Fix function wizard code style

0 of 21 new or added lines in 1 file covered. (0.0%)

8 existing lines in 1 file now uncovered.

14091 of 44731 relevant lines covered (31.5%)

26824.16 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
        {
157
            m_nextButton->setEnabled(m_widgetsTree->topLevelItemCount() > 0);            
×
158
        }
159
        break;
×
160
        case 3:
×
161
            m_nextButton->setEnabled(false);
×
162
        break;
×
163
    }
164

165
    // enable VC Widget Page if tree not empty
166
    m_tabWidget->setTabEnabled(3, m_widgetsTree->topLevelItemCount() > 0);
×
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
        {
231
            updateAvailableFunctionsTree();
×
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
    
244
    updateWidgetsTree();
×
245
    checkTabsAndButtons();
×
246
}
×
247

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

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();
×
447
    updateWidgetsTree();
×
448

449
    checkTabsAndButtons();
×
450
}
×
451

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

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

462
    QTreeWidgetItem *item = new QTreeWidgetItem(grpItem);
×
463
    item->setText(KWidgetName, name );
×
464
    item->setCheckState(KWidgetName, Qt::Unchecked);
×
465
    item->setData(KWidgetName, Qt::UserRole, type);
×
466
    item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void*)fxGrpItem));
×
467
    item->setData(KWidgetName, Qt::UserRole + 2, QVariant::fromValue(channels[0]));
×
468
    item->setIcon(KWidgetName, VCWidget::typeToIcon(type));
×
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 panTiltChannels[4] = {};
×
NEW
482
    for (size_t i = 0; i < 4; i++)
×
NEW
483
        panTiltChannels[i] = channels[i];
×
484

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

487
    channels[0] = -1;
×
488
    channels[1] = -1;
×
489
    channels[2] = -1;
×
490
    channels[3] = -1;
×
491
}
492

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

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

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

505
    RGB[0] = -1;
506
    RGB[1] = -1;
507
    RGB[2] = -1;
508
}
509

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

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

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

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

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

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

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

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

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

606
    // Populate palette Widgets
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
697
    if (m_checkBoxAll->checkState() == 0 && m_checkBoxHeads->checkState() == 0 &&
×
698
        m_checkBoxFixtures->checkState() == 0)
×
699
        return;
700

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

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

709
        QTreeWidgetItem *frame = new QTreeWidgetItem(m_widgetsTree);
×
710
        frame->setText(KWidgetName, "Channels - " + fxGrpItem->text(KFixtureColumnName));
×
711
        frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
712
        frame->setData(KWidgetName, Qt::UserRole, VCWidget::FrameWidget);
×
713
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)NULL));
×
714
        frame->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
715
        frame->setCheckState(KWidgetName, Qt::Unchecked);
×
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
720
        QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
721
        quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
722
        Fixture* fxi = m_doc->fixture(fxID);
×
723
        Q_ASSERT(fxi != NULL);
724

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

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

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

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

747
        quint16 pageCount = 0;
UNCOV
748
        QString pageName = "%1 Pages - ";
×
749

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

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

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

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

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

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

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());
×
853
            cuelist->resize(QSize(300, m_sliderHeightSpin->value()));
×
854

855
            widget = cuelist;
856
        }
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
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
880
                int fxID = fxGrpItem->child(0)->data(KFixtureColumnName, Qt::UserRole).toInt();
×
881
                Fixture *fixture = m_doc->fixture(fxID);
×
882
                const QLCChannel *channel = fixture->channel(chan);
×
883

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1011
    return widget;
1012
}
1013

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

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

1023
        if (childItem->checkState(KWidgetName) == Qt::Checked ||
×
1024
            childItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1025
        {
1026
            int cType = childItem->data(KWidgetName, Qt::UserRole).toInt();
×
1027
            Function *func = NULL;
1028
            QTreeWidgetItem *fxGrpItem  = NULL;
1029
            quint32 channel = 0;
1030

NEW
1031
            if (type)
×
1032
            {
UNCOV
1033
                func = (Function *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1034
            }
1035
            else
1036
            {
1037
                fxGrpItem = (QTreeWidgetItem *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1038
                channel = childItem->data(KWidgetName, Qt::UserRole + 2).toUInt();
×
1039
            }
1040

1041
            if (childItem->text(KWidgetName).contains("Page"))
×
1042
            {
1043
                VCFrame *frame = (VCFrame *)parent;
1044
                frame->setMultipageMode(true);
×
1045

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

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

1077
                                QSize size = recursiveCreateWidget(childItem, parent, type);
×
1078
                                groupSize = childItem->parent()
×
1079
                                                ->data(KWidgetName, Qt::UserRole + 3)
×
1080
                                                .toSize();
×
1081

1082
                                if (size.width() > groupSize.width())
×
1083
                                    groupSize.setWidth(size.width());
1084
                                if (size.height() > groupSize.height())
×
1085
                                    groupSize.setHeight(size.height());
1086

1087
                                QString pageName = "";
×
1088
                                if (f >= 0)
×
1089
                                    pageName.append(QString("F%1").arg(f));
×
1090

1091
                                if (h >= 0)
×
1092
                                    pageName.append(QString("%1H%2").arg((f >= 0) ? "/" : "").arg(h));
×
1093

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

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

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

1124
                //qDebug() << childItem->text(KWidgetName);
1125
                //qDebug << "p:"<<parent->type() << " spin:" << m_lineCntSpin->value() << " per:" <<wPerLine << Qt::endl;
1126

1127
                if (childItem->childCount() > 0)
×
1128
                {
1129
                    childWidget->resize(QSize(2000, 1000));
×
UNCOV
1130
                    QSize size = recursiveCreateWidget(childItem, childWidget, type);
×
1131
                    childWidget->resize(size);
×
1132
                }
1133

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

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

1151
    return groupSize;
×
1152
}
1153

UNCOV
1154
void FunctionWizard::addWidgetsToVirtualConsole()
×
1155
{
1156
    int xPos = 10;
1157
    int yPos = 10;
1158

1159
    VirtualConsole *vc = VirtualConsole::instance();
×
1160
    VCFrame *mainFrame = vc->contents();
×
1161
    Q_ASSERT(mainFrame != NULL);
1162

1163
    for (int i = 0; i < m_widgetsTree->topLevelItemCount(); i++)
×
1164
    {
1165
        QTreeWidgetItem *wItem = m_widgetsTree->topLevelItem(i);
×
1166

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

1175
            widget->resize(QSize(2000, 1000));
×
1176

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

1184
            widget->setCaption(wItem->text(KWidgetName));
×
1185

1186
            QSize size = recursiveCreateWidget(wItem, widget, pType);
×
1187

1188
            widget->resize(size);
×
1189
            xPos += widget->width() + 10;
×
1190
        }
1191
    }
1192
}
×
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