* Shows all categories and sub-categories for the currently selected collection */
| 131 | * Shows all categories and sub-categories for the currently selected collection |
| 132 | */ |
| 133 | void 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 | |
| 178 | void ColorMapsWidget::colorMapChanged() { |
| 179 | const QString& name = ui.lwColorMaps->currentItem()->text(); |
nothing calls this directly
no test coverage detected