| 259 | } |
| 260 | |
| 261 | void MdfDocument::OnShowGroupData(wxCommandEvent &) { |
| 262 | const auto selected_id = GetSelectedBlockId(); |
| 263 | auto *selected_block = GetBlock(selected_id); |
| 264 | if (selected_block == nullptr) { |
| 265 | return; |
| 266 | } |
| 267 | IDataGroup* dg = nullptr; |
| 268 | IChannelGroup* cg = nullptr; |
| 269 | if (selected_block->BlockType() == "DG") { |
| 270 | dg = dynamic_cast<IDataGroup*>(selected_block); |
| 271 | if (dg != nullptr) { |
| 272 | auto cg_list = dg->ChannelGroups(); |
| 273 | if (!cg_list.empty()) { |
| 274 | cg = cg_list[0]; |
| 275 | } |
| 276 | } |
| 277 | } else if (selected_block->BlockType() == "CG") { |
| 278 | cg = dynamic_cast<IChannelGroup*>(selected_block); |
| 279 | const auto parent_id = GetParentBlockId(); |
| 280 | auto *parent_block = GetBlock(parent_id); |
| 281 | if (parent_block != nullptr) { |
| 282 | dg = dynamic_cast<IDataGroup*>(parent_block); |
| 283 | } |
| 284 | } |
| 285 | if (dg == nullptr || cg == nullptr) { |
| 286 | return; |
| 287 | } |
| 288 | |
| 289 | auto* view = GetFirstView(); |
| 290 | if (view == nullptr) { |
| 291 | return; |
| 292 | } |
| 293 | |
| 294 | auto* parent = view->GetFrame(); |
| 295 | if (parent == nullptr) { |
| 296 | return; |
| 297 | } |
| 298 | |
| 299 | std::ostringstream title; |
| 300 | if (!cg->Name().empty()) { |
| 301 | title << cg->Name(); |
| 302 | } |
| 303 | |
| 304 | if (!dg->Description().empty()) { |
| 305 | if (!title.str().empty()) { |
| 306 | title << "/"; |
| 307 | } |
| 308 | title << dg->Description(); |
| 309 | } |
| 310 | |
| 311 | if (!title.str().empty()) { |
| 312 | title << "/"; |
| 313 | } |
| 314 | title << reader_->ShortName(); |
| 315 | |
| 316 | auto observer_list = std::make_unique<mdf::ChannelObserverList>(); |
| 317 | mdf::CreateChannelObserverForChannelGroup(*dg, *cg, *observer_list); |
| 318 | const bool read = reader_->ReadData(*dg); |
nothing calls this directly
no test coverage detected