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

mcallegari / qlcplus / 7252848206

18 Dec 2023 07:26PM UTC coverage: 32.067% (+0.001%) from 32.066%
7252848206

push

github

mcallegari
Code style review #1427

199 of 628 new or added lines in 101 files covered. (31.69%)

8 existing lines in 2 files now uncovered.

15169 of 47304 relevant lines covered (32.07%)

23733.74 hits per line

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

0.0
/ui/src/showmanager/showmanager.cpp
1
/*
2
  Q Light Controller
3
  showmanager.cpp
4

5
  Copyright (C) Massimo Callegari
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 <QInputDialog>
21
#include <QColorDialog>
22
#include <QMessageBox>
23
#include <QFileDialog>
24
#include <QVBoxLayout>
25
#include <QMouseEvent>
26
#include <QScrollBar>
27
#include <QComboBox>
28
#include <QSplitter>
29
#include <QSettings>
30
#include <QToolBar>
31
#include <QSpinBox>
32
#include <QLabel>
33
#include <QDebug>
34
#include <QUrl>
35

36
#include "functionselection.h"
37
#include "audioplugincache.h"
38
#include "rgbmatrixeditor.h"
39
#include "multitrackview.h"
40
#include "chasereditor.h"
41
#include "audioeditor.h"
42
#include "efxeditor.h"
43
#include "videoeditor.h"
44
#include "showmanager.h"
45
#include "sceneeditor.h"
46
#include "timingstool.h"
47
#include "qlcmacros.h"
48
#include "sequence.h"
49
#include "chaser.h"
50

51
#define SETTINGS_HSPLITTER "showmanager/hsplitter"
52
#define SETTINGS_VSPLITTER "showmanager/vsplitter"
53

54
ShowManager* ShowManager::s_instance = NULL;
55

56
ShowManager::ShowManager(QWidget* parent, Doc* doc)
×
57
    : QWidget(parent)
58
    , m_doc(doc)
59
    , m_show(NULL)
60
    , m_currentTrack(NULL)
61
    , m_currentScene(NULL)
62
    , m_sceneEditor(NULL)
63
    , m_currentEditor(NULL)
64
    , m_editorFunctionID(Function::invalidId())
×
65
    , m_selectedShowIndex(-1)
66
    , m_splitter(NULL)
67
    , m_vsplitter(NULL)
68
    , m_showview(NULL)
69
    , m_toolbar(NULL)
70
    , m_showsCombo(NULL)
71
    , m_addShowAction(NULL)
72
    , m_addTrackAction(NULL)
73
    , m_addSequenceAction(NULL)
74
    , m_addAudioAction(NULL)
75
    , m_addVideoAction(NULL)
76
    , m_copyAction(NULL)
77
    , m_pasteAction(NULL)
78
    , m_deleteAction(NULL)
79
    , m_colorAction(NULL)
80
    , m_lockAction(NULL)
81
    , m_timingsAction(NULL)
82
    , m_snapGridAction(NULL)
83
    , m_stopAction(NULL)
84
    , m_playAction(NULL)
×
85
{
86
    Q_ASSERT(s_instance == NULL);
×
87
    s_instance = this;
×
88

89
    Q_ASSERT(doc != NULL);
×
90

91
    new QVBoxLayout(this);
×
92
    layout()->setContentsMargins(0, 0, 0, 0);
×
93
    layout()->setSpacing(0);
×
94

95
    initActions();
×
96
    initToolbar();
×
97

98
    m_splitter = new QSplitter(Qt::Vertical, this);
×
99
    layout()->addWidget(m_splitter);
×
100
    //initMultiTrackView();
101
    m_showview = new MultiTrackView();
×
102
    // add container for multitrack & function editors view
103
    QWidget* gcontainer = new QWidget(this);
×
104
    m_splitter->addWidget(gcontainer);
×
105
    gcontainer->setLayout(new QVBoxLayout);
×
106
    gcontainer->layout()->setContentsMargins(0, 0, 0, 0);
×
107

108
    m_showview->setRenderHint(QPainter::Antialiasing);
×
109
    m_showview->setAcceptDrops(true);
×
110
    m_showview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
×
111
    m_showview->setBackgroundBrush(QBrush(QColor(88, 88, 88, 255), Qt::SolidPattern));
×
NEW
112
    connect(m_showview, SIGNAL(viewClicked(QMouseEvent *)),
×
113
            this, SLOT(slotViewClicked(QMouseEvent *)));
114

115
    connect(m_showview, SIGNAL(showItemMoved(ShowItem*,quint32,bool)),
×
116
            this, SLOT(slotShowItemMoved(ShowItem*,quint32,bool)));
117
    connect(m_showview, SIGNAL(timeChanged(quint32)),
×
118
            this, SLOT(slotUpdateTime(quint32)));
119
    connect(m_showview, SIGNAL(trackClicked(Track*)),
×
120
            this, SLOT(slotTrackClicked(Track*)));
121
    connect(m_showview, SIGNAL(trackDoubleClicked(Track*)),
×
122
            this, SLOT(slotTrackDoubleClicked(Track*)));
123
    connect(m_showview, SIGNAL(trackMoved(Track*,int)),
×
124
            this, SLOT(slotTrackMoved(Track*,int)));
125
    connect(m_showview, SIGNAL(trackDelete(Track*)),
×
126
            this, SLOT(slotTrackDelete(Track*)));
127

128
    // split the multitrack view into two (left: tracks, right: function editors)
129
    m_vsplitter = new QSplitter(Qt::Horizontal, this);
×
130
    m_splitter->widget(0)->layout()->addWidget(m_vsplitter);
×
131
    QWidget* mcontainer = new QWidget(this);
×
132
    mcontainer->setLayout(new QHBoxLayout);
×
133
    mcontainer->layout()->setContentsMargins(0, 0, 0, 0);
×
134
    m_vsplitter->addWidget(mcontainer);
×
135
    m_vsplitter->widget(0)->layout()->addWidget(m_showview);
×
136

137
    // add container for function editors
138
    QWidget* ccontainer = new QWidget(this);
×
139
    m_vsplitter->addWidget(ccontainer);
×
140
    ccontainer->setLayout(new QVBoxLayout);
×
141
    ccontainer->layout()->setContentsMargins(0, 0, 0, 0);
×
142
    m_vsplitter->widget(1)->hide();
×
143

144
    // add container for scene editor
145
    QWidget* container = new QWidget(this);
×
146
    m_splitter->addWidget(container);
×
147
    container->setLayout(new QVBoxLayout);
×
148
    container->layout()->setContentsMargins(0, 0, 0, 0);
×
149
    m_splitter->widget(1)->hide();
×
150

151
    connect(m_doc, SIGNAL(clearing()), this, SLOT(slotDocClearing()));
×
152
    connect(m_doc, SIGNAL(functionRemoved(quint32)), this, SLOT(slotFunctionRemoved(quint32)));
×
153
    connect(m_doc, SIGNAL(loaded()), this, SLOT(slotDocLoaded()));
×
154

155
    QSettings settings;
×
156
    QVariant var = settings.value(SETTINGS_HSPLITTER);
×
157
    if (var.isValid() == true)
×
158
        m_splitter->restoreState(var.toByteArray());
×
159
    else
160
        m_splitter->setSizes(QList <int> () << int(this->width() / 2) << int(this->width() / 2));
×
161

162
    QVariant var2 = settings.value(SETTINGS_VSPLITTER);
×
163
    if (var2.isValid() == true)
×
164
        m_vsplitter->restoreState(var2.toByteArray());
×
165
    else
166
        m_vsplitter->setSizes(QList <int> () << int(this->width() / 2) << int(this->width() / 2));
×
167
}
×
168

169
ShowManager::~ShowManager()
×
170
{
171
    QSettings settings;
×
172
    settings.setValue(SETTINGS_HSPLITTER, m_splitter->saveState());
×
173
    settings.setValue(SETTINGS_VSPLITTER, m_vsplitter->saveState());
×
174

175
    ShowManager::s_instance = NULL;
×
176
}
×
177

178
ShowManager* ShowManager::instance()
×
179
{
180
    return s_instance;
×
181
}
182

183
void ShowManager::clearContents()
×
184
{
185
    hideRightEditor();
×
186
    showSceneEditor(NULL);
×
187
    m_showview->resetView();
×
188
    m_showsCombo->clear();
×
189
    m_show = NULL;
×
190
    m_currentScene = NULL;
×
191
    m_currentTrack = NULL;
×
192
}
×
193

194
void ShowManager::initActions()
×
195
{
196
    /* Manage actions */
197
    m_addShowAction = new QAction(QIcon(":/show.png"),
×
198
                                   tr("New s&how"), this);
×
199
    m_addShowAction->setShortcut(QKeySequence("CTRL+H"));
×
200
    connect(m_addShowAction, SIGNAL(triggered(bool)),
×
201
            this, SLOT(slotAddShow()));
202

203
    m_addTrackAction = new QAction(QIcon(":/edit_add.png"),
×
204
                                   tr("Add a &track or an existing function"), this);
×
205
    m_addTrackAction->setShortcut(QKeySequence("CTRL+N"));
×
206
    connect(m_addTrackAction, SIGNAL(triggered(bool)),
×
207
            this, SLOT(slotAddItem()));
208

209
    m_addSequenceAction = new QAction(QIcon(":/sequence.png"),
×
210
                                    tr("New s&equence"), this);
×
211
    m_addSequenceAction->setShortcut(QKeySequence("CTRL+E"));
×
212
    connect(m_addSequenceAction, SIGNAL(triggered(bool)),
×
213
            this, SLOT(slotAddSequence()));
214

215
    m_addAudioAction = new QAction(QIcon(":/audio.png"),
×
216
                                    tr("New &audio"), this);
×
217
    m_addAudioAction->setShortcut(QKeySequence("CTRL+A"));
×
218
    connect(m_addAudioAction, SIGNAL(triggered(bool)),
×
219
            this, SLOT(slotAddAudio()));
220

221
    m_addVideoAction = new QAction(QIcon(":/video.png"),
×
222
                                    tr("New vi&deo"), this);
×
223
    m_addVideoAction->setShortcut(QKeySequence("CTRL+D"));
×
224
    connect(m_addVideoAction, SIGNAL(triggered(bool)),
×
225
            this, SLOT(slotAddVideo()));
226

227
    /* Edit actions */
228
    m_copyAction = new QAction(QIcon(":/editcopy.png"),
×
229
                                tr("&Copy"), this);
×
230
    m_copyAction->setShortcut(QKeySequence("CTRL+C"));
×
231
    connect(m_copyAction, SIGNAL(triggered(bool)),
×
232
            this, SLOT(slotCopy()));
233
    m_copyAction->setEnabled(false);
×
234

235
    m_pasteAction = new QAction(QIcon(":/editpaste.png"),
×
236
                               tr("&Paste"), this);
×
237
    m_pasteAction->setShortcut(QKeySequence("CTRL+V"));
×
238
    connect(m_pasteAction, SIGNAL(triggered(bool)),
×
239
            this, SLOT(slotPaste()));
240
    m_pasteAction->setEnabled(false);
×
241

242
    m_deleteAction = new QAction(QIcon(":/editdelete.png"),
×
243
                                 tr("&Delete"), this);
×
244
    m_deleteAction->setShortcut(QKeySequence("Delete"));
×
245
    connect(m_deleteAction, SIGNAL(triggered(bool)),
×
246
            this, SLOT(slotDelete()));
247
    m_deleteAction->setEnabled(false);
×
248

249
    m_colorAction = new QAction(QIcon(":/color.png"),
×
250
                                tr("Change Co&lor"), this);
×
251
    m_colorAction->setShortcut(QKeySequence("CTRL+L"));
×
252
    connect(m_colorAction, SIGNAL(triggered(bool)),
×
253
           this, SLOT(slotChangeColor()));
254
    m_colorAction->setEnabled(false);
×
255

256
    m_lockAction = new QAction(QIcon(":/lock.png"),
×
257
                               tr("Lock item"), this);
×
258
    m_lockAction->setShortcut(QKeySequence("CTRL+K"));
×
259
    connect(m_lockAction, SIGNAL(triggered()),
×
260
            this, SLOT(slotChangeLock()));
261
    m_lockAction->setEnabled(false);
×
262

263
    m_timingsAction = new QAction(QIcon(":/speed.png"),
×
264
                                  tr("Item start time and duration"), this);
×
265
    m_timingsAction->setShortcut(QKeySequence("CTRL+T"));
×
266
    connect(m_timingsAction, SIGNAL(triggered()),
×
267
            this, SLOT(slotShowTimingsTool()));
268
    m_timingsAction->setEnabled(false);
×
269

270
    m_snapGridAction = new QAction(QIcon(":/grid.png"),
×
271
                                   tr("Snap to &Grid"), this);
×
272
    m_snapGridAction->setShortcut(QKeySequence("CTRL+G"));
×
273
    m_snapGridAction->setCheckable(true);
×
274
    connect(m_snapGridAction, SIGNAL(triggered(bool)),
×
275
           this, SLOT(slotToggleSnapToGrid(bool)));
276

277
    m_stopAction = new QAction(QIcon(":/player_stop.png"),
×
278
                                 tr("St&op"), this);
×
279
    m_stopAction->setShortcut(QKeySequence("CTRL+SPACE"));
×
280
    connect(m_stopAction, SIGNAL(triggered(bool)),
×
281
            this, SLOT(slotStopPlayback()));
282

283
    m_playAction = new QAction(QIcon(":/player_play.png"),
×
284
                                 tr("&Play"), this);
×
285
    m_playAction->setShortcut(QKeySequence("SPACE"));
×
286
    connect(m_playAction, SIGNAL(triggered(bool)),
×
287
            this, SLOT(slotStartPlayback()));
288
}
×
289

290
void ShowManager::initToolbar()
×
291
{
292
    // Add a toolbar to the dock area
293
    m_toolbar = new QToolBar("Show Manager", this);
×
294
    m_toolbar->setFloatable(false);
×
295
    m_toolbar->setMovable(false);
×
296
    layout()->addWidget(m_toolbar);
×
297
    m_toolbar->addAction(m_addShowAction);
×
298
    m_showsCombo = new QComboBox();
×
299
    m_showsCombo->setFixedWidth(250);
×
300
    m_showsCombo->setMaxVisibleItems(30);
×
301
    connect(m_showsCombo, SIGNAL(currentIndexChanged(int)),
×
302
            this, SLOT(slotShowsComboChanged(int)));
303
    m_toolbar->addWidget(m_showsCombo);
×
304
    m_toolbar->addSeparator();
×
305

306
    m_toolbar->addAction(m_addTrackAction);
×
307
    m_toolbar->addAction(m_addSequenceAction);
×
308
    m_toolbar->addAction(m_addAudioAction);
×
309
    m_toolbar->addAction(m_addVideoAction);
×
310

311
    m_toolbar->addSeparator();
×
312
    m_toolbar->addAction(m_copyAction);
×
313
    m_toolbar->addAction(m_pasteAction);
×
314
    m_toolbar->addAction(m_deleteAction);
×
315
    m_toolbar->addSeparator();
×
316

317
    m_toolbar->addAction(m_colorAction);
×
318
    m_toolbar->addAction(m_lockAction);
×
319
    m_toolbar->addAction(m_timingsAction);
×
320
    m_toolbar->addAction(m_snapGridAction);
×
321
    m_toolbar->addSeparator();
×
322

323
    // Time label and playback buttons
324
    m_timeLabel = new QLabel("00:00:00.00");
×
325
    m_timeLabel->setFixedWidth(150);
×
326
    m_timeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
×
327
    QFont timeFont = QApplication::font();
×
328
    timeFont.setBold(true);
×
329
    timeFont.setPixelSize(20);
×
330
    m_timeLabel->setFont(timeFont);
×
331
    m_toolbar->addWidget(m_timeLabel);
×
332
    m_toolbar->addSeparator();
×
333

334
    m_toolbar->addAction(m_stopAction);
×
335
    m_toolbar->addAction(m_playAction);
×
336

337
    /* Create an empty widget between help items to flush them to the right */
338
    QWidget* widget = new QWidget(this);
×
339
    widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
×
340
    m_toolbar->addWidget(widget);
×
341

342
    /* Add time division elements */
343
    QLabel* timeLabel = new QLabel(tr("Time division:"));
×
344
    m_toolbar->addWidget(timeLabel);
×
345

346
    m_timeDivisionCombo = new QComboBox();
×
347
    m_timeDivisionCombo->setFixedWidth(100);
×
348
    m_timeDivisionCombo->addItem(tr("Time"), Show::Time);
×
349
    m_timeDivisionCombo->addItem("BPM 4/4", Show::BPM_4_4);
×
350
    m_timeDivisionCombo->addItem("BPM 3/4", Show::BPM_3_4);
×
351
    m_timeDivisionCombo->addItem("BPM 2/4", Show::BPM_2_4);
×
352
    m_toolbar->addWidget(m_timeDivisionCombo);
×
353
    connect(m_timeDivisionCombo, SIGNAL(currentIndexChanged(int)),
×
354
            this, SLOT(slotTimeDivisionTypeChanged(int)));
355

356
    m_bpmField = new QSpinBox();
×
357
    m_bpmField->setFixedWidth(70);
×
358
    m_bpmField->setMinimum(10);
×
359
    m_bpmField->setMaximum(240);
×
360
    m_bpmField->setValue(120);
×
361
    m_bpmField->setEnabled(false);
×
362
    m_toolbar->addWidget(m_bpmField);
×
363
    connect(m_bpmField, SIGNAL(valueChanged(int)),
×
364
            this, SLOT(slotBPMValueChanged(int)));
365
}
×
366

367
/*********************************************************************
368
 * Shows combo
369
 *********************************************************************/
370
void ShowManager::updateShowsCombo()
×
371
{
372
    int oldIndex = m_showsCombo->currentIndex();
×
373

374
    // protect poor Show Manager from drawing all the shows
375
    disconnect(m_showsCombo, SIGNAL(currentIndexChanged(int)),
×
376
            this, SLOT(slotShowsComboChanged(int)));
377

378
    m_showsCombo->clear();
×
379
    foreach (Function* f, m_doc->functionsByType(Function::ShowType))
×
380
    {
381
        // Insert in ascii order
382
        int insertPosition = 0;
×
383
        while (insertPosition < m_showsCombo->count() &&
×
384
               QString::localeAwareCompare(m_showsCombo->itemText(insertPosition), f->name()) <= 0)
×
385
                    ++insertPosition;
×
386
        m_showsCombo->insertItem(insertPosition, f->name(), QVariant(f->id()));
×
387
    }
388
    if (m_showsCombo->count() > 0)
×
389
    {
390
        m_addTrackAction->setEnabled(true);
×
391
    }
392
    else
393
    {
394
        m_addTrackAction->setEnabled(false);
×
395
        m_addSequenceAction->setEnabled(false);
×
396
        m_addAudioAction->setEnabled(false);
×
397
        m_addVideoAction->setEnabled(false);
×
398
    }
399

400
    if (m_show == NULL || m_show->getTracksCount() == 0)
×
401
    {
402
        m_deleteAction->setEnabled(false);
×
403
        m_pasteAction->setEnabled(false);
×
404
    }
405
    else
406
    {
407
        if (m_doc->clipboard()->hasFunction())
×
408
            m_pasteAction->setEnabled(true);
×
409
        m_deleteAction->setEnabled(true);
×
410
    }
411

412
    connect(m_showsCombo, SIGNAL(currentIndexChanged(int)),
×
413
            this, SLOT(slotShowsComboChanged(int)));
414

415
    if (m_showsCombo->count() == 0)
×
416
    {
417
        m_showview->resetView();
×
418
        m_show = NULL;
×
419
        m_currentScene = NULL;
×
420
        m_currentTrack = NULL;
×
421
        return;
×
422
    }
423

424
    if (m_selectedShowIndex < 0 || m_selectedShowIndex >= m_showsCombo->count())
×
425
        m_selectedShowIndex = 0;
×
426

427
    m_showsCombo->setCurrentIndex(m_selectedShowIndex);
×
428

429
    if (oldIndex != m_selectedShowIndex)
×
430
        updateMultiTrackView();
×
431
}
432

433
void ShowManager::slotShowsComboChanged(int idx)
×
434
{
435
    qDebug() << Q_FUNC_INFO << "Idx: " << idx;
×
436
    if (m_selectedShowIndex != idx)
×
437
    {
438
        m_selectedShowIndex = idx;
×
439
        hideRightEditor();
×
440
        updateMultiTrackView();
×
441
    }
442
}
×
443

444
void ShowManager::showSceneEditor(Scene *scene)
×
445
{
446
    if (m_sceneEditor != NULL)
×
447
    {
448
        emit functionManagerActive(false);       
×
449
        m_splitter->widget(1)->layout()->removeWidget(m_sceneEditor);
×
450
        m_splitter->widget(1)->hide();
×
451
        delete m_sceneEditor;
×
452
        m_sceneEditor = NULL;
×
453
    }
454

455
    if (scene == NULL)
×
456
        return;
×
457

458
    if (this->isVisible())
×
459
    {
460
        m_sceneEditor = new SceneEditor(m_splitter->widget(1), scene, m_doc, false);
×
461
        if (m_sceneEditor != NULL)
×
462
        {
463
            m_splitter->widget(1)->layout()->addWidget(m_sceneEditor);
×
464
            m_splitter->widget(1)->show();
×
465

466
            connect(this, SIGNAL(functionManagerActive(bool)),
×
467
                    m_sceneEditor, SLOT(slotFunctionManagerActive(bool)));
×
468
        }
469
    }
470
}
471

472
void ShowManager::hideRightEditor()
×
473
{
474
    if (m_currentEditor != NULL)
×
475
    {
476
        m_vsplitter->widget(1)->layout()->removeWidget(m_currentEditor);
×
477
        m_vsplitter->widget(1)->hide();
×
478
        delete m_currentEditor;
×
479
        m_currentEditor = NULL;
×
480
        m_editorFunctionID = Function::invalidId();
×
481
    }
482
}
×
483

484
void ShowManager::showRightEditor(Function *function)
×
485
{
486
    if (function != NULL && m_editorFunctionID == function->id())
×
487
        return;
×
488

489
    hideRightEditor();
×
490

491
    if (function == NULL || this->isVisible() == false)
×
492
        return;
×
493

494
    if (function->type() == Function::ChaserType)
×
495
    {
496
        Chaser *chaser = qobject_cast<Chaser*> (function);
×
497
        m_currentEditor = new ChaserEditor(m_vsplitter->widget(1), chaser, m_doc);
×
498
        if (m_currentEditor != NULL)
×
499
        {
500
            connect(m_currentEditor, SIGNAL(stepSelectionChanged(int)),
×
501
                    this, SLOT(slotStepSelectionChanged(int)));
502
        }
503
    }
504
    else if (function->type() == Function::SequenceType)
×
505
    {
506
        Sequence *sequence = qobject_cast<Sequence*> (function);
×
507
        m_currentEditor = new ChaserEditor(m_vsplitter->widget(1), sequence, m_doc);
×
508
        if (m_currentEditor != NULL)
×
509
        {
510
            ChaserEditor *editor = qobject_cast<ChaserEditor*>(m_currentEditor);
×
511

512
            editor->showOrderAndDirection(false);
×
513

514
            /** Signal from chaser editor to scene editor.
515
             *  When a step is clicked apply values immediately */
516
            connect(m_currentEditor, SIGNAL(applyValues(QList<SceneValue>&)),
×
517
                    m_sceneEditor, SLOT(slotSetSceneValues(QList <SceneValue>&)));
×
518

519
            /** Signal from scene editor to chaser editor.
520
             *  When a fixture value is changed, update the selected chaser step */
521
            connect(m_sceneEditor, SIGNAL(fixtureValueChanged(SceneValue,bool)),
×
522
                    m_currentEditor, SLOT(slotUpdateCurrentStep(SceneValue,bool)));
×
523

524
            connect(m_currentEditor, SIGNAL(stepSelectionChanged(int)),
×
525
                    this, SLOT(slotStepSelectionChanged(int)));
526
        }
527
    }
528
    else if (function->type() == Function::AudioType)
×
529
    {
530
        m_currentEditor = new AudioEditor(m_vsplitter->widget(1), qobject_cast<Audio*> (function), m_doc);
×
531
    }
532
    else if (function->type() == Function::RGBMatrixType)
×
533
    {
534
        m_currentEditor = new RGBMatrixEditor(m_vsplitter->widget(1), qobject_cast<RGBMatrix*> (function), m_doc);
×
535
    }
536
    else if (function->type() == Function::EFXType)
×
537
    {
538
        m_currentEditor = new EFXEditor(m_vsplitter->widget(1), qobject_cast<EFX*> (function), m_doc);
×
539
    }
540
    else if (function->type() == Function::VideoType)
×
541
    {
542
        m_currentEditor = new VideoEditor(m_vsplitter->widget(1), qobject_cast<Video*> (function), m_doc);
×
543
    }
544
    else
545
        return;
×
546

547
    if (m_currentEditor != NULL)
×
548
    {
549
        m_vsplitter->widget(1)->layout()->addWidget(m_currentEditor);
×
550
        m_vsplitter->widget(1)->show();
×
551
        m_currentEditor->show();
×
552
        m_editorFunctionID = function->id();
×
553
    }
554

555
}
556

557
void ShowManager::slotAddShow()
×
558
{
559
    bool ok;
560
    QString defaultName = QString("%1 %2").arg(tr("New Show")).arg(m_doc->nextFunctionID());
×
561
    QString showName = QInputDialog::getText(this, tr("Show name setup"),
×
562
                                         tr("Show name:"), QLineEdit::Normal,
×
563
                                         defaultName, &ok);
×
564

565
    if (ok == true)
×
566
    {
567
        m_show = new Show(m_doc);
×
568
        if (showName.isEmpty() == false)
×
569
            m_show->setName(showName);
×
570
        else
571
            m_show->setName(defaultName);
×
572
        Function *f = qobject_cast<Function*>(m_show);
×
573
        if (m_doc->addFunction(f) == true)
×
574
        {
575
            // modify the new selected Show index
576
            int insertPosition = 0;
×
577
            while (insertPosition < m_showsCombo->count() &&
×
578
                    QString::localeAwareCompare(m_showsCombo->itemText(insertPosition), m_show->name()) <= 0)
×
579
                ++insertPosition;
×
580
            m_selectedShowIndex = insertPosition;
×
581
            updateShowsCombo();
×
582
            m_copyAction->setEnabled(false);
×
583
            if (m_doc->clipboard()->hasFunction())
×
584
                m_pasteAction->setEnabled(true);
×
585
            showSceneEditor(NULL);
×
586
            hideRightEditor();
×
587
            m_currentScene = NULL;
×
588
            m_currentTrack = NULL;
×
589
        }
590
    }
591
}
×
592

593
void ShowManager::slotAddItem()
×
594
{
595
    if (m_show == NULL)
×
596
        return;
×
597

598
    FunctionSelection fs(this, m_doc);
×
599
    // Forbid self-containment
600
    QList<quint32> disabledList;
×
601
    foreach (Function* function, m_doc->functions())
×
602
    {
603
        if (function->contains(m_show->id()))
×
604
            disabledList << function->id();
×
605
    }
606
    fs.setDisabledFunctions(disabledList);
×
607

608
    fs.setMultiSelection(false);
×
609
    fs.setFilter(Function::SceneType | Function::ChaserType | Function::SequenceType | Function::AudioType | Function::RGBMatrixType | Function::EFXType);
×
610
    fs.disableFilters(Function::ShowType | Function::ScriptType | Function::CollectionType);
×
611
    fs.showNewTrack(true);
×
612

613
    if (fs.exec() == QDialog::Accepted)
×
614
    {
615
        QList <quint32> ids = fs.selection();
×
616
        if (ids.count() == 0)
×
617
            return;
×
618
        quint32 selectedID = ids.first();
×
619

620
        /**
621
         * Here there are 8 cases:
622
         * 1) a new empty track
623
         * 2) an existing scene: create a new track with a 10 seconds Sequence
624
         * 3) an existing sequence
625
         *    3.1) append to an existing track
626
         *    3.2) create a new track bound to the Sequence's Scene ID
627
         * 4) an existing chaser
628
         *    4.1) append to the selected track
629
         *    4.3) create a new track
630
         * 5) an existing audio:
631
         *    5.1) append to the selected track
632
         *    5.2) create a new track
633
         * 6) an existing RGB Matrix:
634
         *    6.1) append to the selected track
635
         *    6.2) create a new track
636
         * 7) an existing EFX:
637
         *    7.1) append to the selected track
638
         *    7.2) create a new track
639
         * 8) an existing video:
640
         *    8.1) append to the selected track
641
         *    8.2) create a new track
642
         **/
643

644
        bool createTrack = false;
×
645
        quint32 newTrackBoundID = Function::invalidId();
×
646

647
        if (selectedID == Function::invalidId())
×
648
        {
649
            createTrack = true;
×
650
        }
651
        else
652
        {
653
            Function *selectedFunc = m_doc->function(selectedID);
×
654
            if (selectedFunc == NULL) // maybe a popup here ?
×
655
                return;
×
656

657
            /** 2) an existing scene */
658
            if (selectedFunc->type() == Function::SceneType)
×
659
            {
660
                m_currentScene = qobject_cast<Scene*>(selectedFunc);
×
661
                newTrackBoundID = selectedFunc->id();
×
662
                createTrack = true;
×
663
            }
664
            else if (selectedFunc->type() == Function::ChaserType)
×
665
            {
666
                /** 4.1) add chaser to the currently selected track */
667
                if (m_currentTrack != NULL)
×
668
                {
669
                    m_showview->addSequence(qobject_cast<Chaser*>(selectedFunc), m_currentTrack);
×
670
                    m_doc->setModified();
×
671
                    return;
×
672
                }
673
                /** 4.2) It is necessary to create a new track (below) */
674
                createTrack = true;
×
675
            }
676
            else if (selectedFunc->type() == Function::SequenceType)
×
677
            {
678
                Sequence *sequence = qobject_cast<Sequence*>(selectedFunc);
×
679
                quint32 chsSceneID = sequence->boundSceneID();
×
680
                foreach (Track *track, m_show->tracks())
×
681
                {
682
                    /** 3.1) append to an existing track */
683
                    if (track->getSceneID() == chsSceneID)
×
684
                    {
685
                        Sequence *newSequence = qobject_cast<Sequence*>(sequence->createCopy(m_doc, true));
×
686
                        newSequence->setName(sequence->name() + tr(" (Copy)"));
×
687
                        newSequence->setDirection(Function::Forward);
×
688
                        newSequence->setRunOrder(Function::SingleShot);
×
689
                        m_showview->addSequence(newSequence, track);
×
690
                        m_doc->setModified();
×
691
                        return;
×
692
                    }
693
                }
694
                /** 3.2) It is necessary to create a new track (below) */
695
                createTrack = true;
×
696
                newTrackBoundID = sequence->boundSceneID();
×
697
                m_currentScene = qobject_cast<Scene*>(m_doc->function(newTrackBoundID));
×
698
            }
699
            else if (selectedFunc->type() == Function::AudioType)
×
700
            {
701
                /** 5.1) add audio to the currently selected track */
702
                if (m_currentTrack != NULL)
×
703
                {
704
                    m_showview->addAudio(qobject_cast<Audio*>(selectedFunc), m_currentTrack);
×
705
                    m_doc->setModified();
×
706
                    return;
×
707
                }
708
                /** 5.2) It is necessary to create a new track (below) */
709
                createTrack = true;
×
710
            }
711
            else if (selectedFunc->type() == Function::RGBMatrixType)
×
712
            {
713
                /** 6.1) add RGB Matrix to the currently selected track */
714
                if (m_currentTrack != NULL)
×
715
                {
716
                    m_showview->addRGBMatrix(qobject_cast<RGBMatrix*>(selectedFunc), m_currentTrack);
×
717
                    m_doc->setModified();
×
718
                    return;
×
719
                }
720
                /** 6.2) It is necessary to create a new track (below) */
721
                createTrack = true;
×
722
            }
723
            else if (selectedFunc->type() == Function::EFXType)
×
724
            {
725
                /** 7.1) add EFX to the currently selected track */
726
                if (m_currentTrack != NULL)
×
727
                {
728
                    m_showview->addEFX(qobject_cast<EFX*>(selectedFunc), m_currentTrack);
×
729
                    m_doc->setModified();
×
730
                    return;
×
731
                }
732
                /** 7.2) It is necessary to create a new track (below) */
733
                createTrack = true;
×
734
            }
735
            else if (selectedFunc->type() == Function::VideoType)
×
736
            {
737
                /** 8.1) add video to the currently selected track */
738
                if (m_currentTrack != NULL)
×
739
                {
740
                    m_showview->addVideo(qobject_cast<Video*>(selectedFunc), m_currentTrack);
×
741
                    m_doc->setModified();
×
742
                    return;
×
743
                }
744
                /** 8.2) It is necessary to create a new track (below) */
745
                createTrack = true;
×
746
            }
747
        }
748

749
        if (createTrack == true)
×
750
        {
751
            Track* newTrack = new Track(newTrackBoundID);
×
752
            if (newTrackBoundID != Function::invalidId() && m_currentScene != NULL)
×
753
                newTrack->setName(m_currentScene->name());
×
754
            else
755
                newTrack->setName(tr("Track %1").arg(m_show->tracks().count() + 1));
×
756

757
            m_show->addTrack(newTrack);
×
758
            m_showview->addTrack(newTrack);
×
759
            m_currentTrack = newTrack;
×
760
            if (newTrackBoundID == Function::invalidId())
×
761
                m_currentScene = NULL;
×
762
            else
763
                m_currentScene = qobject_cast<Scene*>(m_doc->function(newTrackBoundID));
×
764
        }
765

766
        if (selectedID != Function::invalidId())
×
767
        {
768
            Function *selectedFunc = m_doc->function(selectedID);
×
769
            if (selectedFunc == NULL) // maybe a popup here ?
×
770
                return;
×
771

772
            /** 2) create a 10 seconds Sequence on the current track */
773
            if (selectedFunc->type() == Function::SceneType)
×
774
            {
775
                Function* f = new Sequence(m_doc);
×
776
                Sequence *sequence = qobject_cast<Sequence*> (f);
×
777
                sequence->setBoundSceneID(m_currentScene->id());
×
778
                if (m_doc->addFunction(f) == true)
×
779
                {
780
                    sequence->setDirection(Function::Forward);
×
781
                    sequence->setRunOrder(Function::SingleShot);
×
782
                    sequence->setDurationMode(Chaser::PerStep);
×
783
                    m_currentScene->setVisible(false);
×
784
                    f->setName(QString("%1 %2").arg(tr("New Sequence")).arg(f->id()));
×
785
                    m_showview->addSequence(sequence, m_currentTrack);
×
786
                    ChaserStep step(m_currentScene->id(), m_currentScene->fadeInSpeed(), 10000, m_currentScene->fadeOutSpeed());
×
787
                    step.note = QString();
×
788
                    step.values.append(m_currentScene->values());
×
789
                    sequence->addStep(step);
×
790
                }
791
            }
792
            else if (selectedFunc->type() == Function::ChaserType)
×
793
            {
794
                /** 4.2) add chaser to the new track */
795
                m_showview->addSequence(qobject_cast<Chaser*>(selectedFunc), m_currentTrack);
×
796
            }
797
            else if (selectedFunc->type() == Function::SequenceType)
×
798
            {
799
                /** 3.2) create a new Scene and bind a Sequence clone to it */
800
                Sequence *sequence = qobject_cast<Sequence*>(selectedFunc);
×
801
                Sequence *newSequence = qobject_cast<Sequence*>(sequence->createCopy(m_doc, true));
×
802
                newSequence->setName(sequence->name() + tr(" (Copy)"));
×
803
                newSequence->setDirection(Function::Forward);
×
804
                newSequence->setRunOrder(Function::SingleShot);
×
805
                m_showview->addSequence(newSequence, m_currentTrack);
×
806
            }
807
            else if (selectedFunc->type() == Function::AudioType)
×
808
            {
809
                /** 5.2) add audio to the new track */
810
                Audio *audio = qobject_cast<Audio*> (selectedFunc);
×
811
                m_showview->addAudio(audio, m_currentTrack);
×
812
            }
813
            else if (selectedFunc->type() == Function::RGBMatrixType)
×
814
            {
815
                /** 6.2) add RGBMatrix to the new track */
816
                RGBMatrix *rgbm = qobject_cast<RGBMatrix*> (selectedFunc);
×
817
                m_showview->addRGBMatrix(rgbm, m_currentTrack);
×
818
            }
819
            else if (selectedFunc->type() == Function::EFXType)
×
820
            {
821
                /** 7.2) add EFX to the new track */
822
                EFX *efx = qobject_cast<EFX*> (selectedFunc);
×
823
                m_showview->addEFX(efx, m_currentTrack);
×
824
            }
825
            else if (selectedFunc->type() == Function::VideoType)
×
826
            {
827
                /** 8.2) add video to the new track */
828
                Video *video = qobject_cast<Video*> (selectedFunc);
×
829
                m_showview->addVideo(video, m_currentTrack);
×
830
            }
831
        }
832
        m_doc->setModified();
×
833

834
        m_addSequenceAction->setEnabled(true);
×
835
        m_addAudioAction->setEnabled(true);
×
836
        m_addVideoAction->setEnabled(true);
×
837
        m_showview->activateTrack(m_currentTrack);
×
838
        m_deleteAction->setEnabled(true);
×
839
        m_showview->updateViewSize();
×
840
    }
841
}
842

843
void ShowManager::slotAddSequence()
×
844
{
845
    // Overlapping check
846
    if (checkOverlapping(m_showview->getTimeFromCursor(), 1000) == true)
×
847
    {
848
        QMessageBox::warning(this, tr("Overlapping error"), tr("Overlapping not allowed. Operation canceled."));
×
849
        return;
×
850
    }
851

852
    if (m_currentTrack->getSceneID() == Function::invalidId())
×
853
    {
854
        m_currentScene = new Scene(m_doc);
×
855
        m_currentScene->setVisible(false);
×
856

857
        if (m_doc->addFunction(m_currentScene))
×
858
            m_currentScene->setName(tr("Scene for %1 - Track %2").arg(m_show->name()).arg(m_currentTrack->id() + 1));
×
859
        m_currentTrack->setSceneID(m_currentScene->id());
×
860
    }
861

862
    Function* f = new Sequence(m_doc);
×
863
    Sequence *sequence = qobject_cast<Sequence*> (f);
×
864
    sequence->setBoundSceneID(m_currentScene->id());
×
865

866
    if (m_doc->addFunction(f) == true)
×
867
    {
868
        sequence->setRunOrder(Function::SingleShot);
×
869
        m_currentScene->setVisible(false);
×
870
        f->setName(QString("%1 %2").arg(tr("New Sequence")).arg(f->id()));
×
871
        showSceneEditor(m_currentScene);
×
872
        showRightEditor(f);
×
873
        m_showview->addSequence(sequence, m_currentTrack);
×
874
    }
875
}
876

877
void ShowManager::slotAddAudio()
×
878
{
879
    QString fn;
×
880

881
    /* Create a file open dialog */
882
    QFileDialog dialog(this);
×
883
    dialog.setWindowTitle(tr("Open Audio File"));
×
884
    dialog.setAcceptMode(QFileDialog::AcceptOpen);
×
885
    //dialog.selectFile(fileName());
886

887
    /* Append file filters to the dialog */
888
    QStringList extList = m_doc->audioPluginCache()->getSupportedFormats();
×
889

890
    QStringList filters;
×
891
    qDebug() << Q_FUNC_INFO << "Extensions: " << extList.join(" ");
×
892
    filters << tr("Audio Files (%1)").arg(extList.join(" "));
×
893
#if defined(WIN32) || defined(Q_OS_WIN)
894
    filters << tr("All Files (*.*)");
895
#else
896
    filters << tr("All Files (*)");
×
897
#endif
898
    dialog.setNameFilters(filters);
×
899

900
    /* Append useful URLs to the dialog */
901
    QList <QUrl> sidebar;
×
902
    sidebar.append(QUrl::fromLocalFile(QDir::homePath()));
×
903
    sidebar.append(QUrl::fromLocalFile(QDir::rootPath()));
×
904
    dialog.setSidebarUrls(sidebar);
×
905

906
    /* Get file name */
907
    if (dialog.exec() != QDialog::Accepted)
×
908
        return;
×
909

910
    fn = dialog.selectedFiles().first();
×
911
    if (fn.isEmpty() == true)
×
912
        return;
×
913

914
    Function* f = new Audio(m_doc);
×
915
    Audio *audio = qobject_cast<Audio*> (f);
×
916
    if (audio->setSourceFileName(fn) == false)
×
917
    {
918
        QMessageBox::warning(this, tr("Unsupported audio file"), tr("This audio file cannot be played with QLC+. Sorry."));
×
919
        delete f;
×
920
        return;
×
921
    }
922
    // Overlapping check
923
    if (checkOverlapping(m_showview->getTimeFromCursor(), audio->totalDuration()) == true)
×
924
    {
925
        QMessageBox::warning(this, tr("Overlapping error"), tr("Overlapping not allowed. Operation canceled."));
×
926
        delete f;
×
927
        return;
×
928
    }
929
    if (m_doc->addFunction(f) == true)
×
930
    {
931
        m_showview->addAudio(audio, m_currentTrack);
×
932
    }
933
}
934

935
void ShowManager::slotAddVideo()
×
936
{
937
    QString fn;
×
938

939
    /* Create a file open dialog */
940
    QFileDialog dialog(this);
×
941
    dialog.setWindowTitle(tr("Open Video File"));
×
942
    dialog.setAcceptMode(QFileDialog::AcceptOpen);
×
943
    //dialog.selectFile(fileName());
944

945
    /* Append file filters to the dialog */
946
    QStringList extList = Video::getVideoCapabilities();
×
947

948
    QStringList filters;
×
949
    qDebug() << Q_FUNC_INFO << "Extensions: " << extList.join(" ");
×
950
    filters << tr("Video Files (%1)").arg(extList.join(" "));
×
951
#if defined(WIN32) || defined(Q_OS_WIN)
952
    filters << tr("All Files (*.*)");
953
#else
954
    filters << tr("All Files (*)");
×
955
#endif
956
    dialog.setNameFilters(filters);
×
957

958
    /* Append useful URLs to the dialog */
959
    QList <QUrl> sidebar;
×
960
    sidebar.append(QUrl::fromLocalFile(QDir::homePath()));
×
961
    sidebar.append(QUrl::fromLocalFile(QDir::rootPath()));
×
962
    dialog.setSidebarUrls(sidebar);
×
963

964
    /* Get file name */
965
    if (dialog.exec() != QDialog::Accepted)
×
966
        return;
×
967

968
    fn = dialog.selectedFiles().first();
×
969
    if (fn.isEmpty() == true)
×
970
        return;
×
971

972
    Function* f = new Video(m_doc);
×
973
    Video *video = qobject_cast<Video*> (f);
×
974
    if (video->setSourceUrl(fn) == false)
×
975
    {
976
        QMessageBox::warning(this, tr("Unsupported video file"), tr("This video file cannot be played with QLC+. Sorry."));
×
977
        delete f;
×
978
        return;
×
979
    }
980
    // Overlapping check
981
    if (checkOverlapping(m_showview->getTimeFromCursor(), video->totalDuration()) == true)
×
982
    {
983
        QMessageBox::warning(this, tr("Overlapping error"), tr("Overlapping not allowed. Operation canceled."));
×
984
        delete f;
×
985
        return;
×
986
    }
987
    if (m_doc->addFunction(f) == true)
×
988
    {
989
        m_showview->addVideo(video, m_currentTrack);
×
990
    }
991
}
992

993
void ShowManager::slotCopy()
×
994
{
995
    ShowItem *item = m_showview->getSelectedItem();
×
996
    if (item != NULL)
×
997
    {
998
        Function* function = m_doc->function(item->functionID());
×
999
        Q_ASSERT(function != NULL);
×
1000

1001
        m_doc->clipboard()->copyContent(m_show->id(), function);
×
1002
        m_pasteAction->setEnabled(true);
×
1003
    }
1004
}
×
1005

1006
void ShowManager::slotPaste()
×
1007
{
1008
    if (m_doc->clipboard()->hasFunction() == false)
×
1009
        return;
×
1010

1011
    // Get the Function copy and add it to Doc
1012
    Function* clipboardCopy = m_doc->clipboard()->getFunction();
×
1013
    quint32 copyDuration = clipboardCopy->totalDuration();
×
1014

1015
    // Overlapping check
1016
    if (checkOverlapping(m_showview->getTimeFromCursor(), copyDuration) == true)
×
1017
    {
1018
        QMessageBox::warning(this, tr("Paste error"), tr("Overlapping paste not allowed. Operation canceled."));
×
1019
        return;
×
1020
    }
1021
    //qDebug() << "Check overlap... cursor time:" << cursorTime << "msec";
1022

1023
    if (clipboardCopy != NULL)
×
1024
    {
1025
        // copy the function again, to allow multiple copies of the same function
1026
        Function* newCopy = clipboardCopy->createCopy(m_doc, false);
×
1027
        if (newCopy == NULL)
×
1028
            return;
×
1029

1030
        if (clipboardCopy->type() == Function::ChaserType)
×
1031
        {
1032
            Chaser *chaser = qobject_cast<Chaser*>(newCopy);
×
1033

1034
            if (m_doc->addFunction(newCopy) == false)
×
1035
            {
1036
                delete newCopy;
×
1037
                return;
×
1038
            }
1039
            m_showview->addSequence(chaser, m_currentTrack);
×
1040
        }
1041
        else if (clipboardCopy->type() == Function::SequenceType)
×
1042
        {
1043
            Sequence *sequence = qobject_cast<Sequence*>(newCopy);
×
1044

1045
            if (m_currentScene == NULL)
×
1046
            {
1047
                // No scene on the current track -> copy it from source sequence
1048
                Scene* clipboardCopyScene = qobject_cast<Scene*>(m_doc->function(sequence->boundSceneID()));
×
1049
                if (clipboardCopyScene == NULL)
×
1050
                {
1051
                    delete newCopy;
×
1052
                    return;
×
1053
                }
1054
                Scene* newScene = static_cast<Scene*>(clipboardCopyScene->createCopy(m_doc, true));
×
1055
                if (newScene == NULL)
×
1056
                {
1057
                    delete newCopy;
×
1058
                    return;
×
1059
                }
1060
                m_currentScene = newScene;
×
1061
                m_currentTrack->setSceneID(m_currentScene->id());
×
1062
            }
1063
            else
1064
            {
1065
                // Verify the Chaser copy steps against the current Scene
NEW
1066
                foreach (ChaserStep cs, sequence->steps())
×
1067
                {
NEW
1068
                    foreach (SceneValue scv, cs.values)
×
1069
                    {
1070
                        if (m_currentScene->checkValue(scv) == false)
×
1071
                        {
1072
                            QMessageBox::warning(this, tr("Paste error"), tr("Trying to paste on an incompatible Scene. Operation canceled."));
×
1073
                            delete newCopy;
×
1074
                            return;
×
1075
                        }
1076
                    }
1077
                }
1078
            }
1079

1080
            // Bind the sequence to the track Scene ID
1081
            sequence->setBoundSceneID(m_currentScene->id());
×
1082

1083
            if (m_doc->addFunction(newCopy) == false)
×
1084
            {
1085
                delete newCopy;
×
1086
                return;
×
1087
            }
1088
            Track *track = m_currentTrack;
×
1089
            track = m_show->getTrackFromSceneID(m_currentScene->id());
×
1090
            m_showview->addSequence(sequence, track);
×
1091
        }
1092
        else if (clipboardCopy->type() == Function::AudioType)
×
1093
        {
1094
            if (m_doc->addFunction(newCopy) == false)
×
1095
            {
1096
                delete newCopy;
×
1097
                return;
×
1098
            }
1099
            Audio *audio = qobject_cast<Audio*>(newCopy);
×
1100
            m_showview->addAudio(audio, m_currentTrack);
×
1101
        }
1102
        else if (clipboardCopy->type() == Function::RGBMatrixType)
×
1103
        {
1104
            if (m_doc->addFunction(newCopy) == false)
×
1105
            {
1106
                delete newCopy;
×
1107
                return;
×
1108
            }
1109
            RGBMatrix *rgbm = qobject_cast<RGBMatrix*>(newCopy);
×
1110
            m_showview->addRGBMatrix(rgbm, m_currentTrack);
×
1111
        }
1112
        else if (clipboardCopy->type() == Function::EFXType)
×
1113
        {
1114
            if (m_doc->addFunction(newCopy) == false)
×
1115
            {
1116
                delete newCopy;
×
1117
                return;
×
1118
            }
1119
            EFX *efx = qobject_cast<EFX*>(newCopy);
×
1120
            m_showview->addEFX(efx, m_currentTrack);
×
1121
        }
1122
        else if (clipboardCopy->type() == Function::VideoType)
×
1123
        {
1124
            if (m_doc->addFunction(newCopy) == false)
×
1125
            {
1126
                delete newCopy;
×
1127
                return;
×
1128
            }
1129
            Video *video = qobject_cast<Video*>(newCopy);
×
1130
            m_showview->addVideo(video, m_currentTrack);
×
1131
        }
1132
        else if (clipboardCopy->type() == Function::SceneType)
×
1133
        {
1134
            if (m_doc->addFunction(newCopy) == false)
×
1135
            {
1136
                delete newCopy;
×
1137
                return;
×
1138
            }
1139
            m_currentScene = qobject_cast<Scene*>(newCopy);
×
1140
            Track* newTrack = new Track(m_currentScene->id());
×
1141
            newTrack->setName(m_currentScene->name());
×
1142
            m_show->addTrack(newTrack);
×
1143
            //showSceneEditor(m_currentScene);
1144
            m_showview->addTrack(newTrack);
×
1145
            m_addSequenceAction->setEnabled(true);
×
1146
            m_addAudioAction->setEnabled(true);
×
1147
            m_addVideoAction->setEnabled(true);
×
1148
            m_showview->activateTrack(newTrack);
×
1149
            m_deleteAction->setEnabled(true);
×
1150
            m_showview->updateViewSize();
×
1151
        }
1152
    }
1153
}
1154

1155
void ShowManager::slotDelete()
×
1156
{
1157
    // find out if we're deleting a show item or a track
1158
    bool isTrack = true;
×
1159
    ShowItem *selectedItem = m_showview->getSelectedItem();
×
1160
    if (selectedItem != NULL)
×
1161
        isTrack = false;
×
1162

1163
    // get the ID of the function to delete (invalidId if nothing was selected)
1164
    quint32 deleteID = m_showview->deleteSelectedItem();
×
1165
    if (deleteID != Function::invalidId())
×
1166
    {
1167
        if (isTrack == false)
×
1168
        {
1169
            if (m_currentTrack != NULL)
×
1170
            {
1171
                hideRightEditor();
×
1172
                showSceneEditor(NULL);
×
1173
                m_currentTrack->removeShowFunction(selectedItem->showFunction());
×
1174
            }
1175
        }
1176
        else
1177
        {
1178
            m_show->removeTrack(deleteID);
×
1179
            m_doc->setModified();
×
1180
            updateMultiTrackView();
×
1181
        }
1182
    }
1183
}
×
1184

1185
void ShowManager::slotStopPlayback()
×
1186
{
1187
    m_playAction->setIcon(QIcon(":/player_play.png"));
×
1188
    if (m_show != NULL && m_show->isRunning())
×
1189
    {
1190
        m_show->stop(functionParent());
×
1191
        return;
×
1192
    }
1193
    m_showview->rewindCursor();
×
1194
    m_timeLabel->setText("00:00:00.00");
×
1195
}
1196

1197
void ShowManager::slotStartPlayback()
×
1198
{
1199
    if (m_showsCombo->count() == 0 || m_show == NULL)
×
1200
        return;
×
1201

1202
    if (m_show->isRunning() == false)
×
1203
    {
1204
        m_show->start(m_doc->masterTimer(), functionParent(), m_showview->getTimeFromCursor());
×
1205
        m_playAction->setIcon(QIcon(":/player_pause.png"));
×
1206
    }
1207
    else
1208
    {
1209
        if (m_show->isPaused())
×
1210
        {
1211
            m_playAction->setIcon(QIcon(":/player_pause.png"));
×
1212
            m_show->setPause(false);
×
1213
        }
1214
        else
1215
        {
1216
            m_playAction->setIcon(QIcon(":/player_play.png"));
×
1217
            m_show->setPause(true);
×
1218
        }
1219
    }
1220
}
1221

1222
void ShowManager::slotShowStopped()
×
1223
{
1224
    slotUpdateTime(m_showview->getTimeFromCursor());
×
1225
}
×
1226

1227
void ShowManager::slotTimeDivisionTypeChanged(int idx)
×
1228
{
1229
    QVariant var = m_timeDivisionCombo->itemData(idx);
×
1230
    if (var.isValid())
×
1231
    {
1232
        m_showview->setHeaderType((Show::TimeDivision)var.toInt());
×
1233
        if (idx > 0)
×
1234
            m_bpmField->setEnabled(true);
×
1235
        else
1236
            m_bpmField->setEnabled(false);
×
1237
        if (m_show != NULL)
×
1238
            m_show->setTimeDivision((Show::TimeDivision)var.toInt(), m_bpmField->value());
×
1239
    }
1240
}
×
1241

1242
void ShowManager::slotBPMValueChanged(int value)
×
1243
{
1244
    m_showview->setBPMValue(value);
×
1245
    QVariant var = m_timeDivisionCombo->itemData(m_timeDivisionCombo->currentIndex());
×
1246
    if (var.isValid() && m_show != NULL)
×
1247
        m_show->setTimeDivision((Show::TimeDivision)var.toInt(), m_bpmField->value());
×
1248
}
×
1249

1250
void ShowManager::slotViewClicked(QMouseEvent *event)
×
1251
{
1252
    Q_UNUSED(event)
1253
    //qDebug() << Q_FUNC_INFO << "View clicked at pos: " << event->pos().x() << event->pos().y();
1254
    showSceneEditor(NULL);
×
1255
    hideRightEditor();
×
1256
    m_colorAction->setEnabled(false);
×
1257
    m_lockAction->setIcon(QIcon(":/lock.png"));
×
1258
    m_lockAction->setEnabled(false);
×
1259
    m_timingsAction->setEnabled(false);
×
1260
    if (m_show != NULL && m_show->getTracksCount() == 0)
×
1261
        m_deleteAction->setEnabled(false);
×
1262
}
×
1263

1264
void ShowManager::slotShowItemMoved(ShowItem *item, quint32 time, bool moved)
×
1265
{
1266
    if (item == NULL)
×
1267
        return;
×
1268

1269
    quint32 fid = item->functionID();
×
1270
    Function *f = m_doc->function(fid);
×
1271
    if (f == NULL)
×
1272
        return;
×
1273

1274
    Sequence *sequence = NULL;
×
1275

1276
    if (f->type() == Function::SequenceType)
×
1277
        sequence = qobject_cast<Sequence*>(f);
×
1278

1279
    if (sequence != NULL)
×
1280
    {
1281
        quint32 sceneID = sequence->boundSceneID();
×
1282
        Function *sf = m_doc->function(sceneID);
×
1283

1284
        if (sf == NULL)
×
1285
        {
1286
            // The bound Scene no longer exists. Invalidate the Sequence
1287
            sequence->setBoundSceneID(Function::invalidId());
×
1288
        }
1289
        else
1290
        {
1291
            Scene *boundScene = qobject_cast<Scene*>(sf);
×
1292

1293
            // if the clicked item represents another Sequence,
1294
            // destroy the Scene editor cause they might share
1295
            // the same bound Scene and Scene values might be overwritten
1296
            if (fid != m_editorFunctionID)
×
1297
                showSceneEditor(NULL);
×
1298

1299
            if (boundScene != m_currentScene || m_sceneEditor == NULL)
×
1300
            {
1301
                m_currentScene = boundScene;
×
1302
                showSceneEditor(m_currentScene);
×
1303
            }
1304

1305
            /* activate the new track */
1306
            m_currentTrack = m_show->getTrackFromSceneID(sceneID);
×
1307
            m_showview->activateTrack(m_currentTrack);
×
1308
            showRightEditor(f);
×
1309

1310
            if (m_currentEditor != NULL)
×
1311
            {
1312
                ChaserEditor *editor = qobject_cast<ChaserEditor*>(m_currentEditor);
×
1313
                editor->selectStepAtTime(time - item->getStartTime());
×
1314
            }
1315
        }
1316
    }
1317
    else
1318
    {
1319
        Track *track = m_show->tracks().at(item->getTrackIndex());
×
1320
        m_showview->activateTrack(track);
×
1321
        m_currentTrack = track;
×
1322
        m_currentScene = NULL;
×
1323
        showSceneEditor(NULL);
×
1324
        showRightEditor(f);
×
1325
    }
1326

1327
    m_copyAction->setEnabled(true);
×
1328
    m_deleteAction->setEnabled(true);
×
1329
    m_colorAction->setEnabled(true);
×
1330
    m_lockAction->setEnabled(true);
×
1331
    if (item->isLocked() == false)
×
1332
        m_lockAction->setIcon(QIcon(":/lock.png"));
×
1333
    else
1334
        m_lockAction->setIcon(QIcon(":/unlock.png"));
×
1335
    m_timingsAction->setEnabled(true);
×
1336

1337
    if (moved == true)
×
1338
        m_doc->setModified();
×
1339
}
1340

1341
void ShowManager::slotupdateTimeAndCursor(quint32 msec_time)
×
1342
{
1343
    //qDebug() << Q_FUNC_INFO << "time: " << msec_time;
1344
    slotUpdateTime(msec_time);
×
1345
    m_showview->moveCursor(msec_time);
×
1346
}
×
1347

1348
void ShowManager::slotUpdateTime(quint32 msec_time)
×
1349
{
1350
    uint h, m, s;
1351

1352
    h = msec_time / MS_PER_HOUR;
×
1353
    msec_time -= (h * MS_PER_HOUR);
×
1354

1355
    m = msec_time / MS_PER_MINUTE;
×
1356
    msec_time -= (m * MS_PER_MINUTE);
×
1357

1358
    s = msec_time / MS_PER_SECOND;
×
1359
    msec_time -= (s * MS_PER_SECOND);
×
1360

1361
    QString str;
×
1362
    if (m_show && m_show->isRunning())
×
1363
    {
1364
        str = QString("%1:%2:%3.%4").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0'))
×
1365
              .arg(s, 2, 10, QChar('0')).arg(msec_time / 100, 1, 10, QChar('0'));
×
1366
    }
1367
    else
1368
        str = QString("%1:%2:%3.%4").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0'))
×
1369
              .arg(s, 2, 10, QChar('0')).arg(msec_time / 10, 2, 10, QChar('0'));
×
1370

1371
    m_timeLabel->setText(str);
×
1372
}
×
1373

1374
void ShowManager::slotTrackClicked(Track *track)
×
1375
{
1376
    m_currentTrack = track;
×
1377
    if (track->getSceneID() == Function::invalidId())
×
1378
        m_currentScene = NULL;
×
1379
    else
1380
    {
1381
        Function *f = m_doc->function(track->getSceneID());
×
1382
        if (f != NULL)
×
1383
            m_currentScene = qobject_cast<Scene*>(f);
×
1384
    }
1385
    m_deleteAction->setEnabled(true);
×
1386
    m_copyAction->setEnabled(true);
×
1387
}
×
1388

1389
void ShowManager::slotTrackDoubleClicked(Track *track)
×
1390
{
1391
    bool ok;
1392
    QString currentName = track->name();
×
1393
    QString newTrackName = QInputDialog::getText(this, tr("Track name setup"),
×
1394
                                         tr("Track name:"), QLineEdit::Normal,
×
1395
                                         currentName, &ok);
×
1396

1397
    if (ok == true && newTrackName.isEmpty() == false)
×
1398
    {
1399
        track->setName(newTrackName);
×
1400
        int idx = m_show->getAttributeIndex(track->name());
×
1401
        m_show->renameAttribute(idx, track->name());
×
1402
    }
1403
}
×
1404

1405
void ShowManager::slotTrackMoved(Track *track, int direction)
×
1406
{
1407
    if (m_show != NULL)
×
1408
        m_show->moveTrack(track, direction);
×
1409
    updateMultiTrackView();
×
1410
    m_doc->setModified();
×
1411
}
×
1412

1413
void ShowManager::slotTrackDelete(Track *track)
×
1414
{
1415
    if (track == NULL)
×
1416
        return;
×
1417

1418
    quint32 deleteID = m_showview->deleteSelectedItem();
×
1419
    if (deleteID != Function::invalidId())
×
1420
    {
1421
        m_show->removeTrack(deleteID);
×
1422
        m_doc->setModified();
×
1423
        updateMultiTrackView();
×
1424
    }
1425
}
1426

1427
void ShowManager::slotChangeColor()
×
1428
{
1429
    ShowItem *item = m_showview->getSelectedItem();
×
1430
    if (item != NULL)
×
1431
    {
1432
        QColor color = item->getColor();
×
1433

1434
        color = QColorDialog::getColor(color);
×
1435
        if (!color.isValid())
×
1436
            return;
×
1437
        item->setColor(color);
×
1438
        return;
×
1439
    }
1440
}
1441

1442
void ShowManager::slotChangeLock()
×
1443
{
1444
    ShowItem *item = m_showview->getSelectedItem();
×
1445
    if (item != NULL)
×
1446
    {
1447
        if (item->isLocked() == false)
×
1448
            m_lockAction->setIcon(QIcon(":/unlock.png"));
×
1449
        else
1450
            m_lockAction->setIcon(QIcon(":/lock.png"));
×
1451
        item->setLocked(!item->isLocked());
×
1452
    }
1453
}
×
1454

1455
void ShowManager::slotShowTimingsTool()
×
1456
{
1457
    ShowItem *item = m_showview->getSelectedItem();
×
1458

1459
    if (item == NULL)
×
1460
        return;
×
1461

1462
    TimingsTool *tt = new TimingsTool(item, this);
×
1463

1464
    Function *func = m_doc->function(item->functionID());
×
1465
    if (func != NULL)
×
1466
    {
1467
        if (func->type() == Function::AudioType)
×
1468
            tt->showDurationControls(false);
×
1469
        if (func->type() == Function::RGBMatrixType || func->type() == Function::EFXType)
×
1470
            tt->showDurationOptions(true);
×
1471
    }
1472

1473
    connect(tt, SIGNAL(startTimeChanged(ShowItem*,int)),
×
1474
            this, SLOT(slotShowItemStartTimeChanged(ShowItem*,int)));
1475
    connect(tt, SIGNAL(durationChanged(ShowItem*,int,bool)),
×
1476
            this, SLOT(slotShowItemDurationChanged(ShowItem*,int,bool)));
1477
    tt->show();
×
1478
}
1479

1480
void ShowManager::slotShowItemStartTimeChanged(ShowItem *item, int msec)
×
1481
{
1482
    if (item == NULL)
×
1483
        return;
×
1484

1485
    if (item->isLocked() == false)
×
1486
    {
1487
        item->setStartTime(msec);
×
1488
        item->setPos(m_showview->getPositionFromTime(msec), item->y());
×
1489
        m_doc->setModified();
×
1490
    }
1491
}
1492

1493
void ShowManager::slotShowItemDurationChanged(ShowItem *item, int msec, bool stretch)
×
1494
{
1495
    if (item == NULL)
×
1496
        return;
×
1497

1498
    item->setDuration(msec, stretch);
×
1499
    m_doc->setModified();
×
1500
}
1501

1502
void ShowManager::slotToggleSnapToGrid(bool enable)
×
1503
{
1504
    m_showview->setSnapToGrid(enable);
×
1505
}
×
1506

1507
void ShowManager::slotChangeSize(int width, int height)
×
1508
{
1509
    if (m_showview != NULL)
×
1510
        m_showview->setViewSize(width, height);
×
1511
}
×
1512

1513
void ShowManager::slotStepSelectionChanged(int index)
×
1514
{
1515
    SequenceItem *seqItem = qobject_cast<SequenceItem*>(m_showview->getSelectedItem());
×
1516
    if (seqItem != NULL)
×
1517
        seqItem->setSelectedStep(index);
×
1518
}
×
1519

1520
void ShowManager::slotDocClearing()
×
1521
{
1522
    m_showsCombo->clear();
×
1523

1524
    if (m_showview != NULL)
×
1525
        m_showview->resetView();
×
1526

1527
    if (m_currentEditor != NULL)
×
1528
    {
1529
        m_vsplitter->widget(1)->layout()->removeWidget(m_currentEditor);
×
1530
        delete m_currentEditor;
×
1531
        m_currentEditor = NULL;
×
1532
    }
1533
    m_vsplitter->widget(1)->hide();
×
1534

1535
    if (m_sceneEditor != NULL)
×
1536
    {
1537
        emit functionManagerActive(false);
×
1538
        m_splitter->widget(1)->layout()->removeWidget(m_sceneEditor);
×
1539
        delete m_sceneEditor;
×
1540
        m_sceneEditor = NULL;
×
1541
    }
1542
    m_splitter->widget(1)->hide();
×
1543

1544
    m_addTrackAction->setEnabled(false);
×
1545
    m_addSequenceAction->setEnabled(false);
×
1546
    m_addAudioAction->setEnabled(false);
×
1547
    m_addVideoAction->setEnabled(false);
×
1548
    m_copyAction->setEnabled(false);
×
1549
    m_deleteAction->setEnabled(false);
×
1550
    m_colorAction->setEnabled(false);
×
1551
    m_timeLabel->setText("00:00:00.00");
×
1552
}
×
1553

1554
void ShowManager::slotDocLoaded()
×
1555
{
1556
    m_show = NULL;
×
1557
    m_currentScene = NULL;
×
1558
    m_currentTrack = NULL;
×
1559
    updateShowsCombo();
×
1560
}
×
1561

1562
void ShowManager::slotFunctionRemoved(quint32 id)
×
1563
{
1564
    if (m_showsCombo->count() == 0)
×
1565
        return;
×
1566

1567
    // check if ID is a Show
1568
    for (int i = 0; i < m_showsCombo->count(); i++)
×
1569
    {
1570
        quint32 showID = m_showsCombo->itemData(i).toUInt();
×
1571
        if (showID == id)
×
1572
        {
1573
            m_showsCombo->blockSignals(true);
×
1574
            m_showsCombo->removeItem(i);
×
1575

1576
            if (i == m_selectedShowIndex)
×
1577
            {
1578
                m_show = NULL;
×
1579
                m_selectedShowIndex = -1;
×
1580
                updateMultiTrackView();
×
1581
            }
1582
            m_showsCombo->blockSignals(false);
×
1583
            return;
×
1584
        }
1585
    }
1586

1587
    foreach (Function *function, m_doc->functionsByType(Function::ShowType))
×
1588
    {
1589
        Show *show = qobject_cast<Show*>(function);
×
NEW
1590
        foreach (Track *track, show->tracks())
×
1591
        {
1592
            foreach (ShowFunction *sf, track->showFunctions())
×
1593
            {
1594
                if (sf->functionID() == id)
×
1595
                    m_showview->deleteShowItem(track, sf);
×
1596
            }
1597

1598
            // check if the Function being removed is a Scene bound to a Track
1599
            if (track->getSceneID() == id)
×
1600
                track->setSceneID(Function::invalidId());
×
1601
        }
1602
    }
1603

1604
    if (m_currentScene != NULL && m_currentScene->id() == id)
×
1605
        m_currentScene = NULL;
×
1606

1607
    //if (isVisible())
1608
    //    updateMultiTrackView();
1609
}
1610

1611
void ShowManager::updateMultiTrackView()
×
1612
{
1613
    qDebug() << "[ShowManager] updateMultiTrackView...";
×
1614
    m_showview->resetView();
×
1615

1616
    /* first of all get the ID of the selected Show */
1617
    int idx = m_showsCombo->currentIndex();
×
1618
    if (idx == -1)
×
1619
        return;
×
1620
    quint32 showID = m_showsCombo->itemData(idx).toUInt();
×
1621

1622
    m_show = qobject_cast<Show *>(m_doc->function(showID));
×
1623
    if (m_show == NULL)
×
1624
    {
1625
        qDebug() << Q_FUNC_INFO << "Invalid show!";
×
1626
        return;
×
1627
    }
1628

1629
    // disconnect BPM field and update the view manually, to
1630
    // prevent m_show time division override
1631
    disconnect(m_bpmField, SIGNAL(valueChanged(int)), this, SLOT(slotBPMValueChanged(int)));
×
1632

1633
    m_bpmField->setValue(m_show->timeDivisionBPM());
×
1634
    m_showview->setBPMValue(m_show->timeDivisionBPM());
×
1635
    int tIdx = m_timeDivisionCombo->findData(QVariant(m_show->timeDivisionType()));
×
1636
    m_timeDivisionCombo->setCurrentIndex(tIdx);
×
1637

1638
    connect(m_bpmField, SIGNAL(valueChanged(int)), this, SLOT(slotBPMValueChanged(int)));
×
1639
    connect(m_show, SIGNAL(timeChanged(quint32)), this, SLOT(slotupdateTimeAndCursor(quint32)));
×
1640
    connect(m_show, SIGNAL(showFinished()), this, SLOT(slotStopPlayback()));
×
1641
    connect(m_show, SIGNAL(stopped(quint32)), this, SLOT(slotShowStopped()));
×
1642

1643
    Track *firstTrack = NULL;
×
1644

NEW
1645
    foreach (Track *track, m_show->tracks())
×
1646
    {
1647
        if (firstTrack == NULL)
×
1648
            firstTrack = track;
×
1649

1650
        quint32 boundSceneID = track->getSceneID();
×
1651
        if (boundSceneID != Function::invalidId())
×
1652
        {
1653
            Function *f = m_doc->function(boundSceneID);
×
1654
            if (f == NULL || f->type() != Function::SceneType)
×
1655
                track->setSceneID(Function::invalidId());
×
1656
        }
1657

1658
        m_showview->addTrack(track);
×
1659

NEW
1660
        foreach (ShowFunction *sf, track->showFunctions())
×
1661
        {
1662
            Function *fn = m_doc->function(sf->functionID());
×
1663
            if (fn != NULL)
×
1664
            {
1665
                if (fn->type() == Function::ChaserType)
×
1666
                {
1667
                    Chaser *chaser = qobject_cast<Chaser*>(fn);
×
1668
                    m_showview->addSequence(chaser, track, sf);
×
1669
                }
1670
                else if (fn->type() == Function::SequenceType)
×
1671
                {
1672
                    Sequence *sequence = qobject_cast<Sequence*>(fn);
×
1673
                    m_showview->addSequence(sequence, track, sf);
×
1674
                }
1675
                else if (fn->type() == Function::AudioType)
×
1676
                {
1677
                    Audio *audio = qobject_cast<Audio*>(fn);
×
1678
                    m_showview->addAudio(audio, track, sf);
×
1679
                }
1680
                else if (fn->type() == Function::RGBMatrixType)
×
1681
                {
1682
                    RGBMatrix *rgbm = qobject_cast<RGBMatrix*>(fn);
×
1683
                    m_showview->addRGBMatrix(rgbm, track, sf);
×
1684
                }
1685
                else if (fn->type() == Function::EFXType)
×
1686
                {
1687
                    EFX *efx = qobject_cast<EFX*>(fn);
×
1688
                    m_showview->addEFX(efx, track, sf);
×
1689
                }
1690
                else if (fn->type() == Function::VideoType)
×
1691
                {
1692
                    Video *video = qobject_cast<Video*>(fn);
×
1693
                    m_showview->addVideo(video, track, sf);
×
1694
                }
1695
            }
1696
        }
1697
    }
1698
    /** Set first track active */
1699
    if (firstTrack != NULL)
×
1700
    {
1701
        m_currentTrack = firstTrack;
×
1702
        if (m_currentTrack->getSceneID() != Function::invalidId())
×
1703
            m_currentScene = qobject_cast<Scene*>(m_doc->function(m_currentTrack->getSceneID()));
×
1704
        m_showview->activateTrack(m_currentTrack);
×
1705
        m_copyAction->setEnabled(true);
×
1706
        m_addSequenceAction->setEnabled(true);
×
1707
        m_addAudioAction->setEnabled(true);
×
1708
        m_addVideoAction->setEnabled(true);
×
1709
    }
1710
    else
1711
    {
1712
        m_addSequenceAction->setEnabled(false);
×
1713
        m_addAudioAction->setEnabled(false);
×
1714
        m_addVideoAction->setEnabled(false);
×
1715
        m_currentScene = NULL;
×
1716
        showSceneEditor(NULL);
×
1717
    }
1718
    if (m_doc->clipboard()->hasFunction())
×
1719
        m_pasteAction->setEnabled(true);
×
1720
    m_showview->updateViewSize();
×
1721
}
1722

1723
bool ShowManager::checkOverlapping(quint32 startTime, quint32 duration)
×
1724
{
1725
    if (m_currentTrack == NULL)
×
1726
        return false;
×
1727

NEW
1728
    foreach (ShowFunction *sf, m_currentTrack->showFunctions())
×
1729
    {
1730
        Function *func = m_doc->function(sf->functionID());
×
1731
        if (func != NULL)
×
1732
        {
1733
            quint32 fst = sf->startTime();
×
1734
            if ((startTime >= fst && startTime <= fst + sf->duration()) ||
×
1735
                (fst >= startTime && fst <= startTime + duration))
×
1736
            {
1737
                return true;
×
1738
            }
1739
        }
1740
    }
1741

1742
    return false;
×
1743
}
1744

1745
void ShowManager::showEvent(QShowEvent* ev)
×
1746
{
1747
    qDebug() << Q_FUNC_INFO;
×
1748
    emit functionManagerActive(true);
×
1749
    QWidget::showEvent(ev);
×
1750
    m_showview->show();
×
1751
    m_showview->horizontalScrollBar()->setSliderPosition(0);
×
1752
    m_showview->verticalScrollBar()->setSliderPosition(0);
×
1753
    updateShowsCombo();
×
1754
}
×
1755

1756
void ShowManager::hideEvent(QHideEvent* ev)
×
1757
{
1758
    qDebug() << Q_FUNC_INFO;
×
1759
    emit functionManagerActive(false);
×
1760
    QWidget::hideEvent(ev);
×
1761

1762
    if (m_currentEditor != NULL)
×
1763
    {
1764
        m_vsplitter->widget(1)->layout()->removeWidget(m_currentEditor);
×
1765
        m_vsplitter->widget(1)->hide();
×
1766
        delete m_currentEditor;
×
1767
        m_currentEditor = NULL;
×
1768
        m_editorFunctionID = Function::invalidId();
×
1769
    }
1770

1771
    if (m_sceneEditor != NULL)
×
1772
    {
1773
        m_splitter->widget(1)->layout()->removeWidget(m_sceneEditor);
×
1774
        m_splitter->widget(1)->hide();
×
1775
        delete m_sceneEditor;
×
1776
        m_sceneEditor = NULL;
×
1777
    }
1778

1779
    ShowItem *item = m_showview->getSelectedItem();
×
1780
    if (item != NULL)
×
1781
        item->setSelected(false);
×
1782
}
×
1783

1784
FunctionParent ShowManager::functionParent() const
×
1785
{
1786
    return FunctionParent::master();
×
1787
}
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