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

Method refreshPreview

src/frontend/datasources/ImportFileWidget.cpp:1758–2173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1756}
1757
1758void ImportFileWidget::refreshPreview() {
1759 DEBUG(Q_FUNC_INFO)
1760 // don't generate any preview if it was explicitly suppressed
1761 // or if the options box together with the preview widget is not visible
1762 if (m_suppressRefresh || !ui.gbOptions->isVisible())
1763 return;
1764
1765 auto* currentFilter = currentFileFilter();
1766 currentFilter->setLastError(QString()); // clear the last error message, if any available
1767
1768 auto path = absolutePath(fileName());
1769 const auto sourceType = currentSourceType();
1770
1771 if (sourceType == LiveDataSource::SourceType::FileOrPipe && path.isEmpty())
1772 return; // initial open with no file selected yet, nothing to preview
1773
1774 const auto fileType = currentFileType();
1775 DEBUG(Q_FUNC_INFO << ", Data File Type: " << ENUM_TO_STRING(AbstractFileFilter, FileType, fileType));
1776 const auto& dbcFile = dbcFileName();
1777 int lines = ui.sbPreviewLines->value();
1778 currentFilter->setPreviewPrecision(ui.sbPreviewPrecision->value());
1779
1780 // default preview widget
1781 if (fileType == AbstractFileFilter::FileType::Ascii || fileType == AbstractFileFilter::FileType::Binary || fileType == AbstractFileFilter::FileType::JSON
1782 || fileType == AbstractFileFilter::FileType::MCAP || fileType == AbstractFileFilter::FileType::Spice
1783 || fileType == AbstractFileFilter::FileType::VECTOR_BLF || fileType == AbstractFileFilter::FileType::READSTAT)
1784 m_twPreview->show();
1785 else
1786 m_twPreview->hide();
1787
1788 bool ok = true;
1789 auto* tmpTableWidget = m_twPreview;
1790 QVector<QStringList> importedStrings;
1791 QStringList vectorNameList;
1792 QVector<AbstractColumn::ColumnMode> columnModes;
1793
1794 WAIT_CURSOR_AUTO_RESET;
1795
1796 QString errorMessage;
1797
1798 switch (fileType) {
1799 case AbstractFileFilter::FileType::Ascii: {
1800 ui.tePreview->clear();
1801
1802 auto filter = static_cast<AsciiFilter*>(currentFilter);
1803 const auto& properties = filter->properties();
1804 if (properties.endRow > 0)
1805 lines = properties.endRow - properties.startRow + 1;
1806 if (lines <= 0) {
1807 Q_EMIT error(i18n("Invalid number rows. Please check 'End Row' and 'Start Row'. 'End Row' must be larger than 'Start Row' or -1"));
1808 return;
1809 }
1810 filter->clearLastError();
1811 filter->clearLastWarnings();
1812
1813 // sequential
1814 if (!automaticAllowed(sourceType)) {
1815 auto p = filter->properties();

Callers 5

selectionChangedMethod · 0.45
testQueryMethod · 0.45

Calls 15

delayFunction · 0.85
setPreviewPrecisionMethod · 0.80
showMethod · 0.80
clearLastErrorMethod · 0.80
clearLastWarningsMethod · 0.80
lastErrorMethod · 0.80
toStdStringMethod · 0.80
setBaudRateMethod · 0.80
errorMethod · 0.80
currentItemMethod · 0.80
columnNamesMethod · 0.80

Tested by 1

testQueryMethod · 0.36