MCPcopy Create free account
hub / github.com/KDE/labplot / collectionChanged

Method collectionChanged

src/frontend/colormaps/ColorMapsWidget.cpp:133–176  ·  view source on GitHub ↗

* Shows all categories and sub-categories for the currently selected collection */

Source from the content-addressed store, hash-verified

131 * Shows all categories and sub-categories for the currently selected collection
132 */
133void ColorMapsWidget::collectionChanged(int) {
134 const QString& collection = ui.cbCollections->currentText();
135
136 // populate the list view for the icon mode
137 if (m_model)
138 delete m_model;
139
140 m_model = new QStandardItemModel(this);
141 const auto& colorMapNames = m_manager->colorMapNames(collection);
142 for (const auto& name : colorMapNames) {
143 auto* item = new QStandardItem();
144 QPixmap pixmap;
145 m_manager->render(pixmap, name);
146 item->setIcon(QIcon(pixmap));
147 item->setText(name);
148 m_model->appendRow(item);
149 }
150
151 ui.lvColorMaps->setModel(m_model);
152
153 // populate the list widget for the list mode
154 ui.lwColorMaps->clear();
155 ui.lwColorMaps->addItems(colorMapNames);
156
157 // populate the list widget for the list details mode
158 ui.lwColorMapsDetails->clear();
159 ui.lwColorMapsDetails->addItems(colorMapNames);
160
161 // select the first color map in the current collection
162 ui.lvColorMaps->setCurrentIndex(ui.lvColorMaps->model()->index(0, 0));
163 ui.lwColorMaps->setCurrentRow(0);
164 ui.lwColorMapsDetails->setCurrentRow(0);
165
166 // update the completer
167 if (m_completer)
168 delete m_completer;
169
170 m_completer = new QCompleter(colorMapNames, this);
171 connect(m_completer, QOverload<const QString&>::of(&QCompleter::activated), this, &ColorMapsWidget::activated);
172 m_completer->setCompletionMode(QCompleter::PopupCompletion);
173 m_completer->setCaseSensitivity(Qt::CaseInsensitive);
174 m_completer->setFilterMode(Qt::MatchContains);
175 ui.leSearch->setCompleter(m_completer);
176}
177
178void ColorMapsWidget::colorMapChanged() {
179 const QString& name = ui.lwColorMaps->currentItem()->text();

Callers

nothing calls this directly

Calls 12

QIconClass · 0.85
currentTextMethod · 0.80
colorMapNamesMethod · 0.80
renderMethod · 0.80
appendRowMethod · 0.80
setIconMethod · 0.45
setTextMethod · 0.45
setModelMethod · 0.45
clearMethod · 0.45
setCurrentIndexMethod · 0.45
indexMethod · 0.45
modelMethod · 0.45

Tested by

no test coverage detected