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

Method confirmGroupWidgetChange

app/src/DataModel/ProjectModel.cpp:4660–4693  ·  view source on GitHub ↗

* @brief Confirms a destructive group widget change and clears existing datasets if needed. */

Source from the content-addressed store, hash-verified

4658 * @brief Confirms a destructive group widget change and clears existing datasets if needed.
4659 */
4660bool DataModel::ProjectModel::confirmGroupWidgetChange(DataModel::Group& grp,
4661 SerialStudio::GroupWidget widget)
4662{
4663 if (grp.datasets.empty())
4664 return true;
4665
4666 if (widget == SerialStudio::Painter) {
4667 grp.widget = "painter";
4668 return true;
4669 }
4670
4671 const bool compatibleTarget =
4672 (widget == SerialStudio::DataGrid || widget == SerialStudio::MultiPlot
4673 || widget == SerialStudio::NoGroupWidget);
4674 const bool compatibleSource = (grp.widget == "multiplot" || grp.widget == "datagrid"
4675 || grp.widget == "painter" || grp.widget == "");
4676 if (compatibleTarget && compatibleSource) {
4677 grp.widget = "";
4678 return true;
4679 }
4680
4681 auto ret = Misc::Utilities::showMessageBox(tr("Are you sure you want to change the group-level "
4682 "widget?"),
4683 tr("Existing datasets for this group are deleted"),
4684 QMessageBox::Question,
4685 APP_NAME,
4686 QMessageBox::Yes | QMessageBox::No);
4687
4688 if (ret == QMessageBox::No)
4689 return false;
4690
4691 grp.datasets.clear();
4692 return true;
4693}
4694
4695/**
4696 * @brief Assigns a group widget tag and any canonical datasets for fixed-layout types.

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected