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

Method selectedObject

src/frontend/datasources/ImportFileWidget.cpp:602–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

600}
601
602QString ImportFileWidget::selectedObject() const {
603 DEBUG(Q_FUNC_INFO)
604 const QString& path = fileName();
605
606 // determine the file name only
607 QString name = path.right(path.length() - path.lastIndexOf(QLatin1Char('/')) - 1);
608
609 // strip away the extension if existing
610 if (name.indexOf(QLatin1Char('.')) != -1)
611 name = name.left(name.lastIndexOf(QLatin1Char('.')));
612
613 // for multi-dimensional formats add the currently selected object
614 const auto format = currentFileType();
615 if (format == AbstractFileFilter::FileType::HDF5) {
616 const QStringList& names = m_hdf5OptionsWidget->selectedNames();
617 if (!names.isEmpty())
618 name += names.first(); // the names of the selected HDF5 objects already have '/'
619 } else if (format == AbstractFileFilter::FileType::NETCDF) {
620 const QStringList& names = m_netcdfOptionsWidget->selectedNames();
621 if (!names.isEmpty())
622 name += QLatin1Char('/') + names.first();
623 } else if (format == AbstractFileFilter::FileType::FITS) {
624 const QString& extensionName = m_fitsOptionsWidget->currentExtensionName();
625 if (!extensionName.isEmpty())
626 name += QLatin1Char('/') + extensionName;
627 } else if (format == AbstractFileFilter::FileType::ROOT) {
628 const QStringList& names = m_rootOptionsWidget->selectedNames();
629 if (!names.isEmpty())
630 name += QLatin1Char('/') + names.first();
631 } else if (format == AbstractFileFilter::FileType::MATIO) {
632 const QStringList& names = m_matioOptionsWidget->selectedNames();
633 if (!names.isEmpty())
634 name += QLatin1Char('/') + names.first();
635 } else if (format == AbstractFileFilter::FileType::XLSX) {
636 const auto& names = m_xlsxOptionsWidget->selectedXLSXRegionNames();
637 if (!names.isEmpty())
638 name += QLatin1Char('/') + names.first();
639 } else if (format == AbstractFileFilter::FileType::Ods) {
640 const auto& names = m_odsOptionsWidget->selectedOdsSheetNames();
641 QDEBUG(Q_FUNC_INFO << ", selected sheet names =")
642 if (!names.isEmpty()) { // name == "start-end", names.first() == "start-end.ods!Sheet2"
643 name += QLatin1Char('!') + names.first().split(QLatin1Char('!')).last();
644 }
645 }
646 return name;
647}
648
649QString ImportFileWidget::host() const {
650 const auto t = ui.leHost->text();

Callers

nothing calls this directly

Calls 8

lengthMethod · 0.80
splitMethod · 0.80
indexOfMethod · 0.45
selectedNamesMethod · 0.45
isEmptyMethod · 0.45
currentExtensionNameMethod · 0.45
selectedOdsSheetNamesMethod · 0.45

Tested by

no test coverage detected