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

Method currentFileFilter

src/frontend/datasources/ImportFileWidget.cpp:737–1002  ·  view source on GitHub ↗

! returns the currently used filter. */

Source from the content-addressed store, hash-verified

735 returns the currently used filter.
736*/
737AbstractFileFilter* ImportFileWidget::currentFileFilter() const {
738 auto fileType = currentFileType();
739 if (m_currentFilter && m_currentFilter->type() != fileType)
740 m_currentFilter.reset();
741
742 switch (fileType) {
743 case AbstractFileFilter::FileType::Ascii: {
744 DEBUG(Q_FUNC_INFO << ", ASCII");
745 if (!m_currentFilter)
746 m_currentFilter.reset(new AsciiFilter);
747 auto filter = static_cast<AsciiFilter*>(m_currentFilter.get());
748 auto properties = filter->defaultProperties();
749
750 // set the data portion to import
751 properties.startRow = ui.sbStartRow->value();
752 properties.endRow = ui.sbEndRow->value();
753 properties.startColumn = ui.sbStartColumn->value();
754 properties.endColumn = ui.sbEndColumn->value();
755
756 const bool automatic = ui.cbFilter->currentIndex() == FilterSettingsHandlingIndex::Automatic;
757 if ((!m_liveDataSource || currentSourceType() == LiveDataSource::SourceType::FileOrPipe) && automatic) {
758 properties.automaticSeparatorDetection = true;
759 properties.removeQuotes = true;
760 if (m_asciiOptionsWidget)
761 m_asciiOptionsWidget->updateWidgets(properties);
762 } else { //"custom" and templates
763 properties.automaticSeparatorDetection = false;
764
765 // set the remaining filter settings
766 if (m_asciiOptionsWidget && !automatic)
767 m_asciiOptionsWidget->applyFilterSettings(properties);
768 }
769 // Both required, because initialize might fail and then no properties are set
770 // Initialize is required for livedata (sequential devices)
771 filter->setProperties(properties);
772 filter->initialize(properties);
773
774 break;
775 }
776 case AbstractFileFilter::FileType::Binary: {
777 DEBUG(Q_FUNC_INFO << ", Binary");
778 if (!m_currentFilter)
779 m_currentFilter.reset(new BinaryFilter);
780 auto filter = static_cast<BinaryFilter*>(m_currentFilter.get());
781
782 if (ui.cbFilter->currentIndex() == FilterSettingsHandlingIndex::Automatic)
783 filter->setAutoModeEnabled(true);
784 else { //"custom" and templates
785 filter->setAutoModeEnabled(false);
786 if (m_binaryOptionsWidget)
787 m_binaryOptionsWidget->applyFilterSettings(filter);
788 }
789
790 filter->setStartRow(ui.sbStartRow->value());
791 filter->setEndRow(ui.sbEndRow->value());
792
793 break;
794 }

Callers 6

sheetSelectionChangedMethod · 0.80
importToMethod · 0.80
importToSpreadsheetMethod · 0.80

Calls 15

defaultPropertiesMethod · 0.80
setPropertiesMethod · 0.80
setAutoModeEnabledMethod · 0.80
splitMethod · 0.80
setCurrentRangeMethod · 0.80
setCurrentSheetMethod · 0.80
setSelectedSheetNamesMethod · 0.80
setImportFormatMethod · 0.80
currentFormatMethod · 0.80
setCurrentDataSetNameMethod · 0.80
setDBCFileMethod · 0.80
extensionNameMethod · 0.80

Tested by

no test coverage detected