2
// C++ Interface: ctextrendering
7
// Author: The BibleTime team <info@bibletime.info>, (C) 2004
9
// Copyright: See COPYING file that comes with this distribution
13
#ifndef CTEXTRENDERING_H
14
#define CTEXTRENDERING_H
17
#include "backend/cswordmoduleinfo.h"
19
#include "util/autoptrvector.h"
24
// class CSwordModuleInfo;
29
* CTextRendering is BibleTime's place where the actual rendering takes place.
30
* It provides several methods to convert an abstract tree of items
31
* into a string of html.
33
* See the implementations @ref CHTMLExportRendering and especially @ref CDisplayRendering.
34
* @short Text rendering based on trees
35
* @author The BibleTime team
40
class CTextRendering {
47
typedef util::AutoPtrVector<KeyTreeItem> KeyTreeItemList;
53
enum KeyRenderingFace {
54
NoKey, //< means no key shown at all
55
SimpleKey, //< means only versenumber or only lexicon entry name
56
CompleteShort, //< means key like "Gen 1:1"
57
CompleteLong //< means "Genesis 1:1"
60
Settings(const bool highlight = false, KeyRenderingFace keyRendering = SimpleKey) : highlight(highlight), keyRenderingFace(keyRendering) {}
63
KeyRenderingFace keyRenderingFace;
66
KeyTreeItem(const QString& key, CSwordModuleInfo const * module, const Settings settings);
67
KeyTreeItem(const QString& key, const ListCSwordModuleInfo& modules, const Settings settings);
68
KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings);
69
KeyTreeItem(const QString& content, const Settings settings);
70
KeyTreeItem(const KeyTreeItem& i);
72
virtual ~KeyTreeItem();
74
const QString& getAlternativeContent() const;
75
inline void setAlternativeContent(const QString& newContent) {
76
m_alternativeContent = newContent;
79
inline const bool hasAlternativeContent() const {
80
return !m_alternativeContent.isNull();
83
inline const ListCSwordModuleInfo& modules() const {
87
inline const QString& key() const {
91
inline const Settings& settings() const {
95
inline KeyTree* const childList() const;
96
inline const bool hasChildItems() const;
102
ListCSwordModuleInfo m_moduleList;
104
mutable KeyTree* m_childList;
107
QString m_alternativeContent;
110
class KeyTree : public KeyTreeItemList {
112
ListCSwordModuleInfo collectModules() const;
115
virtual ~CTextRendering() {}
117
const QString renderKeyTree( KeyTree& );
119
const QString renderKeyRange( const QString& start, const QString& stop, const ListCSwordModuleInfo& modules, const QString& hightlightKey = QString::null, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
121
const QString renderSingleKey( const QString& key, const ListCSwordModuleInfo&, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
124
virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ) = 0;
125
virtual const QString finishText( const QString&, KeyTree& tree ) = 0;
126
virtual void initRendering() = 0;
129
inline CTextRendering::KeyTree* const CTextRendering::KeyTreeItem::childList() const {
131
m_childList = new KeyTree();
137
inline const bool CTextRendering::KeyTreeItem::hasChildItems() const {
142
return !m_childList->isEmpty();