Compose row string from values @input: - values - list of values in rows @output: - QString - result row string
| 105 | // @output: |
| 106 | // - QString - result row string |
| 107 | QString ContentIterator::composeRow(const QStringList& values) const |
| 108 | { |
| 109 | QStringList rowValues = values; |
| 110 | const QString twoDelimiters = m_textDelimiter + m_textDelimiter; |
| 111 | for (int i = 0; i < rowValues.size(); ++i) |
| 112 | { |
| 113 | rowValues[i].replace(m_textDelimiter, twoDelimiters); |
| 114 | |
| 115 | QString delimiter = m_textDelimiter; |
| 116 | if (delimiter.isEmpty() && |
| 117 | (rowValues.at(i).contains(m_separator) || |
| 118 | rowValues.at(i).contains(CR) || |
| 119 | rowValues.at(i).contains(LF))) |
| 120 | { |
| 121 | delimiter = DOUBLE_QUOTE; |
| 122 | } |
| 123 | |
| 124 | rowValues[i].prepend(delimiter); |
| 125 | rowValues[i].append(delimiter); |
| 126 | } |
| 127 | |
| 128 | QString result = rowValues.join(m_separator); |
| 129 | result.append(LF); |
| 130 | |
| 131 | return result; |
| 132 | } |