MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / slotImport

Method slotImport

App/Client/Favorite/FavoriteView.cpp:455–482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453}
454
455void 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
484void CFavoriteView::slotExport()
485{

Callers

nothing calls this directly

Calls 3

ImportFromJsonFileMethod · 0.80
GetErrorMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected