"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/backend/datasources/filters/AsciiFilter.cpp" between
labplot-2.8.1.tar.gz and labplot-2.8.2.tar.gz

About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.

AsciiFilter.cpp  (labplot-2.8.1):AsciiFilter.cpp  (labplot-2.8.2)
skipping to change at line 452 skipping to change at line 452
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Parse the first line: // Parse the first line:
// Determine the number of columns, create the columns and use (if select ed) the first row to name them // Determine the number of columns, create the columns and use (if select ed) the first row to name them
QString firstLine; QString firstLine;
// skip the comment lines and read the first line // skip the comment lines and read the first line
if (!commentCharacter.isEmpty()) { if (!commentCharacter.isEmpty()) {
do { do {
if (!device.canReadLine()) if (!device.canReadLine())
DEBUG("WARNING in AsciiFilterPrivate::prepareDevi ceToRead(): device cannot 'readLine()' but using it anyway."); DEBUG(Q_FUNC_INFO << ", WARNING: device cannot 'r eadLine()' but using it anyway.");
if (device.atEnd()) { if (device.atEnd()) {
DEBUG("device at end! Giving up."); DEBUG("device at end! Giving up.");
if (device.isSequential()) if (device.isSequential())
break; break;
else else
return 1; return 1;
} }
firstLine = device.readLine(); firstLine = device.readLine();
} while (firstLine.startsWith(commentCharacter) || firstLine.simp lified().isEmpty()); } while (firstLine.startsWith(commentCharacter) || firstLine.simp lified().isEmpty());
} else } else
firstLine = device.readLine(); firstLine = device.readLine();
// navigate to the line where we asked to start reading from // navigate to the line where we asked to start reading from
DEBUG(" Skipping " << startRow - 1 << " lines"); DEBUG(Q_FUNC_INFO << ", Skipping " << startRow - 1 << " lines");
for (int i = 0; i < startRow - 1; ++i) { for (int i = 0; i < startRow - 1; ++i) {
if (!device.canReadLine()) if (!device.canReadLine())
DEBUG("WARNING in AsciiFilterPrivate::prepareDeviceToRead (): device cannot 'readLine()' but using it anyway."); DEBUG(Q_FUNC_INFO << ", WARNING: device cannot 'readLine( )' but using it anyway.");
if (device.atEnd()) { if (device.atEnd()) {
DEBUG("device at end! Giving up."); DEBUG("device at end! Giving up.");
if (device.isSequential()) if (device.isSequential())
break; break;
else else
return 1; return 1;
} }
firstLine = device.readLine(); firstLine = device.readLine();
skipping to change at line 526 skipping to change at line 526
// replace symbolic "TAB" with '\t' // replace symbolic "TAB" with '\t'
m_separator = separatingCharacter.replace(QLatin1String("2xTAB"), "\t\t", Qt::CaseInsensitive); m_separator = separatingCharacter.replace(QLatin1String("2xTAB"), "\t\t", Qt::CaseInsensitive);
m_separator = separatingCharacter.replace(QLatin1String("TAB"), " \t", Qt::CaseInsensitive); m_separator = separatingCharacter.replace(QLatin1String("TAB"), " \t", Qt::CaseInsensitive);
// replace symbolic "SPACE" with ' ' // replace symbolic "SPACE" with ' '
m_separator = m_separator.replace(QLatin1String("2xSPACE"), QLati n1String(" "), Qt::CaseInsensitive); m_separator = m_separator.replace(QLatin1String("2xSPACE"), QLati n1String(" "), Qt::CaseInsensitive);
m_separator = m_separator.replace(QLatin1String("3xSPACE"), QLati n1String(" "), Qt::CaseInsensitive); m_separator = m_separator.replace(QLatin1String("3xSPACE"), QLati n1String(" "), Qt::CaseInsensitive);
m_separator = m_separator.replace(QLatin1String("4xSPACE"), QLati n1String(" "), Qt::CaseInsensitive); m_separator = m_separator.replace(QLatin1String("4xSPACE"), QLati n1String(" "), Qt::CaseInsensitive);
m_separator = m_separator.replace(QLatin1String("SPACE"), QLatin1 String(" "), Qt::CaseInsensitive); m_separator = m_separator.replace(QLatin1String("SPACE"), QLatin1 String(" "), Qt::CaseInsensitive);
firstLineStringList = firstLine.split(m_separator, (QString::Spli tBehavior)skipEmptyParts); firstLineStringList = firstLine.split(m_separator, (QString::Spli tBehavior)skipEmptyParts);
} }
DEBUG("separator: \'" << STDSTRING(m_separator) << '\''); DEBUG(Q_FUNC_INFO << ", separator: \'" << STDSTRING(m_separator) << '\'')
DEBUG("number of columns: " << firstLineStringList.size()); ;
QDEBUG("first line: " << firstLineStringList); DEBUG(Q_FUNC_INFO << ", number of columns: " << firstLineStringList.size(
DEBUG("headerEnabled: " << headerEnabled); ));
QDEBUG(Q_FUNC_INFO << ", first line: " << firstLineStringList);
DEBUG(Q_FUNC_INFO << ", headerEnabled: " << headerEnabled);
//optionally, remove potential spaces in the first line //optionally, remove potential spaces in the first line
//TODO: this part should be obsolete actually if we do firstLine = firstL ine.simplified(); above... //TODO: this part should be obsolete actually if we do firstLine = firstL ine.simplified(); above...
if (simplifyWhitespacesEnabled) { if (simplifyWhitespacesEnabled) {
for (int i = 0; i < firstLineStringList.size(); ++i) for (int i = 0; i < firstLineStringList.size(); ++i)
firstLineStringList[i] = firstLineStringList[i].simplifie d(); firstLineStringList[i] = firstLineStringList[i].simplifie d();
} }
//in GUI in AsciiOptionsWidget we start counting from 1, subtract 1 here to start from zero //in GUI in AsciiOptionsWidget we start counting from 1, subtract 1 here to start from zero
m_actualStartRow = startRow - 1; m_actualStartRow = startRow - 1;
if (headerEnabled) { // use first line to name vectors if (headerEnabled) { // use first line to name vectors (starting from
vectorNames = firstLineStringList; startColumn)
vectorNames = firstLineStringList.mid(startColumn - 1);
++m_actualStartRow; ++m_actualStartRow;
} }
// set range to read // set range to read
if (endColumn == -1) { if (endColumn == -1) {
if (headerEnabled || vectorNames.size() == 0) if (headerEnabled || vectorNames.size() == 0)
endColumn = firstLineStringList.size(); // last column endColumn = firstLineStringList.size(); // last column
else else
//number of vector names provided in the import dialog (n ot more than the maximal number of columns in the file) //number of vector names provided in the import dialog (n ot more than the maximal number of columns in the file)
endColumn = qMin(vectorNames.size(), firstLineStringList. size()); endColumn = qMin(vectorNames.size(), firstLineStringList. size());
skipping to change at line 572 skipping to change at line 572
vectorNames.prepend(i18n("Timestamp")); vectorNames.prepend(i18n("Timestamp"));
m_actualCols++; m_actualCols++;
} }
//add index column //add index column
if (createIndexEnabled) { if (createIndexEnabled) {
vectorNames.prepend(i18n("Index")); vectorNames.prepend(i18n("Index"));
m_actualCols++; m_actualCols++;
} }
QDEBUG("vector names =" << vectorNames); QDEBUG(Q_FUNC_INFO << ", vector names =" << vectorNames);
//TEST: readline-seek-readline fails //TEST: readline-seek-readline fails
/* qint64 testpos = device.pos(); /* qint64 testpos = device.pos();
DEBUG("read data line @ pos " << testpos << " : " << STDSTRING(de vice.readLine())); DEBUG("read data line @ pos " << testpos << " : " << STDSTRING(de vice.readLine()));
device.seek(testpos); device.seek(testpos);
testpos = device.pos(); testpos = device.pos();
DEBUG("read data line again @ pos " << testpos << " : " << STDST RING(device.readLine())); DEBUG("read data line again @ pos " << testpos << " : " << STDST RING(device.readLine()));
*/ */
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
skipping to change at line 601 skipping to change at line 601
columnModes[0] = AbstractColumn::ColumnMode::Integer; columnModes[0] = AbstractColumn::ColumnMode::Integer;
++col; ++col;
} }
if (createTimestampEnabled) { if (createTimestampEnabled) {
columnModes[col] = AbstractColumn::ColumnMode::DateTime; columnModes[col] = AbstractColumn::ColumnMode::DateTime;
++col; ++col;
} }
for (auto& valueString : firstLineStringList) { // parse columns availabl e in first data line for (auto& valueString : firstLineStringList) { // parse columns availabl e in first data line
const int index{ col - startColumn + 1 };
if (index < (int)createIndexEnabled + (int)createTimestampEnabled
) {
col++;
continue;
}
if (index == m_actualCols)
break;
if (simplifyWhitespacesEnabled) if (simplifyWhitespacesEnabled)
valueString = valueString.simplified(); valueString = valueString.simplified();
if (removeQuotesEnabled) if (removeQuotesEnabled)
valueString.remove(QLatin1Char('"')); valueString.remove(QLatin1Char('"'));
if (col == m_actualCols) columnModes[index] = AbstractFileFilter::columnMode(valueString,
break; dateTimeFormat, numberFormat);
columnModes[col++] = AbstractFileFilter::columnMode(valueString, col++;
dateTimeFormat, numberFormat);
} }
for (const auto mode : columnModes)
DEBUG(Q_FUNC_INFO << ", column mode = " << static_cast<int>(mode)
);
// parsing more lines to better determine data types // parsing more lines to better determine data types
for (unsigned int i = 0; i < m_dataTypeLines; ++i) { for (unsigned int i = 0; i < m_dataTypeLines; ++i) {
if (device.atEnd()) // EOF reached if (device.atEnd()) // EOF reached
break; break;
firstLineStringList = getLineString(device); firstLineStringList = getLineString(device);
col = (int)createIndexEnabled + (int)createTimestampEnabled; col = (int)createIndexEnabled + (int)createTimestampEnabled;
for (auto& valueString : firstLineStringList) { for (auto& valueString : firstLineStringList) {
const int index{col - startColumn + 1};
if (index < (int)createIndexEnabled + (int)createTimestam
pEnabled) {
col++;
continue;
}
if (index == m_actualCols)
break;
if (simplifyWhitespacesEnabled) if (simplifyWhitespacesEnabled)
valueString = valueString.simplified(); valueString = valueString.simplified();
if (removeQuotesEnabled) if (removeQuotesEnabled)
valueString.remove(QLatin1Char('"')); valueString.remove(QLatin1Char('"'));
if (col == m_actualCols)
break;
auto mode = AbstractFileFilter::columnMode(valueString, d ateTimeFormat, numberFormat); auto mode = AbstractFileFilter::columnMode(valueString, d ateTimeFormat, numberFormat);
// numeric: integer -> numeric // numeric: integer -> numeric
if (mode == AbstractColumn::ColumnMode::Numeric && column if (mode == AbstractColumn::ColumnMode::Numeric && column
Modes[col] == AbstractColumn::ColumnMode::Integer) Modes[index] == AbstractColumn::ColumnMode::Integer)
columnModes[col] = mode; columnModes[index] = mode;
// text: non text -> text // text: non text -> text
if (mode == AbstractColumn::ColumnMode::Text && columnMod if (mode == AbstractColumn::ColumnMode::Text && columnMod
es[col] != AbstractColumn::ColumnMode::Text) es[index] != AbstractColumn::ColumnMode::Text)
columnModes[col] = mode; columnModes[index] = mode;
// numeric: text -> numeric/integer // numeric: text -> numeric/integer
if (mode != AbstractColumn::ColumnMode::Text && columnMod if (mode != AbstractColumn::ColumnMode::Text && columnMod
es[col] == AbstractColumn::ColumnMode::Text) es[index] == AbstractColumn::ColumnMode::Text)
columnModes[col] = mode; columnModes[index] = mode;
col++; col++;
} }
} }
//QDEBUG("column modes = " << columnModes); for (const auto mode : columnModes)
DEBUG(Q_FUNC_INFO << ", column mode = " << static_cast<int>(mode)
);
// ATTENTION: This resets the position in the device to 0 // ATTENTION: This resets the position in the device to 0
m_actualRows = (int)q->lineNumber(device); m_actualRows = (int)q->lineNumber(device);
const int actualEndRow = (endRow == -1 || endRow > m_actualRows) ? m_actu alRows : endRow; const int actualEndRow = (endRow == -1 || endRow > m_actualRows) ? m_actu alRows : endRow;
if (actualEndRow > m_actualStartRow) if (actualEndRow > m_actualStartRow)
m_actualRows = actualEndRow - m_actualStartRow; m_actualRows = actualEndRow - m_actualStartRow;
else else
m_actualRows = 0; m_actualRows = 0;
skipping to change at line 664 skipping to change at line 680
if (m_actualRows == 0 && !device.isSequential()) if (m_actualRows == 0 && !device.isSequential())
return 1; return 1;
return 0; return 0;
} }
/*! /*!
reads the content of the file \c fileName to the data source \c dataSource. Uses the settings defined in the data source. reads the content of the file \c fileName to the data source \c dataSource. Uses the settings defined in the data source.
*/ */
void AsciiFilterPrivate::readDataFromFile(const QString& fileName, AbstractDataS ource* dataSource, AbstractFileFilter::ImportMode importMode) { void AsciiFilterPrivate::readDataFromFile(const QString& fileName, AbstractDataS ource* dataSource, AbstractFileFilter::ImportMode importMode) {
DEBUG("AsciiFilterPrivate::readDataFromFile(): fileName = \'" << STDSTRIN G(fileName) << "\', dataSource = " DEBUG(Q_FUNC_INFO << ", fileName = \'" << STDSTRING(fileName) << "\', dat aSource = "
<< dataSource << ", mode = " << ENUM_TO_STRING(AbstractFileFilter, ImportMode, importMode)); << dataSource << ", mode = " << ENUM_TO_STRING(AbstractFileFilter, ImportMode, importMode));
//dirty hack: set readingFile and readingFileName in order to know in lin eNumber(QIODevice) //dirty hack: set readingFile and readingFileName in order to know in lin eNumber(QIODevice)
//that we're reading from a file and to benefit from much faster wc on li nux //that we're reading from a file and to benefit from much faster wc on li nux
//TODO: redesign the APIs and remove this later //TODO: redesign the APIs and remove this later
readingFile = true; readingFile = true;
readingFileName = fileName; readingFileName = fileName;
KFilterDev device(fileName); KFilterDev device(fileName);
readDataFromDevice(device, dataSource, importMode); readDataFromDevice(device, dataSource, importMode);
readingFile = false; readingFile = false;
} }
qint64 AsciiFilterPrivate::readFromLiveDevice(QIODevice& device, AbstractDataSou rce* dataSource, qint64 from) { qint64 AsciiFilterPrivate::readFromLiveDevice(QIODevice& device, AbstractDataSou rce* dataSource, qint64 from) {
DEBUG("AsciiFilterPrivate::readFromLiveDevice(): bytes available = " << d evice.bytesAvailable() << ", from = " << from); DEBUG(Q_FUNC_INFO << ", bytes available = " << device.bytesAvailable() << ", from = " << from);
if (device.bytesAvailable() <= 0) { if (device.bytesAvailable() <= 0) {
DEBUG(" No new data available"); DEBUG(" No new data available");
return 0; return 0;
} }
//TODO: may be also a matrix? //TODO: may be also a matrix?
auto* spreadsheet = dynamic_cast<LiveDataSource*>(dataSource); auto* spreadsheet = dynamic_cast<LiveDataSource*>(dataSource);
if (!spreadsheet) if (!spreadsheet)
return 0; return 0;
skipping to change at line 1164 skipping to change at line 1180
m_prepared = true; m_prepared = true;
DEBUG("AsciiFilterPrivate::readFromLiveDevice() DONE"); DEBUG("AsciiFilterPrivate::readFromLiveDevice() DONE");
return bytesread; return bytesread;
} }
/*! /*!
reads the content of device \c device to the data source \c dataSource. Uses the settings defined in the data source. reads the content of device \c device to the data source \c dataSource. Uses the settings defined in the data source.
*/ */
void AsciiFilterPrivate::readDataFromDevice(QIODevice& device, AbstractDataSourc e* dataSource, AbstractFileFilter::ImportMode importMode, int lines) { void AsciiFilterPrivate::readDataFromDevice(QIODevice& device, AbstractDataSourc e* dataSource, AbstractFileFilter::ImportMode importMode, int lines) {
DEBUG("AsciiFilterPrivate::readDataFromDevice(): dataSource = " << dataSo urce DEBUG(Q_FUNC_INFO << ", dataSource = " << dataSource
<< ", mode = " << ENUM_TO_STRING(AbstractFileFilter, ImportMode, im portMode) << ", lines = " << lines); << ", mode = " << ENUM_TO_STRING(AbstractFileFilter, ImportMode, im portMode) << ", lines = " << lines);
if (!m_prepared) { if (!m_prepared) {
const int deviceError = prepareDeviceToRead(device); const int deviceError = prepareDeviceToRead(device);
if (deviceError != 0) { if (deviceError != 0) {
DEBUG("Device error = " << deviceError); DEBUG(Q_FUNC_INFO << ", DEVICE ERROR = " << deviceError);
return; return;
} }
// matrix data has only one column mode // matrix data has only one column mode
if (dynamic_cast<Matrix*>(dataSource)) { if (dynamic_cast<Matrix*>(dataSource)) {
auto mode = columnModes[0]; auto mode = columnModes[0];
//TODO: remove this when Matrix supports text type //TODO: remove this when Matrix supports text type
if (mode == AbstractColumn::ColumnMode::Text) if (mode == AbstractColumn::ColumnMode::Text)
mode = AbstractColumn::ColumnMode::Numeric; mode = AbstractColumn::ColumnMode::Numeric;
for (auto& c : columnModes) for (auto& c : columnModes)
skipping to change at line 1214 skipping to change at line 1230
if (qMin(lines, m_actualRows) == 0 || m_actualCols == 0) if (qMin(lines, m_actualRows) == 0 || m_actualCols == 0)
return; return;
QString line; QString line;
QString valueString; QString valueString;
//Don't put the definition QStringList lineStringList outside of the for- loop, //Don't put the definition QStringList lineStringList outside of the for- loop,
//the compiler doesn't seem to optimize the destructor of QList well enou gh in this case. //the compiler doesn't seem to optimize the destructor of QList well enou gh in this case.
lines = qMin(lines, m_actualRows); lines = qMin(lines, m_actualRows);
int progressIndex = 0; int progressIndex = 0;
const float progressInterval = 0.01*lines; //update on every 1% only const qreal progressInterval = 0.01*lines; //update on every 1% only
for (int i = 0; i < lines; ++i) { for (int i = 0; i < lines; ++i) {
line = device.readLine(); line = device.readLine();
// remove any newline // remove any newline
line.remove(QLatin1Char('\n')); line.remove(QLatin1Char('\n'));
line.remove(QLatin1Char('\r')); line.remove(QLatin1Char('\r'));
if (removeQuotesEnabled) if (removeQuotesEnabled)
line.remove(QLatin1Char('"')); line.remove(QLatin1Char('"'));
skipping to change at line 1249 skipping to change at line 1265
for (int n = 0; n < lineStringList.size(); ++n) { for (int n = 0; n < lineStringList.size(); ++n) {
valueString = lineStringList.at(n); valueString = lineStringList.at(n);
if (!QString::compare(valueString, " ")) { if (!QString::compare(valueString, " ")) {
lineStringList.removeAt(n); lineStringList.removeAt(n);
n--; n--;
} }
} }
} }
//parse columns //parse columns
DEBUG(Q_FUNC_INFO << ", actual cols = " << m_actualCols)
for (int n = 0; n < m_actualCols; ++n) { for (int n = 0; n < m_actualCols; ++n) {
// index column if required // index column if required
if (n == 0 && createIndexEnabled) { if (n == 0 && createIndexEnabled) {
static_cast<QVector<int>*>(m_dataContainer[0])->o perator[](currentRow) = i + 1; static_cast<QVector<int>*>(m_dataContainer[0])->o perator[](currentRow) = i + 1;
continue; continue;
} }
//column counting starts with 1, subtract 1 as well as an other 1 for the index column if required //column counting starts with 1, subtract 1 as well as an other 1 for the index column if required
int col = createIndexEnabled ? n + startColumn - 2: n + s tartColumn - 1; int col = createIndexEnabled ? n + startColumn - 2: n + s tartColumn - 1;
QString valueString; QString valueString;
skipping to change at line 1276 skipping to change at line 1293
//ask to update the progress bar only if we have more than 1000 l ines //ask to update the progress bar only if we have more than 1000 l ines
//only in 1% steps //only in 1% steps
progressIndex++; progressIndex++;
if (lines > 1000 && progressIndex > progressInterval) { if (lines > 1000 && progressIndex > progressInterval) {
emit q->completed(100 * currentRow/lines); emit q->completed(100 * currentRow/lines);
progressIndex = 0; progressIndex = 0;
QApplication::processEvents(QEventLoop::AllEvents, 0); QApplication::processEvents(QEventLoop::AllEvents, 0);
} }
} }
DEBUG(" Read " << currentRow << " lines"); DEBUG(Q_FUNC_INFO <<", Read " << currentRow << " lines");
//we might have skipped empty lines above. shrink the spreadsheet if the number of read lines (=currentRow) //we might have skipped empty lines above. shrink the spreadsheet if the number of read lines (=currentRow)
//is smaller than the initial size of the spreadsheet (=m_actualRows). //is smaller than the initial size of the spreadsheet (=m_actualRows).
//TODO: should also be relevant for Matrix //TODO: should also be relevant for Matrix
auto* s = dynamic_cast<Spreadsheet*>(dataSource); auto* s = dynamic_cast<Spreadsheet*>(dataSource);
if (s && currentRow != m_actualRows && importMode == AbstractFileFilter:: ImportMode::Replace) if (s && currentRow != m_actualRows && importMode == AbstractFileFilter:: ImportMode::Replace)
s->setRowCount(currentRow); s->setRowCount(currentRow);
Q_ASSERT(dataSource); Q_ASSERT(dataSource);
dataSource->finalizeImport(m_columnOffset, startColumn, startColumn + m_a ctualCols - 1, dateTimeFormat, importMode); dataSource->finalizeImport(m_columnOffset, startColumn, startColumn + m_a ctualCols - 1, dateTimeFormat, importMode);
} }
//##################################################################### //#####################################################################
//############################ Preview ################################ //############################ Preview ################################
//##################################################################### //#####################################################################
/*! /*!
* preview for special devices (local/UDP/TCP socket or serial port) * preview for special devices (local/UDP/TCP socket or serial port)
*/ */
QVector<QStringList> AsciiFilterPrivate::preview(QIODevice &device) { QVector<QStringList> AsciiFilterPrivate::preview(QIODevice &device) {
DEBUG("AsciiFilterPrivate::preview(): bytesAvailable = " << device.bytesA vailable() << ", isSequential = " << device.isSequential()); DEBUG(Q_FUNC_INFO << ", bytesAvailable = " << device.bytesAvailable() << ", isSequential = " << device.isSequential());
QVector<QStringList> dataStrings; QVector<QStringList> dataStrings;
if (!(device.bytesAvailable() > 0)) { if (!(device.bytesAvailable() > 0)) {
DEBUG("No new data available"); DEBUG("No new data available");
return dataStrings; return dataStrings;
} }
if (device.isSequential() && device.bytesAvailable() < (int)sizeof(quint1 6)) if (device.isSequential() && device.bytesAvailable() < (int)sizeof(quint1 6))
return dataStrings; return dataStrings;
skipping to change at line 1392 skipping to change at line 1409
lineString += QDateTime::currentDateTime().toString(); lineString += QDateTime::currentDateTime().toString();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList lineStringList = line.split(' ', Qt::SkipEmptyParts); QStringList lineStringList = line.split(' ', Qt::SkipEmptyParts);
#else #else
QStringList lineStringList = line.split(' ', QString::SkipEmptyPa rts); QStringList lineStringList = line.split(' ', QString::SkipEmptyPa rts);
#endif #endif
QDEBUG(" line = " << lineStringList); QDEBUG(" line = " << lineStringList);
//parse columns //parse columns
DEBUG(Q_FUNC_INFO << ", number of columns = " << lineStringList.s ize())
for (int n = 0; n < lineStringList.size(); ++n) { for (int n = 0; n < lineStringList.size(); ++n) {
if (n < lineStringList.size()) { if (n < lineStringList.size()) {
QString valueString = lineStringList.at(n); QString valueString = lineStringList.at(n);
if (removeQuotesEnabled) if (removeQuotesEnabled)
valueString.remove(QLatin1Char('"')); valueString.remove(QLatin1Char('"'));
if (skipEmptyParts && !QString::compare(valueStri ng, " ")) // handle left white spaces if (skipEmptyParts && !QString::compare(valueStri ng, " ")) // handle left white spaces
continue; continue;
lineString += previewValue(valueString, columnMod es[n+offset]); lineString += previewValue(valueString, columnMod es[n+offset]);
skipping to change at line 1517 skipping to change at line 1535
} }
//##################################################################### //#####################################################################
//####################### Helper functions ############################ //####################### Helper functions ############################
//##################################################################### //#####################################################################
/*! /*!
* converts \c valueString to the date type according to \c mode and \c locale * converts \c valueString to the date type according to \c mode and \c locale
* and returns its string representation. * and returns its string representation.
*/ */
QString AsciiFilterPrivate::previewValue(const QString& valueString, AbstractCol umn::ColumnMode mode) { QString AsciiFilterPrivate::previewValue(const QString& valueString, AbstractCol umn::ColumnMode mode) {
DEBUG(Q_FUNC_INFO << ", valueString = " << valueString.toStdString() << "
, mode = " << (int)mode)
QString result; QString result;
switch (mode) { switch (mode) {
case AbstractColumn::ColumnMode::Numeric: { case AbstractColumn::ColumnMode::Numeric: {
bool isNumber; bool isNumber;
const double value = locale.toDouble(valueString, &isNumber); const double value = locale.toDouble(valueString, &isNumber);
result = QString::number(isNumber ? value : nanValue, 'g', 15); result = QString::number(isNumber ? value : nanValue, 'g', 15);
break; break;
} }
case AbstractColumn::ColumnMode::Integer: { case AbstractColumn::ColumnMode::Integer: {
bool isNumber; bool isNumber;
 End of changes. 25 change blocks. 
33 lines changed or deleted 61 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)