bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool addText) { if (!key) { return false; } if (!key->module()) { return false; } const QString filename = getSaveFileName(format); if (filename.isEmpty()) { return false; } CSwordBackend::FilterOptions filterOptions = m_filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; filterOptions.lemmas = false; filterOptions.scriptureReferences = false; filterOptions.textualVariants = false; CHTMLExportRendering::Settings settings(addText); boost::scoped_ptr<CTextRendering> render ( (format == HTML) ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions) : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions) ); QString text; QString startKey; QString stopKey; QList<CSwordModuleInfo*> modules; modules.append(key->module()); CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key); if (vk && vk->isBoundSet()) { text = render->renderKeyRange( QString::fromUtf8(vk->LowerBound()), QString::fromUtf8(vk->UpperBound()), modules ); } else { //no range supported text = render->renderSingleKey(key->key(), modules); } if (!progressWasCancelled()) { CToolClass::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() ); closeProgressDialog(); return true; } return false; }
bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool addText) { if (!key) { return false; } if (!key->module()) { return false; } CSwordBackend::FilterOptions filterOptions = m_filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; filterOptions.lemmas = false; filterOptions.scriptureReferences = false; filterOptions.textualVariants = false; CHTMLExportRendering::Settings settings(addText); boost::scoped_ptr<CTextRendering> render ( (format == HTML) ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions) : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions) ); QString text; QString startKey; QString stopKey; QList<CSwordModuleInfo*> modules; modules.append(key->module()); CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key); if (vk && vk->isBoundSet()) { text = render->renderKeyRange( QString::fromUtf8(vk->LowerBound()), QString::fromUtf8(vk->UpperBound()), modules ); } else { //no range supported text = render->renderSingleKey(key->key(), modules); } QApplication::clipboard()->setText(text); return true; }