~vcs-imports/bibletime/trunk

« back to all changes in this revision

Viewing changes to bibletime/backend/ctextrendering.h

  • Committer: mgruner
  • Date: 2007-05-08 15:51:07 UTC
  • Revision ID: vcs-imports@canonical.com-20070508155107-0rj7jdmm5ivf8685
-imported source and data files to new svn module
-this is where KDE4-based development will take place

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// C++ Interface: ctextrendering
 
3
//
 
4
// Description:
 
5
//
 
6
//
 
7
// Author: The BibleTime team <info@bibletime.info>, (C) 2004
 
8
//
 
9
// Copyright: See COPYING file that comes with this distribution
 
10
//
 
11
//
 
12
 
 
13
#ifndef CTEXTRENDERING_H
 
14
#define CTEXTRENDERING_H
 
15
 
 
16
//BT includes
 
17
#include "backend/cswordmoduleinfo.h"
 
18
 
 
19
#include "util/autoptrvector.h"
 
20
 
 
21
//QT includes
 
22
#include <qstring.h>
 
23
 
 
24
// class CSwordModuleInfo;
 
25
 
 
26
class CSwordKey;
 
27
 
 
28
/**
 
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.
 
32
 *
 
33
 * See the implementations @ref CHTMLExportRendering and especially @ref CDisplayRendering.
 
34
 * @short Text rendering based on trees
 
35
 * @author The BibleTime team
 
36
*/
 
37
 
 
38
namespace Rendering {
 
39
 
 
40
        class CTextRendering {
 
41
 
 
42
public:
 
43
 
 
44
        class KeyTreeItem;
 
45
 
 
46
        class KeyTree;
 
47
        typedef util::AutoPtrVector<KeyTreeItem> KeyTreeItemList;
 
48
 
 
49
        class KeyTreeItem {
 
50
        public:
 
51
 
 
52
                struct Settings {
 
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"
 
58
                        };
 
59
 
 
60
                        Settings(const bool highlight = false, KeyRenderingFace keyRendering = SimpleKey) : highlight(highlight), keyRenderingFace(keyRendering) {}
 
61
 
 
62
                        bool highlight;
 
63
                        KeyRenderingFace keyRenderingFace;
 
64
                };
 
65
 
 
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);
 
71
 
 
72
                virtual ~KeyTreeItem();
 
73
 
 
74
                const QString& getAlternativeContent() const;
 
75
                inline void setAlternativeContent(const QString& newContent) {
 
76
                        m_alternativeContent = newContent;
 
77
                };
 
78
 
 
79
                inline const bool hasAlternativeContent() const {
 
80
                        return !m_alternativeContent.isNull();
 
81
                };
 
82
 
 
83
                inline const ListCSwordModuleInfo& modules() const {
 
84
                        return m_moduleList;
 
85
                };
 
86
 
 
87
                inline const QString& key() const {
 
88
                        return m_key;
 
89
                };
 
90
 
 
91
                inline const Settings& settings() const {
 
92
                        return m_settings;
 
93
                };
 
94
 
 
95
                inline KeyTree* const childList() const;
 
96
                inline const bool hasChildItems() const;
 
97
 
 
98
        protected:
 
99
                KeyTreeItem();
 
100
 
 
101
                Settings m_settings;
 
102
                ListCSwordModuleInfo m_moduleList;
 
103
                QString m_key;
 
104
                mutable KeyTree* m_childList;
 
105
 
 
106
                QString m_stopKey;
 
107
                QString m_alternativeContent;
 
108
        };
 
109
 
 
110
        class KeyTree : public KeyTreeItemList {                
 
111
        public:
 
112
                ListCSwordModuleInfo collectModules() const;
 
113
        };
 
114
 
 
115
        virtual ~CTextRendering() {}
 
116
 
 
117
        const QString renderKeyTree( KeyTree& );
 
118
 
 
119
        const QString renderKeyRange( const QString& start, const QString& stop, const ListCSwordModuleInfo& modules, const QString& hightlightKey = QString::null, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
 
120
 
 
121
        const QString renderSingleKey( const QString& key, const ListCSwordModuleInfo&, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
 
122
 
 
123
protected:
 
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;
 
127
};
 
128
 
 
129
inline CTextRendering::KeyTree* const CTextRendering::KeyTreeItem::childList() const {
 
130
        if (!m_childList) {
 
131
                m_childList = new KeyTree();
 
132
        }
 
133
 
 
134
        return m_childList;
 
135
}
 
136
 
 
137
inline const bool CTextRendering::KeyTreeItem::hasChildItems() const {
 
138
        if (!m_childList) {
 
139
                return false;
 
140
        }
 
141
 
 
142
        return !m_childList->isEmpty();
 
143
}
 
144
 
 
145
}
 
146
 
 
147
#endif