summaryrefslogtreecommitdiffstats
path: root/bibletime/backend/cchapterdisplay.cpp
blob: aacdda4aaf6801f06267b9582a3b878e331f17c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// C++ Implementation: cchapterdisplay
//
// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//

//Backend
#include "cchapterdisplay.h"
#include "cdisplayrendering.h"
#include "cswordversekey.h"
#include "cswordbiblemoduleinfo.h"


namespace Rendering {

	const TQString CChapterDisplay::text( const ListCSwordModuleInfo& modules, const TQString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
		Q_ASSERT( modules.count() >= 1 );
		Q_ASSERT( !keyName.isEmpty() );

		CSwordModuleInfo* module = modules.first();

		if (modules.count() == 1) module->module()->setSkipConsecutiveLinks( true ); //skip empty, linked verses

		CTextRendering::KeyTreeItem::Settings settings;
		settings.keyRenderingFace =
			displayOptions.verseNumbers
			? CTextRendering::KeyTreeItem::Settings::SimpleKey
			: CTextRendering::KeyTreeItem::Settings::NoKey;

		TQString startKey = keyName;
		TQString endKey = startKey;

		//check whether there's an intro we have to include
		Q_ASSERT((module->type() == CSwordModuleInfo::Bible));

		if (module->type() == CSwordModuleInfo::Bible) {
			((VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys

			CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
			Q_ASSERT(bible);

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

			if (k1.Chapter() == 1)	k1.Chapter(0); //Chapter 1, start with 0:0, otherwise X:0
			
			k1.Verse(0);

			startKey = k1.key();
			
			if (k1.Chapter() == 0) k1.Chapter(1);
			k1.Verse(bible->verseCount(k1.book(), k1.Chapter()));
			endKey = k1.key();
		}

		CDisplayRendering render(displayOptions, filterOptions);
		return render.renderKeyRange( startKey, endKey, modules, keyName, settings );
	}

};