mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-23 23:13:39 -06:00
CSV import dialog. Use html table in preview text box
This commit is contained in:
parent
6d4820a691
commit
4b14a4fdda
@ -325,6 +325,7 @@ void RicPasteAsciiDataToSummaryPlotFeatureUi::defineEditorAttribute(const caf::P
|
||||
|
||||
QFont font("Monospace", 7);
|
||||
attrib->font = font;
|
||||
attrib->textMode = caf::PdmUiTextEditorAttribute::HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,17 +123,31 @@ QString RifCsvUserDataParser::previewText(int lineCount, const QString& cellSepa
|
||||
QString preview;
|
||||
QTextStream outStream(&preview);
|
||||
int iLine = 0;
|
||||
bool header = true;
|
||||
|
||||
outStream << "<Table>";
|
||||
outStream << "<Style> th, td {padding-right: 15px;} </Style>";
|
||||
while (iLine < lineCount && !stream->atEnd())
|
||||
{
|
||||
QString line = stream->readLine();
|
||||
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
outStream << line;
|
||||
outStream << "\n";
|
||||
outStream << "<tr>";
|
||||
for (const QString& cellData : splitLineAndTrim(line, cellSeparator))
|
||||
{
|
||||
outStream << (header ? "<th>" : "<td>");
|
||||
outStream << cellData;
|
||||
outStream << (header ? "</th>" : "</td>");
|
||||
}
|
||||
outStream << "</tr>";
|
||||
|
||||
header = false;
|
||||
iLine++;
|
||||
}
|
||||
|
||||
outStream << "</Table>";
|
||||
|
||||
closeDataStream();
|
||||
return columnifyText(preview, cellSeparator);
|
||||
}
|
||||
@ -405,7 +419,7 @@ QString RifCsvUserDataParser::tryDetermineDecimalSeparator(const QString& cellSe
|
||||
QString line = dataStream->readLine();
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
for (QString cellData : splitLineAndTrim(line, cellSeparator))
|
||||
for (const QString& cellData : splitLineAndTrim(line, cellSeparator))
|
||||
{
|
||||
bool parseOk;
|
||||
QLocale locale;
|
||||
|
Loading…
Reference in New Issue
Block a user