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

mcallegari / qlcplus / 13633248611

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

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

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

0.0
/ui/src/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
    , cursorMovedDuringPause(false)
×
67
    , m_splitter(NULL)
×
68
    , m_vsplitter(NULL)
×
69
    , m_showview(NULL)
×
70
    , m_toolbar(NULL)
×
71
    , m_showsCombo(NULL)
×
72
    , m_addShowAction(NULL)
×
73
    , m_addTrackAction(NULL)
×
74
    , m_addSequenceAction(NULL)
×
75
    , m_addAudioAction(NULL)
×
76
    , m_addVideoAction(NULL)
×
77
    , m_copyAction(NULL)
×
78
    , m_pasteAction(NULL)
×
79
    , m_deleteAction(NULL)
×
80
    , m_colorAction(NULL)
×
81
    , m_lockAction(NULL)
×
82
    , m_timingsAction(NULL)
×
83
    , m_snapGridAction(NULL)
×
84
    , m_stopAction(NULL)
×
85
    , m_playAction(NULL)
×
86
{
87
    Q_ASSERT(s_instance == NULL);
88
    s_instance = this;
×
89

90
    Q_ASSERT(doc != NULL);
91

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

428
    m_showsCombo->setCurrentIndex(m_selectedShowIndex);
×
429

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

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

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

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

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

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

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

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

490
    hideRightEditor();
×
491

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

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

513
            editor->showOrderAndDirection(false);
×
514

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

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

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

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

556
}
557

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1203
    if (m_show->isRunning() == false)
×
1204
    {
1205
        cursorMovedDuringPause = false;
×
1206
        m_show->start(m_doc->masterTimer(), functionParent(), m_showview->getTimeFromCursor());
×
1207
        m_playAction->setIcon(QIcon(":/player_pause.png"));
×
1208
    }
1209
    else
1210
    {
1211
        if (m_show->isPaused())
×
1212
        {
1213
            m_playAction->setIcon(QIcon(":/player_pause.png"));
×
1214
            if (cursorMovedDuringPause)
×
1215
            {
1216
                m_show->stop(functionParent());
×
1217
                m_show->stopAndWait();
×
1218
                cursorMovedDuringPause = false;
×
1219
                m_show->start(m_doc->masterTimer(), functionParent(), m_showview->getTimeFromCursor());
×
1220
            }
1221
            else
1222
            {
1223
                m_show->setPause(false);
×
1224
            }
1225
        }
1226
        else
1227
        {
1228
            m_playAction->setIcon(QIcon(":/player_play.png"));
×
1229
            m_show->setPause(true);
×
1230
        }
1231
    }
1232
}
1233

1234
void ShowManager::slotShowStopped()
×
1235
{
1236
    slotUpdateTime(m_showview->getTimeFromCursor());
×
1237
}
×
1238

1239
void ShowManager::slotTimeDivisionTypeChanged(int idx)
×
1240
{
1241
    QVariant var = m_timeDivisionCombo->itemData(idx);
×
1242
    if (var.isValid())
×
1243
    {
1244
        m_showview->setHeaderType((Show::TimeDivision)var.toInt());
×
1245
        if (idx > 0)
×
1246
            m_bpmField->setEnabled(true);
×
1247
        else
1248
            m_bpmField->setEnabled(false);
×
1249
        if (m_show != NULL)
×
1250
            m_show->setTimeDivision((Show::TimeDivision)var.toInt(), m_bpmField->value());
×
1251
    }
1252
}
×
1253

1254
void ShowManager::slotBPMValueChanged(int value)
×
1255
{
1256
    m_showview->setBPMValue(value);
×
1257
    QVariant var = m_timeDivisionCombo->itemData(m_timeDivisionCombo->currentIndex());
×
1258
    if (var.isValid() && m_show != NULL)
×
1259
        m_show->setTimeDivision((Show::TimeDivision)var.toInt(), m_bpmField->value());
×
1260
}
×
1261

1262
void ShowManager::slotViewClicked(QMouseEvent *event)
×
1263
{
1264
    Q_UNUSED(event)
1265
    //qDebug() << Q_FUNC_INFO << "View clicked at pos: " << event->pos().x() << event->pos().y();
1266
    showSceneEditor(NULL);
×
1267
    hideRightEditor();
×
1268
    m_colorAction->setEnabled(false);
×
1269
    m_lockAction->setIcon(QIcon(":/lock.png"));
×
1270
    m_lockAction->setEnabled(false);
×
1271
    m_timingsAction->setEnabled(false);
×
1272
    if (m_show != NULL && m_show->getTracksCount() == 0)
×
1273
        m_deleteAction->setEnabled(false);
×
1274
}
×
1275

1276
void ShowManager::slotShowItemMoved(ShowItem *item, quint32 time, bool moved)
×
1277
{
1278
    if (item == NULL)
×
1279
        return;
1280

1281
    quint32 fid = item->functionID();
×
1282
    Function *f = m_doc->function(fid);
×
1283
    if (f == NULL)
×
1284
        return;
1285

1286
    Sequence *sequence = NULL;
1287

1288
    if (f->type() == Function::SequenceType)
×
1289
        sequence = qobject_cast<Sequence*>(f);
1290

1291
    if (sequence != NULL)
×
1292
    {
1293
        quint32 sceneID = sequence->boundSceneID();
×
1294
        Function *sf = m_doc->function(sceneID);
×
1295

1296
        if (sf == NULL)
×
1297
        {
1298
            // The bound Scene no longer exists. Invalidate the Sequence
1299
            sequence->setBoundSceneID(Function::invalidId());
×
1300
        }
1301
        else
1302
        {
1303
            Scene *boundScene = qobject_cast<Scene*>(sf);
1304

1305
            // if the clicked item represents another Sequence,
1306
            // destroy the Scene editor cause they might share
1307
            // the same bound Scene and Scene values might be overwritten
1308
            if (fid != m_editorFunctionID)
×
1309
                showSceneEditor(NULL);
×
1310

1311
            if (boundScene != m_currentScene || m_sceneEditor == NULL)
×
1312
            {
1313
                m_currentScene = boundScene;
×
1314
                showSceneEditor(m_currentScene);
×
1315
            }
1316

1317
            /* activate the new track */
1318
            m_currentTrack = m_show->getTrackFromSceneID(sceneID);
×
1319
            m_showview->activateTrack(m_currentTrack);
×
1320
            showRightEditor(f);
×
1321

1322
            if (m_currentEditor != NULL)
×
1323
            {
1324
                ChaserEditor *editor = qobject_cast<ChaserEditor*>(m_currentEditor);
1325
                editor->selectStepAtTime(time - item->getStartTime());
×
1326
            }
1327
        }
1328
    }
1329
    else
1330
    {
1331
        Track *track = m_show->tracks().at(item->getTrackIndex());
×
1332
        m_showview->activateTrack(track);
×
1333
        m_currentTrack = track;
×
1334
        m_currentScene = NULL;
×
1335
        showSceneEditor(NULL);
×
1336
        showRightEditor(f);
×
1337
    }
1338

1339
    m_copyAction->setEnabled(true);
×
1340
    m_deleteAction->setEnabled(true);
×
1341
    m_colorAction->setEnabled(true);
×
1342
    m_lockAction->setEnabled(true);
×
1343
    if (item->isLocked() == false)
×
1344
        m_lockAction->setIcon(QIcon(":/lock.png"));
×
1345
    else
1346
        m_lockAction->setIcon(QIcon(":/unlock.png"));
×
1347
    m_timingsAction->setEnabled(true);
×
1348

1349
    if (moved == true)
×
1350
        m_doc->setModified();
×
1351
}
1352

1353
void ShowManager::slotUpdateTimeAndCursor(quint32 msec_time)
×
1354
{
1355
    //qDebug() << Q_FUNC_INFO << "time: " << msec_time;
1356
    slotUpdateTime(msec_time);
×
1357
    m_showview->moveCursor(msec_time);
×
1358
}
×
1359

1360
void ShowManager::slotUpdateTime(quint32 msec_time)
×
1361
{
1362
    uint h, m, s;
1363

1364
    h = msec_time / MS_PER_HOUR;
×
1365
    msec_time -= (h * MS_PER_HOUR);
1366

1367
    m = msec_time / MS_PER_MINUTE;
×
1368
    msec_time -= (m * MS_PER_MINUTE);
1369

1370
    s = msec_time / MS_PER_SECOND;
×
1371
    msec_time -= (s * MS_PER_SECOND);
1372

1373
    QString str;
1374
    if (m_show && m_show->isRunning())
×
1375
    {
1376
        str = QString("%1:%2:%3.%4").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0'))
×
1377
              .arg(s, 2, 10, QChar('0')).arg(msec_time / 100, 1, 10, QChar('0'));
×
1378
    }
1379
    else
1380
        str = QString("%1:%2:%3.%4").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0'))
×
1381
              .arg(s, 2, 10, QChar('0')).arg(msec_time / 10, 2, 10, QChar('0'));
×
1382

1383
    m_timeLabel->setText(str);
×
1384

1385
    if (m_show != NULL && m_show->isPaused())
×
1386
        cursorMovedDuringPause = true;
×
1387
}
×
1388

1389
void ShowManager::slotTrackClicked(Track *track)
×
1390
{
1391
    m_currentTrack = track;
×
1392
    if (track->getSceneID() == Function::invalidId())
×
1393
        m_currentScene = NULL;
×
1394
    else
1395
    {
1396
        Function *f = m_doc->function(track->getSceneID());
×
1397
        if (f != NULL)
×
1398
            m_currentScene = qobject_cast<Scene*>(f);
×
1399
    }
1400
    m_deleteAction->setEnabled(true);
×
1401
    m_copyAction->setEnabled(true);
×
1402
}
×
1403

1404
void ShowManager::slotTrackDoubleClicked(Track *track)
×
1405
{
1406
    bool ok;
1407
    QString currentName = track->name();
×
1408
    QString newTrackName = QInputDialog::getText(this, tr("Track name setup"),
×
1409
                                         tr("Track name:"), QLineEdit::Normal,
×
1410
                                         currentName, &ok);
×
1411

1412
    if (ok == true && newTrackName.isEmpty() == false)
×
1413
    {
1414
        track->setName(newTrackName);
×
1415
        int idx = m_show->getAttributeIndex(track->name());
×
1416
        m_show->renameAttribute(idx, track->name());
×
1417
    }
1418
}
×
1419

1420
void ShowManager::slotTrackMoved(Track *track, int direction)
×
1421
{
1422
    if (m_show != NULL)
×
1423
        m_show->moveTrack(track, direction);
×
1424
    updateMultiTrackView();
×
1425
    m_doc->setModified();
×
1426
}
×
1427

1428
void ShowManager::slotTrackDelete(Track *track)
×
1429
{
1430
    if (track == NULL)
×
1431
        return;
1432

1433
    quint32 deleteID = m_showview->deleteSelectedItem();
×
1434
    if (deleteID != Function::invalidId())
×
1435
    {
1436
        m_show->removeTrack(deleteID);
×
1437
        m_doc->setModified();
×
1438
        updateMultiTrackView();
×
1439
    }
1440
}
1441

1442
void ShowManager::slotChangeColor()
×
1443
{
1444
    ShowItem *item = m_showview->getSelectedItem();
×
1445
    if (item != NULL)
×
1446
    {
1447
        QColor color = item->getColor();
×
1448

1449
        color = QColorDialog::getColor(color);
×
1450
        if (!color.isValid())
×
1451
            return;
1452
        item->setColor(color);
×
1453
        return;
×
1454
    }
1455
}
1456

1457
void ShowManager::slotChangeLock()
×
1458
{
1459
    ShowItem *item = m_showview->getSelectedItem();
×
1460
    if (item != NULL)
×
1461
    {
1462
        if (item->isLocked() == false)
×
1463
            m_lockAction->setIcon(QIcon(":/unlock.png"));
×
1464
        else
1465
            m_lockAction->setIcon(QIcon(":/lock.png"));
×
1466
        item->setLocked(!item->isLocked());
×
1467
    }
1468
}
×
1469

1470
void ShowManager::slotShowTimingsTool()
×
1471
{
1472
    ShowItem *item = m_showview->getSelectedItem();
×
1473

1474
    if (item == NULL)
×
1475
        return;
1476

1477
    TimingsTool *tt = new TimingsTool(item, this);
×
1478

1479
    Function *func = m_doc->function(item->functionID());
×
1480
    if (func != NULL)
×
1481
    {
1482
        if (func->type() == Function::AudioType)
×
1483
            tt->showDurationControls(false);
×
1484
        if (func->type() == Function::RGBMatrixType || func->type() == Function::EFXType)
×
1485
            tt->showDurationOptions(true);
×
1486
    }
1487

1488
    connect(tt, SIGNAL(startTimeChanged(ShowItem*,int)),
×
1489
            this, SLOT(slotShowItemStartTimeChanged(ShowItem*,int)));
1490
    connect(tt, SIGNAL(durationChanged(ShowItem*,int,bool)),
×
1491
            this, SLOT(slotShowItemDurationChanged(ShowItem*,int,bool)));
1492
    tt->show();
×
1493
}
1494

1495
void ShowManager::slotShowItemStartTimeChanged(ShowItem *item, int msec)
×
1496
{
1497
    if (item == NULL)
×
1498
        return;
1499

1500
    if (item->isLocked() == false)
×
1501
    {
1502
        item->setStartTime(msec);
×
1503
        item->setPos(m_showview->getPositionFromTime(msec), item->y());
×
1504
        m_doc->setModified();
×
1505
    }
1506
}
1507

1508
void ShowManager::slotShowItemDurationChanged(ShowItem *item, int msec, bool stretch)
×
1509
{
1510
    if (item == NULL)
×
1511
        return;
1512

1513
    item->setDuration(msec, stretch);
×
1514
    m_doc->setModified();
×
1515
}
1516

1517
void ShowManager::slotToggleSnapToGrid(bool enable)
×
1518
{
1519
    m_showview->setSnapToGrid(enable);
×
1520
}
×
1521

1522
void ShowManager::slotChangeSize(int width, int height)
×
1523
{
1524
    if (m_showview != NULL)
×
1525
        m_showview->setViewSize(width, height);
×
1526
}
×
1527

1528
void ShowManager::slotStepSelectionChanged(int index)
×
1529
{
1530
    SequenceItem *seqItem = qobject_cast<SequenceItem*>(m_showview->getSelectedItem());
×
1531
    if (seqItem != NULL)
×
1532
        seqItem->setSelectedStep(index);
×
1533
}
×
1534

1535
void ShowManager::slotDocClearing()
×
1536
{
1537
    m_showsCombo->clear();
×
1538

1539
    if (m_showview != NULL)
×
1540
        m_showview->resetView();
×
1541

1542
    if (m_currentEditor != NULL)
×
1543
    {
1544
        m_vsplitter->widget(1)->layout()->removeWidget(m_currentEditor);
×
1545
        delete m_currentEditor;
×
1546
        m_currentEditor = NULL;
×
1547
    }
1548
    m_vsplitter->widget(1)->hide();
×
1549

1550
    if (m_sceneEditor != NULL)
×
1551
    {
1552
        emit functionManagerActive(false);
×
1553
        m_splitter->widget(1)->layout()->removeWidget(m_sceneEditor);
×
1554
        delete m_sceneEditor;
×
1555
        m_sceneEditor = NULL;
×
1556
    }
1557
    m_splitter->widget(1)->hide();
×
1558

1559
    m_addTrackAction->setEnabled(false);
×
1560
    m_addSequenceAction->setEnabled(false);
×
1561
    m_addAudioAction->setEnabled(false);
×
1562
    m_addVideoAction->setEnabled(false);
×
1563
    m_copyAction->setEnabled(false);
×
1564
    m_deleteAction->setEnabled(false);
×
1565
    m_colorAction->setEnabled(false);
×
1566
    m_timeLabel->setText("00:00:00.00");
×
1567
}
×
1568

1569
void ShowManager::slotDocLoaded()
×
1570
{
1571
    m_show = NULL;
×
1572
    m_currentScene = NULL;
×
1573
    m_currentTrack = NULL;
×
1574
    updateShowsCombo();
×
1575
}
×
1576

1577
void ShowManager::slotFunctionRemoved(quint32 id)
×
1578
{
1579
    if (m_showsCombo->count() == 0)
×
1580
        return;
1581

1582
    // check if ID is a Show
1583
    for (int i = 0; i < m_showsCombo->count(); i++)
×
1584
    {
1585
        quint32 showID = m_showsCombo->itemData(i).toUInt();
×
1586
        if (showID == id)
×
1587
        {
1588
            m_showsCombo->blockSignals(true);
×
1589
            m_showsCombo->removeItem(i);
×
1590

1591
            if (i == m_selectedShowIndex)
×
1592
            {
1593
                m_show = NULL;
×
1594
                m_selectedShowIndex = -1;
×
1595
                updateMultiTrackView();
×
1596
            }
1597
            m_showsCombo->blockSignals(false);
×
1598
            return;
×
1599
        }
1600
    }
1601

1602
    foreach (Function *function, m_doc->functionsByType(Function::ShowType))
×
1603
    {
1604
        Show *show = qobject_cast<Show*>(function);
1605
        foreach (Track *track, show->tracks())
×
1606
        {
1607
            foreach (ShowFunction *sf, track->showFunctions())
×
1608
            {
1609
                if (sf->functionID() == id)
×
1610
                    m_showview->deleteShowItem(track, sf);
×
1611
            }
1612

1613
            // check if the Function being removed is a Scene bound to a Track
1614
            if (track->getSceneID() == id)
×
1615
                track->setSceneID(Function::invalidId());
×
1616
        }
1617
    }
1618

1619
    if (m_currentScene != NULL && m_currentScene->id() == id)
×
1620
        m_currentScene = NULL;
×
1621

1622
    //if (isVisible())
1623
    //    updateMultiTrackView();
1624
}
1625

1626
void ShowManager::updateMultiTrackView()
×
1627
{
1628
    qDebug() << "[ShowManager] updateMultiTrackView...";
1629
    m_showview->resetView();
×
1630

1631
    /* first of all get the ID of the selected Show */
1632
    int idx = m_showsCombo->currentIndex();
×
1633
    if (idx == -1)
×
1634
        return;
1635
    quint32 showID = m_showsCombo->itemData(idx).toUInt();
×
1636

1637
    m_show = qobject_cast<Show *>(m_doc->function(showID));
×
1638
    if (m_show == NULL)
×
1639
    {
1640
        qDebug() << Q_FUNC_INFO << "Invalid show!";
1641
        return;
1642
    }
1643

1644
    // disconnect BPM field and update the view manually, to
1645
    // prevent m_show time division override
1646
    disconnect(m_bpmField, SIGNAL(valueChanged(int)), this, SLOT(slotBPMValueChanged(int)));
×
1647

1648
    m_bpmField->setValue(m_show->timeDivisionBPM());
×
1649
    m_showview->setBPMValue(m_show->timeDivisionBPM());
×
1650
    int tIdx = m_timeDivisionCombo->findData(QVariant(m_show->timeDivisionType()));
×
1651
    m_timeDivisionCombo->setCurrentIndex(tIdx);
×
1652

1653
    connect(m_bpmField, SIGNAL(valueChanged(int)), this, SLOT(slotBPMValueChanged(int)));
×
1654
    connect(m_show, SIGNAL(timeChanged(quint32)), this, SLOT(slotUpdateTimeAndCursor(quint32)));
×
1655
    connect(m_show, SIGNAL(showFinished()), this, SLOT(slotStopPlayback()));
×
1656
    connect(m_show, SIGNAL(stopped(quint32)), this, SLOT(slotShowStopped()));
×
1657

1658
    Track *firstTrack = NULL;
1659

1660
    foreach (Track *track, m_show->tracks())
×
1661
    {
1662
        if (firstTrack == NULL)
×
1663
            firstTrack = track;
1664

1665
        quint32 boundSceneID = track->getSceneID();
×
1666
        if (boundSceneID != Function::invalidId())
×
1667
        {
1668
            Function *f = m_doc->function(boundSceneID);
×
1669
            if (f == NULL || f->type() != Function::SceneType)
×
1670
                track->setSceneID(Function::invalidId());
×
1671
        }
1672

1673
        m_showview->addTrack(track);
×
1674

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

1738
bool ShowManager::checkOverlapping(quint32 startTime, quint32 duration)
×
1739
{
1740
    if (m_currentTrack == NULL)
×
1741
        return false;
1742

1743
    foreach (ShowFunction *sf, m_currentTrack->showFunctions())
×
1744
    {
1745
        Function *func = m_doc->function(sf->functionID());
×
1746
        if (func != NULL)
×
1747
        {
1748
            quint32 fst = sf->startTime();
×
1749
            if ((startTime >= fst && startTime <= fst + sf->duration()) ||
×
1750
                (fst >= startTime && fst <= startTime + duration))
×
1751
            {
1752
                return true;
1753
            }
1754
        }
1755
    }
1756

1757
    return false;
×
1758
}
1759

1760
void ShowManager::showEvent(QShowEvent* ev)
×
1761
{
1762
    qDebug() << Q_FUNC_INFO;
1763
    emit functionManagerActive(true);
×
1764
    QWidget::showEvent(ev);
×
1765
    m_showview->show();
×
1766
    m_showview->horizontalScrollBar()->setSliderPosition(0);
×
1767
    m_showview->verticalScrollBar()->setSliderPosition(0);
×
1768
    updateShowsCombo();
×
1769
}
×
1770

1771
void ShowManager::hideEvent(QHideEvent* ev)
×
1772
{
1773
    qDebug() << Q_FUNC_INFO;
1774
    emit functionManagerActive(false);
×
1775
    QWidget::hideEvent(ev);
×
1776

1777
    if (m_currentEditor != NULL)
×
1778
    {
1779
        m_vsplitter->widget(1)->layout()->removeWidget(m_currentEditor);
×
1780
        m_vsplitter->widget(1)->hide();
×
1781
        delete m_currentEditor;
×
1782
        m_currentEditor = NULL;
×
1783
        m_editorFunctionID = Function::invalidId();
×
1784
    }
1785

1786
    if (m_sceneEditor != NULL)
×
1787
    {
1788
        m_splitter->widget(1)->layout()->removeWidget(m_sceneEditor);
×
1789
        m_splitter->widget(1)->hide();
×
1790
        delete m_sceneEditor;
×
1791
        m_sceneEditor = NULL;
×
1792
    }
1793

1794
    ShowItem *item = m_showview->getSelectedItem();
×
1795
    if (item != NULL)
×
1796
        item->setSelected(false);
×
1797
}
×
1798

1799
FunctionParent ShowManager::functionParent() const
×
1800
{
1801
    return FunctionParent::master();
×
1802
}
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