MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / driverForEditing

Method driverForEditing

app/src/IO/ConnectionManager.cpp:299–331  ·  view source on GitHub ↗

* @brief Returns (lazily creating) a driver instance for editing source @p deviceId. */

Source from the content-addressed store, hash-verified

297 * @brief Returns (lazily creating) a driver instance for editing source @p deviceId.
298 */
299IO::HAL_Driver* IO::ConnectionManager::driverForEditing(int deviceId)
300{
301 const auto& sources = DataModel::ProjectModel::instance().sources();
302 const DataModel::Source* srcPtr = nullptr;
303 for (const auto& src : sources) {
304 if (src.sourceId == deviceId) {
305 srcPtr = &src;
306 break;
307 }
308 }
309
310 if (!srcPtr)
311 return nullptr;
312
313 const auto busType = static_cast<SerialStudio::BusType>(srcPtr->busType);
314 HAL_Driver* uiDrv = uiDriverForBusType(busType);
315 if (!uiDrv)
316 return nullptr;
317
318 if (!srcPtr->connectionSettings.isEmpty()) {
319 m_syncingFromProject = true;
320 uiDrv->applyConnectionSettings(srcPtr->connectionSettings);
321 m_syncingFromProject = false;
322 }
323
324 if (busType == SerialStudio::BusType::BluetoothLE) {
325 auto* ble = qobject_cast<IO::Drivers::BluetoothLE*>(uiDrv);
326 if (ble && ble->deviceCount() == 0)
327 ble->startDiscovery();
328 }
329
330 return uiDrv;
331}
332
333//--------------------------------------------------------------------------------------------------
334// UI driver accessors

Callers 5

sourceConfigureMethod · 0.80
sourceSetPropertyMethod · 0.80
restoreSourceSettingsMethod · 0.80

Calls 4

isEmptyMethod · 0.80
deviceCountMethod · 0.80
startDiscoveryMethod · 0.45

Tested by

no test coverage detected