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

Method selectedAspectsChanged

src/frontend/GuiObserver.cpp:171–514  ·  view source on GitHub ↗

! called on selection changes in the project explorer. Determines the type of the currently selected objects (aspects) and activates the corresponding dockwidgets, toolbars etc. */

Source from the content-addressed store, hash-verified

169 and activates the corresponding dockwidgets, toolbars etc.
170*/
171void GuiObserver::selectedAspectsChanged(const QList<AbstractAspect*>& selectedAspects) {
172 auto clearDock = [&]() {
173 if (m_mainWindow->stackedWidget->currentWidget())
174 m_mainWindow->stackedWidget->currentWidget()->hide();
175
176 m_mainWindow->m_propertiesDock->setWindowTitle(i18nc("@title:window", "Properties"));
177 };
178
179 if (selectedAspects.isEmpty() || selectedAspects.front() == nullptr) {
180 clearDock();
181 return;
182 }
183
184 const AspectType type{selectedAspects.front()->type()};
185 DEBUG(Q_FUNC_INFO << ", type: " << STDSTRING(AbstractAspect::typeName(type)))
186
187 // update cursor dock
188 if (m_mainWindow->cursorWidget) {
189 if (type == AspectType::Worksheet) {
190 auto* worksheet = static_cast<Worksheet*>(selectedAspects.front());
191 m_mainWindow->cursorWidget->setWorksheet(worksheet);
192 } else {
193 auto* parent = selectedAspects.front()->parent(AspectType::Worksheet);
194 if (parent) {
195 auto* worksheet = static_cast<Worksheet*>(parent);
196 m_mainWindow->cursorWidget->setWorksheet(worksheet);
197 }
198 }
199 }
200
201 // Check, whether objects of different types were selected.
202 // Don't show any dock widgets in this case.
203 for (const auto* aspect : selectedAspects) {
204 if (aspect->type() != type) {
205 clearDock();
206 return;
207 }
208 }
209
210 switch (type) {
211 case AspectType::Spreadsheet:
212 m_mainWindow->m_propertiesDock->setWindowTitle(i18nc("@title:window", "Properties: Spreadsheet"));
213 raiseDockConnect(m_spreadsheetDock, m_mainWindow->statusBar(), m_mainWindow->stackedWidget);
214 m_spreadsheetDock->setSpreadsheets(castList<Spreadsheet>(selectedAspects));
215 break;
216 case AspectType::StatisticsSpreadsheet:
217 m_mainWindow->m_propertiesDock->setWindowTitle(i18nc("@title:window", "Properties: Column Statistics"));
218 raiseDockConnect(m_statisticsSpreadsheetDock, m_mainWindow->statusBar(), m_mainWindow->stackedWidget);
219 m_statisticsSpreadsheetDock->setSpreadsheets(castList<StatisticsSpreadsheet>(selectedAspects));
220 break;
221 case AspectType::Column: {
222#ifdef HAVE_CANTOR_LIBS
223 auto* casParent = dynamic_cast<Notebook*>(selectedAspects.first()->parentAspect());
224 if (casParent) {
225 // a column from a CAS-worksheets was selected, show the dock widget for the CAS worksheet
226 raiseDockConnect(m_notebookDock, m_mainWindow->statusBar(), m_mainWindow->stackedWidget);
227 m_mainWindow->m_propertiesDock->setWindowTitle(i18nc("@title:window %1 is a Cantor backend", "%1 Worksheet", casParent->backendName()));
228 m_notebookDock->setNotebooks(QList<Notebook*>{casParent});

Callers

nothing calls this directly

Calls 15

raiseDockConnectFunction · 0.85
raiseDockSetupConnectFunction · 0.85
raiseDockFunction · 0.85
currentWidgetMethod · 0.80
setWindowTitleMethod · 0.80
setWorksheetMethod · 0.80
parentAspectMethod · 0.80
backendNameMethod · 0.80
setNotebooksMethod · 0.80
setMatricesMethod · 0.80
setWorksheetsMethod · 0.80
setLegendsMethod · 0.80

Tested by

no test coverage detected