| 277 | } |
| 278 | |
| 279 | void AddressBookPage::on_exportButton_clicked() |
| 280 | { |
| 281 | // CSV is currently the only supported format |
| 282 | QString filename = GUIUtil::getSaveFileName(this, |
| 283 | tr("Export Address List"), QString(), |
| 284 | /*: Expanded name of the CSV file format. |
| 285 | See: https://en.wikipedia.org/wiki/Comma-separated_values. */ |
| 286 | tr("Comma separated file") + QLatin1String(" (*.csv)"), nullptr); |
| 287 | |
| 288 | if (filename.isNull()) |
| 289 | return; |
| 290 | |
| 291 | CSVModelWriter writer(filename); |
| 292 | |
| 293 | // name, column, role |
| 294 | writer.setModel(proxyModel); |
| 295 | writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole); |
| 296 | writer.addColumn("Address", AddressTableModel::Address, Qt::EditRole); |
| 297 | |
| 298 | if(!writer.write()) { |
| 299 | QMessageBox::critical(this, tr("Exporting Failed"), |
| 300 | /*: An error message. %1 is a stand-in argument for the name |
| 301 | of the file we attempted to save to. */ |
| 302 | tr("There was an error trying to save the address list to %1. Please try again.").arg(filename)); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | void AddressBookPage::contextualMenu(const QPoint &point) |
| 307 | { |
nothing calls this directly
no test coverage detected