| 453 | } |
| 454 | |
| 455 | void CFavoriteView::slotImport() |
| 456 | { |
| 457 | QString filename = QFileDialog::getOpenFileName( |
| 458 | this, tr("Import favorite"), |
| 459 | RabbitCommon::CDir::Instance()->GetDirUserDocument(), |
| 460 | tr("JSON (*.json)")); |
| 461 | |
| 462 | if (!filename.isEmpty()) { |
| 463 | QFileInfo fi(filename); |
| 464 | if(0 == fi.suffix().compare("json", Qt::CaseInsensitive)) { |
| 465 | if (m_pDatabase->ImportFromJsonFile(filename)) { |
| 466 | slotRefresh(); |
| 467 | QMessageBox::information( |
| 468 | this, tr("Success"), |
| 469 | tr("Successfully imported favorite from JSON file: %1").arg(filename)); |
| 470 | } else { |
| 471 | QString szErr = tr("Failed to import favorite from JSON file: %1").arg(filename) + "\n"; |
| 472 | if(!m_pDatabase->GetError().isEmpty()) |
| 473 | szErr += "\n" + tr("Error: ") + m_pDatabase->GetError(); |
| 474 | QMessageBox::critical(this, tr("Failure"), szErr); |
| 475 | } |
| 476 | return; |
| 477 | } |
| 478 | QMessageBox::warning(this, tr("Import favorite"), |
| 479 | tr("Invalid file: %1").arg(filename) + "\n\n" |
| 480 | + tr("Please use JSON file")); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | void CFavoriteView::slotExport() |
| 485 | { |
nothing calls this directly
no test coverage detected