// Also tests key() void test_CSwordVerseKey::setKey() { QFETCH(QString, moduleName); QFETCH(QString, reference); CSwordBackend* backend = CSwordBackend::instance(); CSwordModuleInfo* module = backend->findModuleByName(moduleName); QVERIFY(module != 0); CSwordVerseKey* vKey = dynamic_cast<CSwordVerseKey*>(CSwordKey::createInstance(module)); vKey->setKey(reference); QString newKey = vKey->key(); QCOMPARE(newKey, reference); }
QString BtModuleTextModel::indexToKeyName(int index) const { QString keyName = "???"; if (isBible() || isCommentary()) { CSwordVerseKey key = indexToVerseKey(index); keyName = key.key(); } else if (isBook()) { CSwordTreeKey key = indexToBookKey(index); keyName = key.key(); } else if (isLexicon()) { const CSwordLexiconModuleInfo *lexiconModule = qobject_cast<const CSwordLexiconModuleInfo*>(m_moduleInfoList.at(0)); keyName = lexiconModule->entries()[index]; } return keyName; }
QVariant BtModuleTextModel::verseData(const QModelIndex & index, int role) const { int row = index.row(); CSwordVerseKey key = indexToVerseKey(row); int verse = key.getVerse(); if (role == ModuleEntry::TextRole) { if (verse == 0) return QString(); QString text; QString chapterTitle; if (verse == 1) chapterTitle = key.book() + " " + QString::number(key.getChapter()); text += Rendering::CEntryDisplay().textKeyRendering(m_moduleInfoList, key.key(), m_displayOptions, m_filterOptions, Rendering::CTextRendering::KeyTreeItem::Settings::SimpleKey); text.replace("#CHAPTERTITLE#", chapterTitle); text = replaceColors(text); return CSwordModuleSearch::highlightSearchedText(text, m_highlightWords); } return QString(); }