~ubuntu-branches/ubuntu/saucy/bibletime/saucy-proposed

« back to all changes in this revision

Viewing changes to src/backend/managers/cdisplaytemplatemgr.h

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-08-12 21:02:54 UTC
  • mfrom: (1.3.8)
  • Revision ID: package-import@ubuntu.com-20130812210254-oumj97t1gqs2g8nb
Tags: 2.9.2-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#ifndef CDISPLAYTEMPLATEMGR_H
11
11
#define CDISPLAYTEMPLATEMGR_H
12
12
 
13
 
#include <QMap>
14
 
#include <QString>
 
13
#include <QHash>
15
14
#include <QStringList>
16
 
 
17
 
 
18
 
class CSwordModuleInfo;
 
15
#include "../drivers/cswordmoduleinfo.h"
 
16
 
19
17
 
20
18
/**
21
19
  Manages the display templates used in the filters and display classes.
30
28
        */
31
29
        struct Settings {
32
30
 
33
 
            inline Settings() : pageDirection("ltr") {}
 
31
            inline Settings()
 
32
                : langAbbrev("en")
 
33
                , textDirection(CSwordModuleInfo::LeftToRight) {}
 
34
 
 
35
            inline const char * textDirectionAsHtmlDirAttr() const {
 
36
                return textDirection == CSwordModuleInfo::LeftToRight ? "ltr" : "rtl";
 
37
            }
34
38
 
35
39
            /** The list of modules */
36
 
            QList<const CSwordModuleInfo*> modules;
 
40
            QList<const CSwordModuleInfo *> modules;
37
41
 
38
42
            /** The title which is used for the new processed HTML page */
39
43
            QString title;
41
45
            /** The language for the HTML page. */
42
46
            QString langAbbrev;
43
47
 
44
 
            /** The language direction for the HTML page. */
45
 
            QString pageDirection;
46
 
 
47
48
            /** The CSS ID which is used in the content part of the page */
48
49
            QString pageCSS_ID;
49
50
 
 
51
            /** The language direction for the HTML page. */
 
52
            CSwordModuleInfo::TextDirection textDirection;
 
53
 
50
54
        };
51
55
 
52
56
    public: /* Methods: */
55
59
          \param[out] errorMessage Set to error string on error, otherwise set
56
60
                                   to QString::null.
57
61
        */
58
 
        explicit CDisplayTemplateMgr(QString &errorMessage);
 
62
        explicit CDisplayTemplateMgr(QString & errorMessage);
59
63
 
60
64
        /**
61
65
          \returns the list of available templates.
62
66
        */
63
 
        inline const QStringList availableTemplates() const {
64
 
            return m_cssMap.keys();
 
67
        inline const QStringList & availableTemplates() const {
 
68
            return m_availableTemplateNamesCache;
65
69
        }
66
70
 
67
71
        /**
76
80
 
77
81
          \returns The full HTML template HTML code including the CSS data.
78
82
        */
79
 
        QString fillTemplate(const QString &name, const QString &content,
80
 
                             const Settings &settings);
 
83
        QString fillTemplate(const QString & name,
 
84
                             const QString & content,
 
85
                             const Settings & settings) const;
81
86
 
82
87
        /**
83
88
          \returns the name of the default template.
92
97
        /**
93
98
          \returns The singleton instance of the instance of this class.
94
99
        */
95
 
        static inline CDisplayTemplateMgr *instance() {
 
100
        static inline CDisplayTemplateMgr * instance() {
96
101
            Q_ASSERT(m_instance != 0);
97
102
            return m_instance;
98
103
        }
100
105
    private: /* Methods: */
101
106
 
102
107
        /** Preloads a single template from disk: */
103
 
        void loadTemplate(const QString &filename);
104
 
        void loadCSSTemplate(const QString &filename);
 
108
        void loadTemplate(const QString & filename);
 
109
        void loadCSSTemplate(const QString & filename);
105
110
 
106
111
    private: /* Fields: */
107
112
 
108
 
        QMap<QString, QString> m_templateMap;
109
 
        QMap<QString, QString> m_cssMap;
110
 
        static CDisplayTemplateMgr *m_instance;
 
113
        QHash<QString, QString> m_templateMap;
 
114
        QHash<QString, QString> m_cssMap;
 
115
        static CDisplayTemplateMgr * m_instance;
 
116
        QStringList m_availableTemplateNamesCache;
111
117
 
112
118
};
113
119