| 482 | } |
| 483 | |
| 484 | void CFavoriteView::slotExport() |
| 485 | { |
| 486 | QString filename = QFileDialog::getSaveFileName( |
| 487 | this, tr("Export favorite"), |
| 488 | RabbitCommon::CDir::Instance()->GetDirUserDocument(), |
| 489 | tr("JSON (*.json)")); |
| 490 | |
| 491 | if (!filename.isEmpty()) { |
| 492 | QFileInfo fi(filename); |
| 493 | if(0 == fi.suffix().compare("json", Qt::CaseInsensitive)) { |
| 494 | if (m_pDatabase->ExportToJsonFile(filename)) { |
| 495 | QMessageBox::information( |
| 496 | this, tr("Success"), |
| 497 | tr("Favorite successfully exported to JSON file: %1").arg(filename)); |
| 498 | } else { |
| 499 | QString szErr = tr("Failed to import favorite from JSON file: %1").arg(filename) + "\n"; |
| 500 | if(!m_pDatabase->GetError().isEmpty()) |
| 501 | szErr += "\n" + tr("Error: ") + m_pDatabase->GetError(); |
| 502 | QMessageBox::critical(this, tr("Failure"), szErr); |
| 503 | } |
| 504 | return; |
| 505 | } |
| 506 | QMessageBox::critical(this, tr("Failure"), |
| 507 | tr("Invalid file: %1").arg(filename) + "\n\n" |
| 508 | + tr("Please use JSON file")); |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | void CFavoriteView::InitialDragDrop() |
| 513 | { |
nothing calls this directly
no test coverage detected