| 117 | } |
| 118 | |
| 119 | void SavedAddressesView::contextPasteCSV() |
| 120 | { |
| 121 | QString csv = QGuiApplication::clipboard()->text(); |
| 122 | // Skip header |
| 123 | csv = csv.mid(csv.indexOf('\n') + 1); |
| 124 | |
| 125 | for (const QString& line : csv.split('\n')) |
| 126 | { |
| 127 | QStringList fields; |
| 128 | // In order to handle text with commas in them we must wrap values in quotes to mark |
| 129 | // where a value starts and end so that text commas aren't identified as delimiters. |
| 130 | // So matches each quote pair, parse it out, and removes the quotes to get the value. |
| 131 | QRegularExpression each_quote_pair(R"("([^"]|\\.)*")"); |
| 132 | QRegularExpressionMatchIterator it = each_quote_pair.globalMatch(line); |
| 133 | while (it.hasNext()) |
| 134 | { |
| 135 | QRegularExpressionMatch match = it.next(); |
| 136 | QString matched_value = match.captured(0); |
| 137 | fields << matched_value.mid(1, matched_value.length() - 2); |
| 138 | } |
| 139 | |
| 140 | m_model->loadSavedAddressFromFieldList(fields); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | void SavedAddressesView::contextNew() |
| 145 | { |
nothing calls this directly
no test coverage detected