* Shows all categories and sub-categories for the currently selected collection */
| 100 | * Shows all categories and sub-categories for the currently selected collection |
| 101 | */ |
| 102 | void ExamplesWidget::collectionChanged(int) { |
| 103 | const QString& collection = ui.cbCollections->currentText(); |
| 104 | |
| 105 | // populate the list view for the icon mode |
| 106 | if (m_model) |
| 107 | delete m_model; |
| 108 | |
| 109 | m_model = new QStandardItemModel(this); |
| 110 | const auto& exampleNames = m_manager->exampleNames(collection); |
| 111 | for (const auto& name : exampleNames) { |
| 112 | auto* item = new QStandardItem(); |
| 113 | item->setIcon(QIcon(m_manager->pixmap(name))); |
| 114 | item->setText(name); |
| 115 | item->setToolTip(m_manager->description(name)); |
| 116 | m_model->appendRow(item); |
| 117 | } |
| 118 | |
| 119 | ui.lvExamples->setModel(m_model); |
| 120 | |
| 121 | // populate the list widget for the list mode |
| 122 | ui.lwExamples->clear(); |
| 123 | ui.lwExamples->addItems(exampleNames); |
| 124 | |
| 125 | // select the first example in the current collection |
| 126 | ui.lvExamples->setCurrentIndex(ui.lvExamples->model()->index(0, 0)); |
| 127 | ui.lwExamples->setCurrentRow(0); |
| 128 | |
| 129 | // update the completer |
| 130 | if (m_completer) |
| 131 | delete m_completer; |
| 132 | |
| 133 | m_completer = new QCompleter(exampleNames, this); |
| 134 | connect(m_completer, QOverload<const QString&>::of(&QCompleter::activated), this, &ExamplesWidget::activated); |
| 135 | m_completer->setCompletionMode(QCompleter::PopupCompletion); |
| 136 | m_completer->setCaseSensitivity(Qt::CaseInsensitive); |
| 137 | m_completer->setFilterMode(Qt::MatchContains); |
| 138 | ui.leSearch->setCompleter(m_completer); |
| 139 | } |
| 140 | |
| 141 | void ExamplesWidget::exampleChanged() { |
| 142 | const QString& name = ui.lwExamples->currentItem()->text(); |
nothing calls this directly
no test coverage detected