! * \brief LiveDataDock::updateTypeChanged * \param idx */
| 374 | * \param idx |
| 375 | */ |
| 376 | void LiveDataDock::updateTypeChanged(int idx) { |
| 377 | if (m_liveDataSource) { |
| 378 | DEBUG("LiveDataDock::updateTypeChanged()"); |
| 379 | const auto updateType = static_cast<LiveDataSource::UpdateType>(idx); |
| 380 | |
| 381 | switch (updateType) { |
| 382 | case LiveDataSource::UpdateType::TimeInterval: { |
| 383 | ui.lUpdateInterval->show(); |
| 384 | ui.sbUpdateInterval->show(); |
| 385 | const auto s = m_liveDataSource->sourceType(); |
| 386 | const auto r = m_liveDataSource->readingType(); |
| 387 | const bool showSampleSize = ((s == LiveDataSource::SourceType::FileOrPipe || s == LiveDataSource::SourceType::NetworkUDPSocket) |
| 388 | && (r == LiveDataSource::ReadingType::ContinuousFixed || r == LiveDataSource::ReadingType::FromEnd)); |
| 389 | ui.lSampleSize->setVisible(showSampleSize); |
| 390 | ui.sbSampleSize->setVisible(showSampleSize); |
| 391 | |
| 392 | m_liveDataSource->setUpdateType(updateType); |
| 393 | m_liveDataSource->setUpdateInterval(ui.sbUpdateInterval->value()); |
| 394 | break; |
| 395 | } |
| 396 | case LiveDataSource::UpdateType::NewData: |
| 397 | ui.lUpdateInterval->hide(); |
| 398 | ui.sbUpdateInterval->hide(); |
| 399 | ui.lSampleSize->hide(); |
| 400 | ui.sbSampleSize->hide(); |
| 401 | |
| 402 | m_liveDataSource->setUpdateType(updateType); |
| 403 | } |
| 404 | } |
| 405 | #ifdef HAVE_MQTT |
| 406 | else if (m_mqttClient) { |
| 407 | DEBUG("LiveDataDock::updateTypeChanged()"); |
| 408 | const auto type = static_cast<MQTTClient::UpdateType>(idx); |
| 409 | |
| 410 | if (type == MQTTClient::UpdateType::TimeInterval) { |
| 411 | ui.lUpdateInterval->show(); |
| 412 | ui.sbUpdateInterval->show(); |
| 413 | |
| 414 | m_mqttClient->setUpdateType(type); |
| 415 | m_mqttClient->setUpdateInterval(ui.sbUpdateInterval->value()); |
| 416 | } else if (type == MQTTClient::UpdateType::NewData) { |
| 417 | ui.lUpdateInterval->hide(); |
| 418 | ui.sbUpdateInterval->hide(); |
| 419 | |
| 420 | m_mqttClient->setUpdateType(type); |
| 421 | } |
| 422 | } |
| 423 | #endif |
| 424 | } |
| 425 | |
| 426 | /*! |
| 427 | * \brief Handles the change of the reading type in the dock widget |
no test coverage detected