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

Method collectionChanged

src/frontend/examples/ExamplesWidget.cpp:102–139  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

100 * Shows all categories and sub-categories for the currently selected collection
101 */
102void 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
141void ExamplesWidget::exampleChanged() {
142 const QString& name = ui.lwExamples->currentItem()->text();

Callers

nothing calls this directly

Calls 14

QIconClass · 0.85
currentTextMethod · 0.80
exampleNamesMethod · 0.80
setToolTipMethod · 0.80
descriptionMethod · 0.80
appendRowMethod · 0.80
setIconMethod · 0.45
pixmapMethod · 0.45
setTextMethod · 0.45
setModelMethod · 0.45
clearMethod · 0.45
setCurrentIndexMethod · 0.45

Tested by

no test coverage detected