MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / update

Method update

src/openms_gui/source/VISUAL/LayerListView.cpp:44–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 }
43
44 void LayerListView::update(PlotWidget* active_widget)
45 {
46 // reset items
47 this->clear();
48
49 spectrum_widget_ = active_widget;
50 // during program exit, this could be called after PlotWidgets are gone
51 if (spectrum_widget_ == nullptr)
52 {
53 return;
54 }
55 PlotCanvas* cc = spectrum_widget_->canvas();
56 if (cc == nullptr)
57 {
58 return;
59 }
60
61 // determine if this is a 1D view (for text color)
62 bool is_1d_view = (dynamic_cast<Plot1DCanvas*>(cc) != nullptr);
63
64 this->blockSignals(true);
65 RAIICleanup cl([&]() { this->blockSignals(false); });
66
67 for (Size i = 0; i < cc->getLayerCount(); ++i)
68 {
69 const LayerDataBase& layer = cc->getLayer(i);
70
71 // add item
72 QListWidgetItem* item = new QListWidgetItem(this);
73 QString name = layer.getDecoratedName().toQString();
74
75 item->setText(name);
76 item->setToolTip(layer.filename.toQString());
77
78 if (is_1d_view)
79 {
80 QPixmap icon(7, 7);
81 icon.fill(QColor(String(layer.param.getValue("peak_color").toString()).toQString()));
82 item->setIcon(icon);
83 }
84 else
85 { // 2D/3D map view
86 switch (layer.type)
87 {
88 case LayerDataBase::DT_PEAK:
89 item->setIcon(QIcon(":/peaks.png"));
90 break;
91 case LayerDataBase::DT_FEATURE:
92 item->setIcon(QIcon(":/convexhull.png"));
93 break;
94 case LayerDataBase::DT_CONSENSUS:
95 item->setIcon(QIcon(":/elements.png"));
96 break;
97 default:
98 break;
99 }
100 }
101

Callers

nothing calls this directly

Calls 11

QColorClass · 0.85
getLayerCountMethod · 0.80
getLayerMethod · 0.80
setTextMethod · 0.80
getCurrentLayerIndexMethod · 0.80
StringClass · 0.50
clearMethod · 0.45
toQStringMethod · 0.45
getDecoratedNameMethod · 0.45
toStringMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected