/// <summary> /// Prompt the user and delete the notebok (if they say so). /// </summary> /// <param name="parent"> /// A <see cref="Gtk.Window"/> /// </param> /// <param name="notebook"> /// A <see cref="Notebook"/> /// </param> void NotebookManager::prompt_delete_notebook(Gtk::Window * parent, const Notebook::Ptr & notebook) { // Confirmation Dialog utils::HIGMessageDialog dialog(parent, GTK_DIALOG_MODAL, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, _("Really delete this notebook?"), _("The notes that belong to this notebook will not be " "deleted, but they will no longer be associated with " "this notebook. This action cannot be undone.")); dialog.set_default_response(Gtk::RESPONSE_NO); int response = dialog.run (); if (response != Gtk::RESPONSE_YES) { return; } // Grab the template note before removing all the notebook tags Note::Ptr templateNote = notebook->get_template_note (); instance().delete_notebook (notebook); // Delete the template note if (templateNote) { NoteManager & noteManager(Gnote::obj().default_note_manager()); noteManager.delete_note (templateNote); } }
void WizCombineNotesDialog::accept() { if (WizMainWindow* mainWindow = WizMainWindow::instance()) { WizUserSettings& settings = mainWindow->userSettings(); QString splitter = ui->editSplitter->text(); if (splitter.isEmpty()) { splitter = "<!--none-->"; } settings.set("CombineNote", "splitter", splitter); // settings.set("CombineNote", "addTitle", ui->btnAddTitle->isChecked() ? "1" : "0"); } // QString strResultFileName; CWizDocumentAttachmentDataArray arrayAttachment; QString strError; bool ret = WizKMCombineDocumentsToHtmlFile(m_dbMgr, getResultDocuments(), ui->editSplitter->text(), ui->btnAddTitle->isChecked(), strResultFileName, arrayAttachment, strError); if (!ret) { WizMessageBox::critical(this, tr("Failed to combine note: %1").arg(strError)); return; } // QString folder = Utils::WizMisc::extractFilePath(strResultFileName); QString strZiwFileName = folder + WizGenGUIDLowerCaseLetterOnly() + ".ziw"; bool bZip = ::WizFolder2Zip(folder, strZiwFileName); if (!bZip) { WizMessageBox::critical(this, tr("Info"), tr("Failled to compress notes data")); return; } // WIZDOCUMENTDATA doc = m_documents[0]; doc.strGUID.clear(); doc.strTitle = ui->editNewTitle->text(); // WizNoteManager noteManager(m_dbMgr); if (!noteManager.createNoteByTemplate(doc, WIZTAGDATA(), strZiwFileName)) { WizMessageBox::critical(this, tr("Info"), tr("Failed to create new data")); return; } // for (auto att: arrayAttachment) { WizDatabase& db = m_dbMgr.db(att.strKbGUID); // WIZDOCUMENTATTACHMENTDATA attRet; if (!db.addAttachment(doc, db.getAttachmentFileName(att.strGUID), attRet)) { WizMessageBox::critical(this, tr("Info"), tr("Failed to add attachment")); return; } // attRet.strName = att.strName; db.updateAttachment(attRet); } // if (WizMainWindow* mainWindow = WizMainWindow::instance()) { if (WizDocumentListView* list = mainWindow->documentList()) { int index = list->documentIndexFromGUID(doc.strGUID); if (index != -1) { WizDocumentListViewDocumentItem* pItem = list->documentItemAt(index); pItem->document().tCreated = pItem->document().tCreated.addSecs(-5); } else { doc.tCreated = doc.tCreated.addSecs(-5); //避免自动进入编辑模式 } // list->addAndSelectDocument(doc); } } // QDialog::accept(); }