19 #include <QFileDialog>
20 #include <QGuiApplication>
21 #include <QHBoxLayout>
28 #include "../../backend/keys/cswordkey.h"
29 #include "../../backend/drivers/cswordbiblemoduleinfo.h"
30 #include "../../backend/managers/cswordbackend.h"
31 #include "../../backend/managers/referencemanager.h"
32 #include "../../util/btassert.h"
33 #include "../../util/btconnect.h"
34 #include "../../util/tool.h"
35 #include "../bibletime.h"
36 #include "../btcopybyreferencesdialog.h"
37 #include "../BtMimeData.h"
38 #include "../cexportmanager.h"
39 #include "../displaywindow/cdisplaywindow.h"
40 #include "../keychooser/ckeychooser.h"
49 , m_parentWindow(displayWindow)
51 , m_qmlInterface(m_quickWidget->qmlInterface())
52 , m_scrollBar(new QScrollBar(this))
54 auto *
const layout =
new QHBoxLayout(
this);
55 layout->setContentsMargins(0, 0, 0, 0);
57 m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
60 [
this](QString
const & reference) {
62 key->setKey(reference);
78 [
this](QString
const & reference) {
85 [
this](
const QString& moduleName,
const QString& keyName) {
86 auto & drag = *
new QDrag(
this);
88 std::make_unique<BTMimeData>(
91 if (
auto *
const module =
95 module->moduleIcon().pixmap(
97 std::unique_ptr<CSwordKey> key(module->createKey());
100 mimedata->setText(key->strippedText());
102 drag.setMimeData(mimedata.release());
103 drag.exec(Qt::CopyAction, Qt::CopyAction);
120 int speed = 25 * (1 + std::abs(value/30));
137 { QGuiApplication::clipboard()->setText(
text(part)); }
145 m_popup->exec(event->globalPos());
149 { QGuiApplication::clipboard()->setText(
qmlInterface()->getSelectedText()); }
156 if (dlg.exec() != QDialog::Accepted)
159 auto const & result = dlg.
result();
161 auto const & module = *result.module;
165 qml.copyVerseRange(
static_cast<CSwordVerseKey const &
>(*result.key1),
168 qml.copyRange(result.index1, result.index2);
173 auto const filename =
174 QFileDialog::getSaveFileName(
176 QObject::tr(
"Save document ..."),
178 QObject::tr(
"Text files") +
" (*.txt);;"
179 + QObject::tr(
"All files") +
" (*)");
180 if (!filename.isEmpty())
207 const CSBiMI *bible =
dynamic_cast<const CSBiMI*
>(module);
212 mgr.
printKey(module, startKey.
key(), stopKey.
key(), displayOptions, filterOptions);
215 mgr.
printKey(module, key->
key(), key->
key(), displayOptions, filterOptions);
229 mgr.
printKey(module, startKey.
key(), stopKey.
key(), displayOptions, filterOptions);
266 text = QStringLiteral(
"%1\n(%2, %3)")
272 if (
auto const decodedLink =
274 return decodedLink->key;
279 auto const decodedLink(
281 if (decodedLink && decodedLink->module) {
282 std::unique_ptr<CSwordKey> key(decodedLink->module->createKey());
283 key->setKey(decodedLink->key);
284 return key->strippedText();
290 auto const decodedLink(
292 if (decodedLink && decodedLink->module) {
293 std::unique_ptr<CSwordKey> key(decodedLink->module->createKey());
294 key->setKey(decodedLink->key);
299 return QStringLiteral(
"%1\n(%2, %3)")
300 .arg(key->strippedText(), key->key(), key->module()->name());
QList< BookmarkItem > ItemList
static BibleTime * instance() noexcept
Result const & result() const noexcept
CDisplayWindow * m_parentWindow
void slotSliderMoved(int value)
BtQmlInterface * qmlInterface() const noexcept
void findText(bool const backward)
void highlightText(const QString &text, bool caseSensitive)
void copySelectedText()
Copies the currently selected text.
void scrollToKey(CSwordKey *key)
void setLemma(const QString &lemma)
void setModules(QStringList const &modules)
QString text(TextPart const part=Document)
void copyAsPlainText(TextPart const part)
bool hasActiveAnchor() const
void copyByReferences()
Copies the given text specified by asking user for first and last references.
void save(TextPart const part)
Saves the given text with the specified format into the applications clipboard.
void slotSliderReleased()
BtQuickWidget *const m_quickWidget
void updateReferenceText()
BtQmlInterface *const m_qmlInterface
QScrollBar *const m_scrollBar
BtModelViewReadDisplay(CDisplayWindow *displayWindow, QWidget *parent=nullptr)
void setDisplayOptions(const DisplayOptions &displayOptions)
void print(TextPart const, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
void contextMenuEvent(QContextMenuEvent *event) final override
void setFilterOptions(FilterOptions filterOptions)
void setBibleReference(const QString &reference)
~BtModelViewReadDisplay() override
void scrollToSwordKey(CSwordKey *key)
QString getBibleUrlFromLink(const QString &url)
void dragOccuring(const QString &moduleName, const QString &keyName)
void setBibleReference(const QString &reference)
void updateReference(const QString &reference)
void setModules(const QStringList &modules)
void setHighlightWords(const QString &words, bool caseSensitivy)
void setFilterOptions(FilterOptions filterOptions)
QString const & activeLink() const noexcept
void findText(bool backward)
QString getLemmaFromLink(const QString &url)
The base class for all display windows of BibleTime.
DisplayOptions const & displayOptions() const
CKeyChooser * keyChooser() const
QToolBar * mainToolBar() const noexcept
FilterOptions const & filterOptions() const
void lookupKey(QString const &key)
void setBibleReference(const QString &reference)
bool printKey(CSwordKey const *const key, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
bool printByHyperlink(QString const &hyperlink, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
Prints a key using the hyperlink created by CReferenceManager.
static CSwordBackend & instance() noexcept
void setFilterOptions(const FilterOptions &options)
Implementation for Sword Bibles.
CSwordModuleInfo const * module() const
virtual bool setKey(const QString &key)=0
virtual QString key() const =0
QString const & name() const
CSwordKey implementation for Sword's TreeKey.
QString key() const final override
CSwordKey implementation for Sword's VerseKey.
QString key() const final override
std::optional< DecodedHyperlink > decodeHyperlink(QString const &hyperlink)