18#include "../../util/btassert.h"
19#include "../drivers/cswordbiblemoduleinfo.h"
23#pragma GCC diagnostic push
24#pragma GCC diagnostic ignored "-Wextra-semi"
25#pragma GCC diagnostic ignored "-Wsuggest-override"
26#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
29#pragma clang diagnostic push
30#pragma clang diagnostic ignored "-Wsuggest-destructor-override"
34#pragma clang diagnostic pop
37#pragma GCC diagnostic pop
48 m_key.copyFrom(bible->swordModule().getKey());
49 setKey(bible->lowerBound().key());
51 m_key.setAutoNormalize(
true);
57{
m_key.setAutoNormalize(
true); }
82 const char * newVersification =
83 static_cast<sword::VerseKey *
>(
84 bible->
swordModule().getKey())->getVersificationSystem();
85 bool inVersification =
true;
87 if (strcmp(
m_key.getVersificationSystem(), newVersification)) {
89 sword::VerseKey oldKey(
m_key);
91 m_key.setVersificationSystem(newVersification);
93 m_key.positionFrom(oldKey);
94 inVersification = !
m_key.popError();
101 if(inVersification) {
135 const CSBMI *bible =
dynamic_cast<const CSBMI*
>(
module());
136 if (bible !=
nullptr) {
138 const bool hasNT = bible->hasNewTestament();
140 if (hasOT && hasNT) {
144 else if (hasOT && !hasNT) {
148 else if (!hasOT && hasNT) {
152 else if (!hasOT && !hasNT) {
158 if ((
m_key.getTestament() >= min + 1) && (
m_key.getTestament() <= max + 1) && (
m_key.getBook() <=
m_key.BMAX[min])) {
159 return QString::fromUtf8(
m_key.getBookName());
168 return QString::fromUtf8(
m_key.isBoundSet()
169 ?
m_key.getRangeText()
174 using namespace std::string_view_literals;
175 if (
m_key.getLocale() ==
"en"sv)
177 sword::VerseKey clone(
m_key);
178 clone.setLocale(
"en");
179 return QString::fromUtf8(clone.isBoundSet()
180 ? clone.getRangeText()
187 return setKey(newKey.toUtf8().constData());
191 if(QByteArray(newKey).contains(
'-')) {
192 sword::VerseKey vk(newKey, newKey,
m_key.getVersificationSystem());
193 m_key.setLowerBound(vk.getLowerBound());
194 m_key.setUpperBound(vk.getUpperBound());
195 m_key.setPosition(sword::TOP);
198 m_key.positionFrom(newKey);
217 const int currentTestament =
m_key.getTestament();
218 const int currentBook =
m_key.getBook();
220 if ((currentTestament == 2) && (currentBook >=
m_key.BMAX[currentTestament-1])) {
223 else if ((currentTestament == 1) && (currentBook >=
m_key.BMAX[currentTestament-1])) {
224 m_key.setTestament(currentTestament + 1);
243 const bool oldStatus = m.isSkipConsecutiveLinks();
244 m.setSkipConsecutiveLinks(
true);
246 auto * vKey =
static_cast<sword::VerseKey *
>(m.getKey());
249 bool const oldHeadingsStatus = vKey->isIntros();
250 vKey->setIntros(
true);
252 vKey->setText(
key().toUtf8().constData());
256 vKey =
static_cast<sword::VerseKey *
>(m.getKey());
257 vKey->setIntros(oldHeadingsStatus);
258 m.setSkipConsecutiveLinks(oldStatus);
261 setKey(QString::fromUtf8(vKey->getText()));
265 vKey->setText(
key().toUtf8().constData());
278 const CSBMI *bible =
dynamic_cast<const CSBMI*
>(
module());
279 if (bible !=
nullptr) {
280 if (
m_key._compare(bible->lowerBound().m_key) < 0 ) {
281 setKey(bible->lowerBound().m_key);
285 if (
m_key._compare(bible->upperBound().m_key) > 0 ) {
286 setKey(bible->upperBound().m_key);
293 else if (
m_key.popError()) {
309 if ((
m_key.getBook() == 1) && (
m_key.getTestament() == 1)) {
312 else if ((
m_key.getBook() == 1) && (
m_key.getTestament() == 2)) {
313 m_key.setTestament(1);
333 auto * vKey =
static_cast<sword::VerseKey *
>(m.getKey());
334 bool const oldHeadingsStatus = vKey->isIntros();
335 vKey->setIntros(
true);
336 vKey->setText(
key().toUtf8().constData());
338 bool const oldStatus = m.isSkipConsecutiveLinks();
339 m.setSkipConsecutiveLinks(
true);
342 vKey =
static_cast<sword::VerseKey *
>(m.getKey());
343 vKey->setIntros(oldHeadingsStatus);
344 m.setSkipConsecutiveLinks(oldStatus);
349 setKey(QString::fromUtf8(vKey->getText()));
354 vKey->setText(
key().toUtf8().constData());
365 const CSBMI *bible =
dynamic_cast<const CSBMI*
>(
module());
366 if (bible !=
nullptr) {
367 if (
m_key._compare(bible->lowerBound().m_key) < 0 ) {
368 setKey(bible->lowerBound().m_key);
372 if (
m_key._compare(bible->upperBound().m_key) > 0 ) {
373 setKey(bible->upperBound().m_key);
380 else if (
m_key.popError()) {
Implementation for Sword Bibles.
CSwordVerseKey const & lowerBound() const
CSwordVerseKey const & upperBound() const
bool hasOldTestament() const
CSwordModuleInfo const * module() const
const CSwordModuleInfo * m_module
sword::SWModule & swordModule() const
CSwordKey implementation for Sword's VerseKey.
CSwordVerseKey upperBound() const
void setLowerBound(CSwordVerseKey const &bound)
~CSwordVerseKey() override
bool next(const JumpType type=JumpType::UseVerse)
void setModule(const CSwordModuleInfo *newModule) final override
CSwordVerseKey(const CSwordModuleInfo *module)
bool previous(const JumpType type=JumpType::UseVerse)
QString key() const final override
QPointer< BtSignal > m_afterChangedSignaller
bool setKey(const QString &key) final override
const BtSignal * afterChangedSignaller()
CSwordVerseKey * copy() const final override
const char * rawKey() const final override
QString normalizedKey() const final override
void setUpperBound(CSwordVerseKey const &bound)
sword::SWKey const & asSwordKey() const noexcept final override
CSwordVerseKey lowerBound() const