MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / databaseRestore

Method databaseRestore

nixnote.cpp:1790–1884  ·  view source on GitHub ↗

Restore (or import) notes

Source from the content-addressed store, hash-verified

1788//* Restore (or import) notes
1789//**************************************************
1790void NixNote::databaseRestore(bool fullRestore) {
1791 QLOG_TRACE() << "Entering databaseRestore()";
1792
1793 if (fullRestore) {
1794 QMessageBox msgBox;
1795 msgBox.setText(tr("This is used to restore a database from backups.\nIt is HIGHLY recommended that this only be used to populate\nan empty database. Restoring into a database that\n already has data can cause problems.\n\nAre you sure you want to continue?"));
1796 msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
1797 msgBox.setDefaultButton(QMessageBox::Ok);
1798 msgBox.setWindowTitle(tr("Confirm Restore"));
1799 int retval = msgBox.exec();
1800
1801 switch (retval) {
1802 case QMessageBox::Cancel: // Cancel was clicked, let's exit
1803 QLOG_DEBUG() << "Database restore has been canceled";
1804 return;
1805 break;
1806 default: // Anything else we don't care
1807 break;
1808 }
1809 }
1810
1811 QString caption, directory, filter;
1812
1813 if (fullRestore) {
1814 caption = tr("Restore Database");
1815 filter = tr("NixNote Export (*.nnex);;All Files (*.*)");
1816 } else {
1817 caption = tr("Import Notes");
1818 filter = tr("NixNote Export (*.nnex);;Evernote Export (*.enex);;All Files (*.*)");
1819 }
1820
1821 if (saveLastPath == "")
1822 directory = QDir::homePath();
1823 else
1824 directory = saveLastPath;
1825
1826 QFileDialog fd(0, caption, directory, filter);
1827 fd.setFileMode(QFileDialog::ExistingFile);
1828 fd.setConfirmOverwrite(true);
1829 fd.setAcceptMode(QFileDialog::AcceptOpen);
1830
1831 if (fd.exec() == 0 || fd.selectedFiles().size() == 0) {
1832 QLOG_DEBUG() << "Database restore canceled in file dialog.";
1833 return;
1834 }
1835
1836 waitCursor(true);
1837 QStringList fileNames;
1838 fileNames = fd.selectedFiles();
1839 saveLastPath = fileNames[0];
1840 int pos = saveLastPath.lastIndexOf("/");
1841 if (pos != -1)
1842 saveLastPath.truncate(pos);
1843
1844 if (fullRestore)
1845 setMessage(tr("Restoring database"));
1846 else
1847 setMessage(tr("Importing Notes"));

Callers

nothing calls this directly

Calls 5

setTextMethod · 0.45
execMethod · 0.45
importMethod · 0.45
getErrorMessageMethod · 0.45
loadDataMethod · 0.45

Tested by

no test coverage detected