16 #include <QStringList>
17 #include <string_view>
18 #include "../../util/btassert.h"
19 #include "../drivers/cswordbiblemoduleinfo.h"
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wextra-semi"
24 #pragma GCC diagnostic ignored "-Wsuggest-override"
25 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
27 #pragma clang diagnostic push
28 #pragma clang diagnostic ignored "-Wsuggest-destructor-override"
32 #pragma clang diagnostic pop
34 #pragma GCC diagnostic pop
44 m_key.copyFrom(bible->swordModule().getKey());
45 setKey(bible->lowerBound().key());
47 m_key.setAutoNormalize(
true);
53 {
m_key.setAutoNormalize(
true); }
78 const char * newVersification =
79 static_cast<sword::VerseKey *
>(
80 bible->
swordModule().getKey())->getVersificationSystem();
81 bool inVersification =
true;
83 if (strcmp(
m_key.getVersificationSystem(), newVersification)) {
85 sword::VerseKey oldKey(
m_key);
87 m_key.setVersificationSystem(newVersification);
89 m_key.positionFrom(oldKey);
90 inVersification = !
m_key.popError();
131 const CSBMI *bible =
dynamic_cast<const CSBMI*
>(
module());
132 if (bible !=
nullptr) {
134 const bool hasNT = bible->hasNewTestament();
136 if (hasOT && hasNT) {
140 else if (hasOT && !hasNT) {
144 else if (!hasOT && hasNT) {
148 else if (!hasOT && !hasNT) {
154 if ((
m_key.getTestament() >= min + 1) && (
m_key.getTestament() <= max + 1) && (
m_key.getBook() <=
m_key.BMAX[min])) {
155 return QString::fromUtf8(
m_key.getBookName());
164 return QString::fromUtf8(
m_key.isBoundSet()
165 ?
m_key.getRangeText()
170 using namespace std::string_view_literals;
171 if (
m_key.getLocale() ==
"en"sv)
173 sword::VerseKey clone(
m_key);
174 clone.setLocale(
"en");
175 return QString::fromUtf8(clone.isBoundSet()
176 ? clone.getRangeText()
183 return setKey(newKey.toUtf8().constData());
187 if(QByteArray(newKey).contains(
'-')) {
188 sword::VerseKey vk(newKey, newKey,
m_key.getVersificationSystem());
189 m_key.setLowerBound(vk.getLowerBound());
190 m_key.setUpperBound(vk.getUpperBound());
191 m_key.setPosition(sword::TOP);
194 m_key.positionFrom(newKey);
213 const int currentTestament =
m_key.getTestament();
214 const int currentBook =
m_key.getBook();
216 if ((currentTestament == 2) && (currentBook >=
m_key.BMAX[currentTestament-1])) {
219 else if ((currentTestament == 1) && (currentBook >=
m_key.BMAX[currentTestament-1])) {
220 m_key.setTestament(currentTestament + 1);
239 const bool oldStatus = m.isSkipConsecutiveLinks();
240 m.setSkipConsecutiveLinks(
true);
242 auto * vKey =
static_cast<sword::VerseKey *
>(m.getKey());
245 bool const oldHeadingsStatus = vKey->isIntros();
246 vKey->setIntros(
true);
248 vKey->setText(
key().toUtf8().constData());
252 vKey =
static_cast<sword::VerseKey *
>(m.getKey());
253 vKey->setIntros(oldHeadingsStatus);
254 m.setSkipConsecutiveLinks(oldStatus);
257 setKey(QString::fromUtf8(vKey->getText()));
261 vKey->setText(
key().toUtf8().constData());
274 const CSBMI *bible =
dynamic_cast<const CSBMI*
>(
module());
275 if (bible !=
nullptr) {
276 if (
m_key._compare(bible->lowerBound().m_key) < 0 ) {
277 setKey(bible->lowerBound().m_key);
281 if (
m_key._compare(bible->upperBound().m_key) > 0 ) {
282 setKey(bible->upperBound().m_key);
289 else if (
m_key.popError()) {
305 if ((
m_key.getBook() == 1) && (
m_key.getTestament() == 1)) {
308 else if ((
m_key.getBook() == 1) && (
m_key.getTestament() == 2)) {
309 m_key.setTestament(1);
329 auto * vKey =
static_cast<sword::VerseKey *
>(m.getKey());
330 bool const oldHeadingsStatus = vKey->isIntros();
331 vKey->setIntros(
true);
332 vKey->setText(
key().toUtf8().constData());
334 bool const oldStatus = m.isSkipConsecutiveLinks();
335 m.setSkipConsecutiveLinks(
true);
338 vKey =
static_cast<sword::VerseKey *
>(m.getKey());
339 vKey->setIntros(oldHeadingsStatus);
340 m.setSkipConsecutiveLinks(oldStatus);
345 setKey(QString::fromUtf8(vKey->getText()));
350 vKey->setText(
key().toUtf8().constData());
361 const CSBMI *bible =
dynamic_cast<const CSBMI*
>(
module());
362 if (bible !=
nullptr) {
363 if (
m_key._compare(bible->lowerBound().m_key) < 0 ) {
364 setKey(bible->lowerBound().m_key);
368 if (
m_key._compare(bible->upperBound().m_key) > 0 ) {
369 setKey(bible->upperBound().m_key);
376 else if (
m_key.popError()) {
Implementation for Sword Bibles.
CSwordVerseKey const & lowerBound() const
bool hasOldTestament() const
CSwordVerseKey const & upperBound() const
const CSwordModuleInfo * m_module
CSwordModuleInfo const * module() const
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