Skip to content

Commit 028261f

Browse files
committed
fix: target dropdown showing empty when unknown item was selected
1 parent 58e2267 commit 028261f

File tree

1 file changed

+79
-99
lines changed

1 file changed

+79
-99
lines changed

src/Widgets/Inspector/InspectorOutputWidget.cpp

+79-99
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include <QtWidgets/QApplication>
4949
#include <QtWidgets/QLineEdit>
5050

51-
InspectorOutputWidget::InspectorOutputWidget(QWidget* parent)
51+
InspectorOutputWidget::InspectorOutputWidget(QWidget *parent)
5252
: QWidget(parent),
5353
command(NULL), model(NULL), delayType(""), libraryFilter("")
5454
{
@@ -61,25 +61,25 @@ InspectorOutputWidget::InspectorOutputWidget(QWidget* parent)
6161
this->comboBoxTarget->lineEdit()->setStyleSheet("background-color: transparent; border-width: 0px;");
6262

6363
QObject::connect(&DeviceManager::getInstance(), SIGNAL(deviceRemoved()), this, SLOT(deviceRemoved()));
64-
QObject::connect(&DeviceManager::getInstance(), SIGNAL(deviceAdded(CasparDevice&)), this, SLOT(deviceAdded(CasparDevice&)));
65-
66-
QObject::connect(&EventManager::getInstance(), SIGNAL(rundownItemSelected(const RundownItemSelectedEvent&)), this, SLOT(rundownItemSelected(const RundownItemSelectedEvent&)));
67-
QObject::connect(&EventManager::getInstance(), SIGNAL(libraryItemSelected(const LibraryItemSelectedEvent&)), this, SLOT(libraryItemSelected(const LibraryItemSelectedEvent&)));
68-
QObject::connect(&EventManager::getInstance(), SIGNAL(emptyRundown(const EmptyRundownEvent&)), this, SLOT(emptyRundown(const EmptyRundownEvent&)));
69-
QObject::connect(&EventManager::getInstance(), SIGNAL(deviceChanged(const DeviceChangedEvent&)), this, SLOT(deviceChanged(const DeviceChangedEvent&)));
70-
QObject::connect(&EventManager::getInstance(), SIGNAL(mediaChanged(const MediaChangedEvent&)), this, SLOT(mediaChanged(const MediaChangedEvent&)));
71-
QObject::connect(&EventManager::getInstance(), SIGNAL(templateChanged(const TemplateChangedEvent&)), this, SLOT(templateChanged(const TemplateChangedEvent&)));
72-
QObject::connect(&EventManager::getInstance(), SIGNAL(libraryFilterChanged(const LibraryFilterChangedEvent&)), this, SLOT(libraryFilterChanged(const LibraryFilterChangedEvent&)));
64+
QObject::connect(&DeviceManager::getInstance(), SIGNAL(deviceAdded(CasparDevice &)), this, SLOT(deviceAdded(CasparDevice &)));
65+
66+
QObject::connect(&EventManager::getInstance(), SIGNAL(rundownItemSelected(const RundownItemSelectedEvent &)), this, SLOT(rundownItemSelected(const RundownItemSelectedEvent &)));
67+
QObject::connect(&EventManager::getInstance(), SIGNAL(libraryItemSelected(const LibraryItemSelectedEvent &)), this, SLOT(libraryItemSelected(const LibraryItemSelectedEvent &)));
68+
QObject::connect(&EventManager::getInstance(), SIGNAL(emptyRundown(const EmptyRundownEvent &)), this, SLOT(emptyRundown(const EmptyRundownEvent &)));
69+
QObject::connect(&EventManager::getInstance(), SIGNAL(deviceChanged(const DeviceChangedEvent &)), this, SLOT(deviceChanged(const DeviceChangedEvent &)));
70+
QObject::connect(&EventManager::getInstance(), SIGNAL(mediaChanged(const MediaChangedEvent &)), this, SLOT(mediaChanged(const MediaChangedEvent &)));
71+
QObject::connect(&EventManager::getInstance(), SIGNAL(templateChanged(const TemplateChangedEvent &)), this, SLOT(templateChanged(const TemplateChangedEvent &)));
72+
QObject::connect(&EventManager::getInstance(), SIGNAL(libraryFilterChanged(const LibraryFilterChangedEvent &)), this, SLOT(libraryFilterChanged(const LibraryFilterChangedEvent &)));
7373
}
7474

75-
void InspectorOutputWidget::libraryFilterChanged(const LibraryFilterChangedEvent& event)
75+
void InspectorOutputWidget::libraryFilterChanged(const LibraryFilterChangedEvent &event)
7676
{
7777
this->libraryFilter = event.getFilter();
7878

7979
checkEmptyTarget();
8080
}
8181

82-
void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent& event)
82+
void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent &event)
8383
{
8484
this->command = nullptr;
8585
this->model = event.getLibraryModel();
@@ -125,7 +125,7 @@ void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent&
125125
{
126126
if (deviceModel != NULL)
127127
{
128-
const QStringList& channelFormats = DatabaseManager::getInstance().getDeviceByName(deviceModel->getName()).getChannelFormats().split(",");
128+
const QStringList &channelFormats = DatabaseManager::getInstance().getDeviceByName(deviceModel->getName()).getChannelFormats().split(",");
129129
this->spinBoxChannel->setMaximum(channelFormats.count());
130130
}
131131
}
@@ -147,16 +147,16 @@ void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent&
147147

148148
fillTargetCombo(this->model->getType());
149149

150-
if (dynamic_cast<FileRecorderCommand*>(event.getCommand()))
150+
if (dynamic_cast<FileRecorderCommand *>(event.getCommand()))
151151
{
152152
this->comboBoxTarget->setEnabled(false);
153153
this->spinBoxVideolayer->setEnabled(false);
154154

155155
this->comboBoxTarget->setCurrentIndex(-1);
156156
this->spinBoxVideolayer->setValue(Output::DEFAULT_VIDEOLAYER);
157157
}
158-
else if (dynamic_cast<CommitCommand*>(event.getCommand()) ||
159-
dynamic_cast<PrintCommand*>(event.getCommand()))
158+
else if (dynamic_cast<CommitCommand *>(event.getCommand()) ||
159+
dynamic_cast<PrintCommand *>(event.getCommand()))
160160
{
161161
this->comboBoxTarget->setEnabled(false);
162162
this->spinBoxVideolayer->setEnabled(false);
@@ -166,14 +166,14 @@ void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent&
166166
this->spinBoxVideolayer->setValue(Output::DEFAULT_VIDEOLAYER);
167167
this->spinBoxDuration->setValue(Output::DEFAULT_DURATION);
168168
}
169-
else if (dynamic_cast<GridCommand*>(event.getCommand()))
169+
else if (dynamic_cast<GridCommand *>(event.getCommand()))
170170
{
171171
this->comboBoxTarget->setEnabled(false);
172172
this->spinBoxVideolayer->setEnabled(false);
173173

174174
this->spinBoxVideolayer->setValue(Output::DEFAULT_VIDEOLAYER);
175175
}
176-
else if (dynamic_cast<GroupCommand*>(event.getCommand()))
176+
else if (dynamic_cast<GroupCommand *>(event.getCommand()))
177177
{
178178
this->comboBoxDevice->setEnabled(false);
179179
this->comboBoxTarget->setEnabled(false);
@@ -191,11 +191,11 @@ void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent&
191191
this->spinBoxVideolayer->setValue(Output::DEFAULT_VIDEOLAYER);
192192
this->spinBoxDelay->setValue(Output::DEFAULT_DELAY);
193193
}
194-
else if (dynamic_cast<GpiOutputCommand*>(event.getCommand()) ||
195-
dynamic_cast<OscOutputCommand*>(event.getCommand()) ||
196-
dynamic_cast<HttpGetCommand*>(event.getCommand()) ||
197-
dynamic_cast<HttpPostCommand*>(event.getCommand()) ||
198-
dynamic_cast<PlayoutCommand*>(event.getCommand()))
194+
else if (dynamic_cast<GpiOutputCommand *>(event.getCommand()) ||
195+
dynamic_cast<OscOutputCommand *>(event.getCommand()) ||
196+
dynamic_cast<HttpGetCommand *>(event.getCommand()) ||
197+
dynamic_cast<HttpPostCommand *>(event.getCommand()) ||
198+
dynamic_cast<PlayoutCommand *>(event.getCommand()))
199199
{
200200
this->comboBoxDevice->setEnabled(false);
201201
this->comboBoxTarget->setEnabled(false);
@@ -212,7 +212,7 @@ void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent&
212212
this->spinBoxVideolayer->setValue(Output::DEFAULT_VIDEOLAYER);
213213
this->spinBoxDuration->setValue(Output::DEFAULT_DURATION);
214214
}
215-
else if (dynamic_cast<SeparatorCommand*>(event.getCommand()))
215+
else if (dynamic_cast<SeparatorCommand *>(event.getCommand()))
216216
{
217217
this->comboBoxDevice->setEnabled(false);
218218
this->comboBoxTarget->setEnabled(false);
@@ -235,7 +235,7 @@ void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent&
235235
this->checkBoxAllowRemoteTriggering->setChecked(Output::DEFAULT_ALLOW_REMOTE_TRIGGERING);
236236
this->lineEditRemoteTriggerId->setText(Output::DEFAULT_REMOTE_TRIGGER_ID);
237237
}
238-
else if (dynamic_cast<CustomCommand*>(event.getCommand()))
238+
else if (dynamic_cast<CustomCommand *>(event.getCommand()))
239239
{
240240
this->comboBoxTarget->setEnabled(false);
241241
this->spinBoxChannel->setEnabled(false);
@@ -245,42 +245,41 @@ void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent&
245245
this->spinBoxChannel->setValue(Output::DEFAULT_CHANNEL);
246246
this->spinBoxVideolayer->setValue(Output::DEFAULT_VIDEOLAYER);
247247
}
248-
else if (dynamic_cast<ClearOutputCommand*>(event.getCommand()) ||
249-
dynamic_cast<ResetCommand*>(event.getCommand()))
248+
else if (dynamic_cast<ClearOutputCommand *>(event.getCommand()) ||
249+
dynamic_cast<ResetCommand *>(event.getCommand()))
250250
{
251251
this->comboBoxTarget->setEnabled(false);
252252
this->spinBoxDuration->setEnabled(false);
253253

254254
this->comboBoxTarget->setCurrentIndex(-1);
255255
this->spinBoxDuration->setValue(Output::DEFAULT_DURATION);
256256
}
257-
else if (dynamic_cast<DeckLinkInputCommand*>(event.getCommand()) ||
258-
dynamic_cast<BlendModeCommand*>(event.getCommand()) ||
259-
dynamic_cast<BrightnessCommand*>(event.getCommand()) ||
260-
dynamic_cast<ContrastCommand*>(event.getCommand()) ||
261-
dynamic_cast<ClipCommand*>(event.getCommand()) ||
262-
dynamic_cast<CropCommand*>(event.getCommand()) ||
263-
dynamic_cast<FillCommand*>(event.getCommand()) ||
264-
dynamic_cast<PerspectiveCommand*>(event.getCommand()) ||
265-
dynamic_cast<RotationCommand*>(event.getCommand()) ||
266-
dynamic_cast<AnchorCommand*>(event.getCommand()) ||
267-
dynamic_cast<KeyerCommand*>(event.getCommand()) ||
268-
dynamic_cast<LevelsCommand*>(event.getCommand()) ||
269-
dynamic_cast<OpacityCommand*>(event.getCommand()) ||
270-
dynamic_cast<SaturationCommand*>(event.getCommand()) ||
271-
dynamic_cast<VolumeCommand*>(event.getCommand()) ||
272-
dynamic_cast<SolidColorCommand*>(event.getCommand()) ||
273-
dynamic_cast<FadeToBlackCommand*>(event.getCommand()) ||
274-
dynamic_cast<HtmlCommand*>(event.getCommand()) ||
275-
dynamic_cast<RouteChannelCommand*>(event.getCommand()) ||
276-
dynamic_cast<RouteVideolayerCommand*>(event.getCommand()) ||
277-
dynamic_cast<ChromaCommand*>(event.getCommand()))
257+
else if (dynamic_cast<DeckLinkInputCommand *>(event.getCommand()) ||
258+
dynamic_cast<BlendModeCommand *>(event.getCommand()) ||
259+
dynamic_cast<BrightnessCommand *>(event.getCommand()) ||
260+
dynamic_cast<ContrastCommand *>(event.getCommand()) ||
261+
dynamic_cast<ClipCommand *>(event.getCommand()) ||
262+
dynamic_cast<CropCommand *>(event.getCommand()) ||
263+
dynamic_cast<FillCommand *>(event.getCommand()) ||
264+
dynamic_cast<PerspectiveCommand *>(event.getCommand()) ||
265+
dynamic_cast<RotationCommand *>(event.getCommand()) ||
266+
dynamic_cast<AnchorCommand *>(event.getCommand()) ||
267+
dynamic_cast<KeyerCommand *>(event.getCommand()) ||
268+
dynamic_cast<LevelsCommand *>(event.getCommand()) ||
269+
dynamic_cast<OpacityCommand *>(event.getCommand()) ||
270+
dynamic_cast<SaturationCommand *>(event.getCommand()) ||
271+
dynamic_cast<VolumeCommand *>(event.getCommand()) ||
272+
dynamic_cast<SolidColorCommand *>(event.getCommand()) ||
273+
dynamic_cast<FadeToBlackCommand *>(event.getCommand()) ||
274+
dynamic_cast<HtmlCommand *>(event.getCommand()) ||
275+
dynamic_cast<RouteChannelCommand *>(event.getCommand()) ||
276+
dynamic_cast<RouteVideolayerCommand *>(event.getCommand()) ||
277+
dynamic_cast<ChromaCommand *>(event.getCommand()))
278278
{
279279
this->comboBoxTarget->setEnabled(false);
280280

281281
this->comboBoxTarget->setCurrentIndex(-1);
282282
}
283-
284283
}
285284

286285
if (deviceModel != NULL && deviceModel->getLockedChannel() > 0 && deviceModel->getLockedChannel() <= this->spinBoxChannel->maximum())
@@ -298,7 +297,7 @@ void InspectorOutputWidget::rundownItemSelected(const RundownItemSelectedEvent&
298297
blockAllSignals(false);
299298
}
300299

301-
void InspectorOutputWidget::libraryItemSelected(const LibraryItemSelectedEvent& event)
300+
void InspectorOutputWidget::libraryItemSelected(const LibraryItemSelectedEvent &event)
302301
{
303302
this->model = event.getLibraryModel();
304303

@@ -339,7 +338,7 @@ void InspectorOutputWidget::libraryItemSelected(const LibraryItemSelectedEvent&
339338
blockAllSignals(false);
340339
}
341340

342-
void InspectorOutputWidget::emptyRundown(const EmptyRundownEvent& event)
341+
void InspectorOutputWidget::emptyRundown(const EmptyRundownEvent &event)
343342
{
344343
Q_UNUSED(event);
345344

@@ -384,7 +383,7 @@ void InspectorOutputWidget::emptyRundown(const EmptyRundownEvent& event)
384383
blockAllSignals(false);
385384
}
386385

387-
void InspectorOutputWidget::deviceChanged(const DeviceChangedEvent& event)
386+
void InspectorOutputWidget::deviceChanged(const DeviceChangedEvent &event)
388387
{
389388
if (this->model == NULL)
390389
return;
@@ -400,7 +399,7 @@ void InspectorOutputWidget::deviceChanged(const DeviceChangedEvent& event)
400399
blockAllSignals(false);
401400
}
402401

403-
void InspectorOutputWidget::mediaChanged(const MediaChangedEvent& event)
402+
void InspectorOutputWidget::mediaChanged(const MediaChangedEvent &event)
404403
{
405404
Q_UNUSED(event);
406405

@@ -414,7 +413,7 @@ void InspectorOutputWidget::mediaChanged(const MediaChangedEvent& event)
414413
blockAllSignals(false);
415414
}
416415

417-
void InspectorOutputWidget::templateChanged(const TemplateChangedEvent& event)
416+
void InspectorOutputWidget::templateChanged(const TemplateChangedEvent &event)
418417
{
419418
Q_UNUSED(event);
420419

@@ -441,7 +440,7 @@ void InspectorOutputWidget::blockAllSignals(bool block)
441440
this->lineEditRemoteTriggerId->blockSignals(block);
442441
}
443442

444-
void InspectorOutputWidget::fillTargetCombo(const QString& type, QString deviceName)
443+
void InspectorOutputWidget::fillTargetCombo(const QString &type, QString deviceName)
445444
{
446445
this->comboBoxTarget->clear();
447446

@@ -451,56 +450,37 @@ void InspectorOutputWidget::fillTargetCombo(const QString& type, QString deviceN
451450
if (deviceName.isEmpty())
452451
deviceName = this->model->getDeviceName();
453452

454-
if (deviceName.isEmpty())
455-
return;
456-
457-
const QSharedPointer<CasparDevice> device = DeviceManager::getInstance().getDeviceByName(deviceName);
458-
if (device == NULL)
459-
return;
453+
QSharedPointer<DeviceModel> deviceModel;
460454

461-
const QSharedPointer<DeviceModel> deviceModel = DeviceManager::getInstance().getDeviceModelByName(deviceName);
462-
if (deviceModel == NULL)
463-
return;
455+
if (!deviceName.isEmpty())
456+
deviceModel = DeviceManager::getInstance().getDeviceModelByName(deviceName);
464457

465-
QList<LibraryModel> models;
466-
if (this->libraryFilter.isEmpty())
467-
models = DatabaseManager::getInstance().getLibraryByDeviceId(deviceModel->getId());
468-
else
469-
models = DatabaseManager::getInstance().getLibraryByDeviceIdAndFilter(deviceModel->getId(), this->libraryFilter);
470-
471-
if (models.count() > 0)
458+
if (deviceModel)
472459
{
473-
foreach (LibraryModel model, models)
474-
{
475-
if (type == Rundown::MOVIE && model.getType() == Rundown::MOVIE)
476-
this->comboBoxTarget->addItem(model.getName());
477-
else if (type == Rundown::AUDIO && model.getType() == Rundown::AUDIO)
478-
this->comboBoxTarget->addItem(model.getName());
479-
else if (type == Rundown::TEMPLATE && model.getType() == Rundown::TEMPLATE)
480-
this->comboBoxTarget->addItem(model.getName());
481-
else if ((type == Rundown::STILL || type == Rundown::IMAGESCROLLER) && model.getType() == Rundown::STILL)
482-
this->comboBoxTarget->addItem(model.getName());
483-
}
460+
QList<LibraryModel> models;
461+
if (this->libraryFilter.isEmpty())
462+
models = DatabaseManager::getInstance().getLibraryByDeviceId(deviceModel->getId());
463+
else
464+
models = DatabaseManager::getInstance().getLibraryByDeviceIdAndFilter(deviceModel->getId(), this->libraryFilter);
484465

485-
// Include current target when using filter that do not match it.
486-
if (!this->libraryFilter.isEmpty() && this->comboBoxTarget->findText(this->model->getName()))
466+
if (models.count() > 0)
487467
{
488-
if (!this->model->getName().isEmpty() &&
489-
(this->model->getType() == Rundown::AUDIO || this->model->getType() == Rundown::STILL ||
490-
this->model->getType() == Rundown::IMAGESCROLLER || this->model->getType() == Rundown::TEMPLATE || this->model->getType() == Rundown::MOVIE) &&
491-
this->model->getName() != Rundown::DEFAULT_AUDIO_NAME &&
492-
this->model->getName() != Rundown::DEFAULT_STILL_NAME &&
493-
this->model->getName() != Rundown::DEFAULT_IMAGESCROLLER_NAME &&
494-
this->model->getName() != Rundown::DEFAULT_TEMPLATE_NAME &&
495-
this->model->getName() != Rundown::DEFAULT_MOVIE_NAME)
468+
foreach (LibraryModel model, models)
496469
{
497-
this->comboBoxTarget->addItem(this->model->getName());
470+
if (type == Rundown::MOVIE && model.getType() == Rundown::MOVIE)
471+
this->comboBoxTarget->addItem(model.getName());
472+
else if (type == Rundown::AUDIO && model.getType() == Rundown::AUDIO)
473+
this->comboBoxTarget->addItem(model.getName());
474+
else if (type == Rundown::TEMPLATE && model.getType() == Rundown::TEMPLATE)
475+
this->comboBoxTarget->addItem(model.getName());
476+
else if ((type == Rundown::STILL || type == Rundown::IMAGESCROLLER) && model.getType() == Rundown::STILL)
477+
this->comboBoxTarget->addItem(model.getName());
498478
}
499479
}
500-
501-
this->comboBoxTarget->setCurrentIndex(this->comboBoxTarget->findText(this->model->getName()));
502480
}
503-
else
481+
482+
// Include current target when it is not already an option.
483+
if (this->comboBoxTarget->findText(this->model->getName()) == -1)
504484
{
505485
if (!this->model->getName().isEmpty() &&
506486
(this->model->getType() == Rundown::AUDIO || this->model->getType() == Rundown::STILL ||
@@ -549,13 +529,13 @@ void InspectorOutputWidget::deviceRemoved()
549529
blockAllSignals(true);
550530

551531
this->comboBoxDevice->clear();
552-
foreach (const DeviceModel& model, DeviceManager::getInstance().getDeviceModels())
532+
foreach (const DeviceModel &model, DeviceManager::getInstance().getDeviceModels())
553533
this->comboBoxDevice->addItem(model.getName());
554534

555535
blockAllSignals(false);
556536
}
557537

558-
void InspectorOutputWidget::deviceAdded(CasparDevice& device)
538+
void InspectorOutputWidget::deviceAdded(CasparDevice &device)
559539
{
560540
blockAllSignals(true);
561541

@@ -579,7 +559,7 @@ void InspectorOutputWidget::deviceNameChanged(QString deviceName)
579559
return;
580560

581561
const QSharedPointer<DeviceModel> model = DeviceManager::getInstance().getDeviceModelByName(deviceName);
582-
const QStringList& channelFormats = DatabaseManager::getInstance().getDeviceByName(model->getName()).getChannelFormats().split(",");
562+
const QStringList &channelFormats = DatabaseManager::getInstance().getDeviceByName(model->getName()).getChannelFormats().split(",");
583563
this->spinBoxChannel->setMaximum(channelFormats.count());
584564

585565
if (model->getLockedChannel() > 0 && model->getLockedChannel() <= this->spinBoxChannel->maximum())

0 commit comments

Comments
 (0)