| 257 | } |
| 258 | |
| 259 | void DIATreeTab::updateEntries(LayerDataBase* layer) |
| 260 | { |
| 261 | if (layer == nullptr) |
| 262 | { |
| 263 | clear(); |
| 264 | return; |
| 265 | } |
| 266 | |
| 267 | if (!dia_treewidget_->isVisible() || dia_treewidget_->signalsBlocked()) |
| 268 | { |
| 269 | return; |
| 270 | } |
| 271 | auto* lp = dynamic_cast<const LayerDataChrom*>(layer); |
| 272 | if (!lp) return; |
| 273 | |
| 274 | OSWData* data = lp->getChromatogramAnnotation().get(); |
| 275 | |
| 276 | if (current_data_ == data) |
| 277 | { |
| 278 | // layer data is still the same as last time .. |
| 279 | // do not repopulate the table for now, since the data should not have changed |
| 280 | // Note: If we ever need to redraw, the tree's state (which subtress are expanded, which items are selected) will need to be remembered and restored |
| 281 | return; |
| 282 | } |
| 283 | |
| 284 | // update last data pointer |
| 285 | current_data_ = data; |
| 286 | |
| 287 | dia_treewidget_->blockSignals(true); |
| 288 | RAIICleanup clean([&]() { dia_treewidget_->blockSignals(false); }); |
| 289 | |
| 290 | dia_treewidget_->clear(); |
| 291 | |
| 292 | dia_treewidget_->setHeaders(Clmn::HEADER_NAMES); |
| 293 | |
| 294 | |
| 295 | if (data == nullptr // DIA tab is active, but the layer has no data to show... |
| 296 | || data->getProteins().empty()) |
| 297 | { |
| 298 | dia_treewidget_->setHeaders(QStringList() << "No data"); |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | for (size_t prot_index = 0; prot_index < data->getProteins().size(); ++prot_index) |
| 303 | { |
| 304 | const auto& prot = data->getProteins()[prot_index]; |
| 305 | auto item_prot = createProt(prot, (int)prot_index); |
| 306 | dia_treewidget_->addTopLevelItem(item_prot); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | populateSearchBox_(); |
| 311 | |
| 312 | // automatically set column width, depending on data |
| 313 | dia_treewidget_->header()->setStretchLastSection(false); |
| 314 | dia_treewidget_->header()->setSectionResizeMode(QHeaderView::ResizeToContents); |
| 315 | } |
| 316 |
no test coverage detected