15 #include <QApplication>
17 #include <QFileDialog>
19 #include <QProgressDialog>
20 #include <QTextStream>
21 #include "../backend/drivers/cswordmoduleinfo.h"
22 #include "../backend/keys/cswordkey.h"
23 #include "../backend/keys/cswordversekey.h"
24 #include "../backend/managers/referencemanager.h"
25 #include "../backend/rendering/cplaintextexportrendering.h"
26 #include "../backend/rendering/ctextrendering.h"
27 #include "../util/btassert.h"
28 #include "../util/tool.h"
41 QString
const & progressLabel,
44 : m_filterOptions(filterOptions)
45 , m_displayOptions(displayOptions)
50 std::make_unique<QProgressDialog>(
nullptr, Qt::Dialog);
51 dialog->setWindowTitle(QStringLiteral(
"BibleTime"));
52 dialog->setLabelText(progressLabel);
65 if (!key || !key->
module())
68 if (filename.isEmpty())
77 text = render->renderKeyRange(vk->
lowerBound(),
80 text.replace(QStringLiteral(
"#CHAPTERTITLE#"),
81 QStringLiteral(
"%1 %2")
83 .arg(QString::number(vk->
chapter())));
84 text.replace(QStringLiteral(
"#TEXT_ALIGN#"),
85 QStringLiteral(
"right"));
87 text = render->renderSingleKey(key->
key(), modules);
103 if (filename.isEmpty())
112 for (
auto const & keyPtr : l) {
115 tree.emplace_back(QString::fromLocal8Bit(keyPtr->getText()),
121 QString
const text =
newRenderer(format, addText)->renderKeyTree(tree);
135 if (filename.isEmpty())
147 tree.emplace_back(k->key(), k->module(), itemSettings);
151 QString
const text =
newRenderer(format, addText)->renderKeyTree(tree);
160 { QApplication::clipboard()->setText(std::forward<Arg>(arg)); }
168 if (!key || !key->
module())
173 modules.append(key->
module());
180 text = render->renderKeyRange(vk->
lowerBound(),
184 text = render->renderSingleKey(key->
key(), modules);
204 for (
auto const & keyPtr : l) {
207 tree.emplace_back(QString::fromLocal8Bit(keyPtr->getText()),
233 tree.emplace_back(k->key(), k->module(), itemSettings);
249 displayOptions.verseNumbers ? Settings::SimpleKey : Settings::NoKey}
260 PrintSettings settings{displayOptions};
262 tree.emplace_back(key->
key(), key->
module(), settings);
263 BtPrinter{displayOptions, filterOptions}.printKeyTree(tree);
268 QString
const & startKey,
269 QString
const & stopKey,
273 PrintSettings settings{displayOptions};
275 if (startKey != stopKey) {
276 tree.emplace_back(startKey, stopKey, module, settings);
278 tree.emplace_back(startKey, module, settings);
280 BtPrinter{displayOptions, filterOptions}.printKeyTree(tree);
289 if (!decodedLink && !decodedLink->module)
291 auto const *
const module = decodedLink->module;
292 auto const & keyName = decodedLink->key;
295 PrintSettings settings{displayOptions};
300 sword::ListKey
const verses =
301 sword::VerseKey().parseVerseList(
302 keyName.toUtf8().constData(),
306 for (
int i = 0; i < verses.getCount(); i++) {
307 if (sword::VerseKey
const *
const element =
308 dynamic_cast<sword::VerseKey
const *
>(verses.getElement(i)))
312 element->getLowerBound().getText()),
314 element->getUpperBound().getText()),
317 }
else if (verses.getElement(i)) {
319 QString::fromUtf8(verses.getElement(i)->getText()),
325 tree.emplace_back(keyName, module, settings);
327 BtPrinter{displayOptions, filterOptions}.printKeyTree(tree);
339 PrintSettings settings{displayOptions};
343 for (
auto const & keyPtr : list) {
346 QString
const key = keyPtr->getText();
347 tree.emplace_back(key, key, module, settings);
350 BtPrinter{displayOptions, filterOptions}.printKeyTree(tree);
363 PrintSettings settings{displayOptions};
367 for (QString
const & key: list) {
370 tree.emplace_back(key, module, settings);
373 BtPrinter{displayOptions, filterOptions}.printKeyTree(tree);
383 filter = QObject::tr(
"HTML files") +
" (*.html *.htm);;";
386 filter = QObject::tr(
"Text files") +
" (*.txt);;";
389 filter += QObject::tr(
"All files") + QStringLiteral(
" (*)");
391 return QFileDialog::getSaveFileName(
nullptr,
392 QObject::tr(
"Save file"),
405 filterOptions.
lemmas =
false;
409 using R = std::unique_ptr<CTextRendering>;
429 qApp->processEvents();
448 qApp->processEvents();
QList< CSwordModuleInfo const * > BtConstModuleList
Manages the print item queue and printing.
std::unique_ptr< QProgressDialog > const m_progressDialog
bool progressWasCancelled()
bool printKey(CSwordKey const *const key, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
std::unique_ptr< Rendering::CTextRendering > newRenderer(Format const format, bool const addText)
void setProgressRange(int const items)
FilterOptions const m_filterOptions
bool printByHyperlink(QString const &hyperlink, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
Prints a key using the hyperlink created by CReferenceManager.
bool printKeyList(CSwordModuleSearch::ModuleResultList const &list, CSwordModuleInfo const *const module, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
bool copyKeyList(CSwordModuleSearch::ModuleResultList const &list, CSwordModuleInfo const *const module, Format const format, bool const addText)
void incProgress()
Increments the progress by one item.
const QString getSaveFileName(Format const format)
bool saveKey(CSwordKey const *const key, Format const format, bool const addText, const BtConstModuleList &modules)
CExportManager(const bool showProgress=true, const QString &progressLabel=QString(), const FilterOptions &filterOptions=btConfig().getFilterOptions(), const DisplayOptions &displayOptions=btConfig().getDisplayOptions())
bool saveKeyList(CSwordModuleSearch::ModuleResultList const &list, CSwordModuleInfo const *const module, Format const format, bool const addText)
void closeProgressDialog()
Closes the progress dialog immediately.
bool copyKey(CSwordKey const *const key, Format const format, bool const addText)
DisplayOptions const m_displayOptions
CSwordModuleInfo const * module() const
virtual QString key() const =0
CSwordKey implementation for Sword's VerseKey.
CSwordVerseKey upperBound() const
CSwordVerseKey lowerBound() const
Text rendering as plain text.
Text rendering based on trees.
std::list< KeyTreeItem > KeyTree
std::vector< std::shared_ptr< sword::SWKey const > > ModuleResultList
std::optional< DecodedHyperlink > decodeHyperlink(QString const &hyperlink)
bool filter(WizardTaskType const taskType, QStringList const &languages, CSwordModuleInfo const *const mInfo)
void copyToClipboard(Arg &&arg)
PrintSettings(DisplayOptions const &displayOptions)