1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, http://www.bibletime.info/.
6 *
7 * Copyright 1999-2016 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #ifndef BT_WINDOW_INTERFACE_H
14 #define BT_WINDOW_INTERFACE_H
15 
16 #include <QList>
17 #include <QObject>
18 #include <QString>
19 #include "backend/managers/cswordbackend.h"
20 #include "mobile/models/roleitemmodel.h"
21 
22 class CSwordKey;
23 class CSwordVerseKey;
24 class CSwordModuleInfo;
25 class BtModuleTextModel;
26 
27 namespace btm {
28 
29 class BookKeyChooser;
30 class KeyNameChooser;
31 class VerseChooser;
32 
33 struct History
34 {
35     QString moduleName;
36     QString reference;
37 };
38 
39 class BtWindowInterface : public QObject {
40 
41     Q_OBJECT
42 
43     Q_PROPERTY(int      currentModelIndex   READ getCurrentModelIndex NOTIFY currentModelIndexChanged)
44     Q_PROPERTY(int      fontSize   READ getFontSize WRITE setFontSize NOTIFY textChanged)
45     Q_PROPERTY(QString  fontName   READ getFontName NOTIFY textChanged)
46     Q_PROPERTY(QString  highlightWords   READ getHighlightWords WRITE setHighlightWords)
47     Q_PROPERTY(QString  moduleLanguage  READ getModuleLanguage)
48     Q_PROPERTY(QString  moduleName   READ getModuleName WRITE setModuleName NOTIFY moduleChanged)
49     Q_PROPERTY(QString  reference   READ getReference WRITE setReference NOTIFY referenceChange)
50     Q_PROPERTY(QVariant textModel   READ getTextModel NOTIFY textModelChanged)
51     Q_PROPERTY(bool     historyBackwardVisible READ getHistoryBackwardVisible NOTIFY historyChanged)
52     Q_PROPERTY(bool     historyForwardVisible READ getHistoryForwardVisible NOTIFY historyChanged)
53 
54 public:
55     Q_INVOKABLE void changeModule();
56     Q_INVOKABLE void changeReference();
57     Q_INVOKABLE void saveWindowStateToConfig(int windowIndex);
58     Q_INVOKABLE void updateCurrentModelIndex();
59     Q_INVOKABLE void updateTextFonts();
60     Q_INVOKABLE void updateKeyText(int modelIndex);
61     Q_INVOKABLE void moveHistoryBackward();
62     Q_INVOKABLE void moveHistoryForward();
63     Q_INVOKABLE void setHistoryPoint();
64     Q_INVOKABLE void setModuleToBeginning();
65 
66     BtWindowInterface(QObject *parent = nullptr);
67 
68     int getCurrentModelIndex() const;
69     int getFontSize() const;
70     QString getFontName() const;
71     QString getHighlightWords() const;
72     CSwordKey* getKey() const;
73     QString getModuleLanguage() const;
74     QString getModuleName() const;
75     QString getReference() const;
76     QVariant getTextModel();
77 
78     void moduleNameChanged(const QString& moduleName);
79     void setFontSize(int size);
80     void setHighlightWords(const QString& words);
81     void setModuleName(const QString& moduleName);
82     void setReference(const QString& key);
83 
84     bool getHistoryBackwardVisible() const;
85     bool getHistoryForwardVisible() const;
86 
87 signals:
88     void currentModelIndexChanged();
89     void historyChanged();
90     void moduleChanged();
91     void referenceChange();
92     void textChanged();
93     void textModelChanged();
94 
95 private slots:
96     void referenceChanged();
97     void referenceChosen();
98     void referenceChosen(int index);
99     void reloadModules(CSwordBackend::SetupChangedReason reason);
100 
101 private:
102     const CSwordModuleInfo* module() const;
103     void updateModel();
104 
105     CSwordKey* m_key;
106     RoleItemModel* m_textModel;
107     BtModuleTextModel* m_moduleTextModel;
108     BookKeyChooser* m_bookKeyChooser;
109     KeyNameChooser* m_keyNameChooser;
110     VerseChooser* m_verseKeyChooser;
111     QString m_highlightWords;
112     QString m_moduleName;
113     QList<History> m_history;
114     int m_historyIndex;
115 
116 };
117 
118 } // end namespace
119 
120 #endif
121