コード例 #1
0
ファイル: centrydisplay.cpp プロジェクト: kalemas/bibletime
const QString CEntryDisplay::textKeyRendering(
    const BtConstModuleList &modules,
    const QString &keyName,
    const DisplayOptions &displayOptions,
    const FilterOptions &filterOptions,
    CTextRendering::KeyTreeItem::Settings::KeyRenderingFace keyRendering,
    bool introdutions) {

    if (keyName.isEmpty())
        return QString("");

    CDisplayRendering render(displayOptions, filterOptions);

    //no highlighted key and no extra key link in the text
    CTextRendering::KeyTreeItem::Settings normal_settings(false, keyRendering);
    const CSwordModuleInfo *module = modules.first();

    Rendering::CTextRendering::KeyTree tree;

    //in Bibles and Commentaries we need to check if 0:0 and X:0 contain something
    if (introdutions && (module->type() == CSwordModuleInfo::Bible ||
                         module->type() == CSwordModuleInfo::Commentary)) {
        // HACK: enable headings for VerseKeys
        static_cast<sword::VerseKey *>(module->module()->getKey())
        ->setIntros(true);

        CSwordVerseKey k1(module);
        k1.setIntros(true);
        k1.setKey(keyName);

        // don't print the key
        CTextRendering::KeyTreeItem::Settings preverse_settings(false, CTextRendering::KeyTreeItem::Settings::NoKey);

        if (k1.getVerse() == 1) { // X:1, prepend X:0
            if (k1.getChapter() == 1) { // 1:1, also prepend 0:0 before that
                k1.setChapter(0);
                k1.setVerse(0);
                if ( k1.rawText().length() > 0 ) {
                    tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
                }
                k1.setChapter(1);
            }
            k1.setVerse(0);
            if ( k1.rawText().length() > 0 ) {
                tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
            }
        }
    }
    tree.append( new Rendering::CTextRendering::KeyTreeItem(keyName, modules, normal_settings) );
    return render.renderKeyTree(tree);
}
コード例 #2
0
/** Returns the rendered text using the modules in the list and using the key parameter.
 * The displayoptions and filter options are used, too.
 */
const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
    CDisplayRendering render(displayOptions, filterOptions);

    //no highlighted key and no extra key link in the text
    CTextRendering::KeyTreeItem::Settings normal_settings(false, CTextRendering::KeyTreeItem::Settings::CompleteShort);
    CSwordModuleInfo* module = modules.first();

    Rendering::CTextRendering::KeyTree tree;

    //in Bibles and Commentaries we need to check if 0:0 and X:0 contain something
    if (module->type() == CSwordModuleInfo::Bible || module->type() == CSwordModuleInfo::Commentary) {
        ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys

        CSwordVerseKey k1(module);
        k1.Headings(1);
        k1.key(keyName);

        // don't print the key
        CTextRendering::KeyTreeItem::Settings preverse_settings(false, CTextRendering::KeyTreeItem::Settings::NoKey);

        if (k1.Verse() == 1) { //X:1, prepend X:0
            if (k1.Chapter() == 1) { //1:1, also prepend 0:0 before that
                k1.Chapter(0);
                k1.Verse(0);
                if ( k1.rawText().length() > 0 ) {
                    tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
                }
                k1.Chapter(1);
            }
            k1.Verse(0);
            if ( k1.rawText().length() > 0 ) {
				tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
            }
        }
    }
	tree.append( new Rendering::CTextRendering::KeyTreeItem(keyName, modules, normal_settings) );
    QString result(render.renderKeyTree(tree));
    qDeleteAll(tree);
	return result;
}