mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
ASCII import dialog. Update preview when cell separator is modified
This commit is contained in:
@@ -97,7 +97,7 @@ bool RifCsvUserDataParser::parseColumnInfo(const QString& cellSeparator)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifCsvUserDataParser::previewText(int lineCount)
|
||||
QString RifCsvUserDataParser::previewText(int lineCount, const QString& cellSeparator)
|
||||
{
|
||||
QTextStream *stream = openDataStream();
|
||||
|
||||
@@ -118,7 +118,7 @@ QString RifCsvUserDataParser::previewText(int lineCount)
|
||||
iLine++;
|
||||
}
|
||||
closeDataStream();
|
||||
return columnifyText(preview);
|
||||
return columnifyText(preview, cellSeparator);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -291,16 +291,15 @@ bool RifCsvUserDataParser::parseData(const AsciiDataParseOptions& parseOptions)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifCsvUserDataParser::columnifyText(const QString& text)
|
||||
QString RifCsvUserDataParser::columnifyText(const QString& text, const QString& cellSeparator)
|
||||
{
|
||||
QString pretty = text;
|
||||
|
||||
QString cellSep = tryDetermineCellSeparator();
|
||||
if (!cellSep.isEmpty())
|
||||
if (!cellSeparator.isEmpty())
|
||||
{
|
||||
if (cellSep == ";" || cellSep == ",")
|
||||
if (cellSeparator == ";" || cellSeparator == ",")
|
||||
{
|
||||
pretty = pretty.replace(cellSep, QString("\t") + cellSep);
|
||||
pretty = pretty.replace(cellSeparator, QString("\t") + cellSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
const ColumnInfo* columnInfo(size_t columnIndex) const;
|
||||
|
||||
bool parseColumnInfo(const QString& cellSeparator);
|
||||
QString previewText(int lineCount);
|
||||
QString previewText(int lineCount, const QString& cellSeparator);
|
||||
|
||||
QString tryDetermineCellSeparator();
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
const QString& cellSeparator,
|
||||
std::vector<ColumnInfo>* columnInfoList);
|
||||
bool parseData(const AsciiDataParseOptions& parseOptions);
|
||||
QString columnifyText(const QString& text);
|
||||
QString columnifyText(const QString& text, const QString& cellSeparator);
|
||||
static QStringList splitLineAndTrim(const QString& line, const QString& separator);
|
||||
static QDateTime tryParseDateTime(const std::string& colData, const QString& format);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user