void CPlainWriteWindow::beforeKeyChange() { Q_ASSERT(displayWidget()); Q_ASSERT(keyChooser()); if (!isReady()) return; // Get current key string for this window QString thisWindowsKey; CSwordKey* oldKey = key(); if (oldKey == 0) return; thisWindowsKey = oldKey->key(); //If the text changed and we'd do a lookup ask the user if the text should be saved if (modules().first() && m_writeDisplay->isModified()) { switch (message::showQuestion( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ) { case QMessageBox::Yes: { //save the changes saveCurrentText( thisWindowsKey ); break; } default: {// set modified to false so it won't ask again m_writeDisplay->setModified(false); break; } } } }
bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, const bool addText ) { if (!list.count()) 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) ); CTextRendering::KeyTree tree; setProgressRange(list.count()); CTextRendering::KeyTreeItem::Settings itemSettings; itemSettings.highlight = false; QListIterator<CSwordKey*> it(list); while (it.hasNext() && !progressWasCancelled()) { CSwordKey* k = it.next(); tree.append( new CTextRendering::KeyTreeItem(k->key(), k->module(), itemSettings) ); incProgress(); }; const QString text = render->renderKeyTree(tree); if (!progressWasCancelled()) { CToolClass::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() ); closeProgressDialog(); return true; } return false; }
RefIndexes BtCopyByReferencesDialog::normalizeReferences(const QString& ref1, const QString& ref2) { RefIndexes ri; CSwordKey * key = m_key->copy(); key->setKey(ref1); QString x1 = key->key(); ri.index1 = m_moduleTextModel->keyToIndex(key); key->setKey(ref2); QString x2 = key->key(); ri.index2 = m_moduleTextModel->keyToIndex(key); ri.r1 = ref1; ri.r2 = ref2; if (ri.index1 > ri.index2) { ri.r1.swap(ri.r2); std::swap(ri.index1, ri.index2); } return ri; }
/** Store the settings of this window in the given CProfileWindow object. */ void CDisplayWindow::storeProfileSettings(const QString & windowGroup) { BtConfig & conf = btConfig(); conf.beginGroup(windowGroup); QWidget * w = getProfileWindow(); /** \note We don't use saveGeometry/restoreGeometry for MDI subwindows, because they give slightly incorrect results with some window managers. Might be related to Qt bug QTBUG-7634. */ const QRect rect(w->x(), w->y(), w->width(), w->height()); conf.setSessionValue<QRect>("windowRect", rect); conf.setSessionValue("maximized", w->isMaximized()); bool hasFocus = (w == dynamic_cast<CDisplayWindow *>(mdi()->activeSubWindow())); conf.setSessionValue("hasFocus", hasFocus); // conf.setSessionValue("type", static_cast<int>(modules().first()->type())); // Save current key: if (key()) { CSwordKey * k = key(); sword::VerseKey * vk = dynamic_cast<sword::VerseKey*>(k); QString oldLang; if (vk) { // Save keys in english only: const QString oldLang = QString::fromLatin1(vk->getLocale()); vk->setLocale("en"); conf.setSessionValue("key", k->key()); vk->setLocale(oldLang.toLatin1()); } else { conf.setSessionValue("key", k->key()); } } // Save list of modules: QStringList mods; Q_FOREACH (const CSwordModuleInfo * module, modules()) mods.append(module->name()); conf.setSessionValue("modules", mods); conf.endGroup(); }
bool CExportManager::copyKeyList(QList<CSwordKey*>& list, const Format format, const bool addText ) { if (!list.count()) 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) ); CTextRendering::KeyTree tree; CTextRendering::KeyTreeItem::Settings itemSettings; itemSettings.highlight = false; QListIterator<CSwordKey*> it(list); while (it.hasNext() && !progressWasCancelled()) { CSwordKey* k = it.next(); tree.append( new CTextRendering::KeyTreeItem(k->key(), k->module(), itemSettings) ); incProgress(); }; const QString text = render->renderKeyTree(tree); QApplication::clipboard()->setText(text); if (!progressWasCancelled()) { closeProgressDialog(); } return true; }