BibleTime
btmodelviewreaddisplay.h
Go to the documentation of this file.
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, https://bibletime.info/
6*
7* Copyright 1999-2025 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#pragma once
14
15#include <QWidget>
16
17#include "../../backend/btglobal.h"
18
19
20class BtQmlInterface;
21class BtQuickWidget;
22class CDisplayWindow;
23class CSwordKey;
24class QMenu;
25class QScrollBar;
26
27/**
28 * @page modelviewmain Details about the model/view read display
29 * <p>
30 * In the simplest form, the model/view read display uses BtModuleTextModel
31 * as the model and a <b>QML ListView</b> in Display.qml. BtModuleTextModel is a
32 * subclass of QAbstractItemList. The BtModuleTextModel creates entries for
33 * references that are being displayed in the ListView or those that are just
34 * above and below the displayed references. As the ListView is scrolled, the
35 * entries are automatically created and deleted. The entries represent verses,
36 * chapters, lexicon items, etc. depending upon the module type.
37 * </p>
38 * <p>
39 * - For more details about the model see @ref modelviewmodel.<br/>
40 * - For details about the view, see @ref modelviewdisplay.<br/>
41 * </p>
42 */
43
44/**
45 * @page modelviewdisplay Details about the QML view
46 * <p>
47 * The class BtModelViewReadDisplay contains the functionality to display a model
48 * of a module. It uses a set of widgets to do this. The hierarchy of contained
49 * widgets is:<br/>
50 * - BtQmlScrollView - Contains the scrolling functionality.<br/>
51 * - BtQuickWidget - Contains the functionality for displaying QML.<br/>
52 *
53 * Below the BtQuickWidget is the QML file, <b>DisplayView.qml</b>. It contains
54 * the ListView that displays the module entries. The QML instantiates
55 * another class, BtQmlInterface, that provides properties and functions
56 * that QML uses.
57 * </p>
58 */
59
60/** The view implementation for the Model/View read display.
61 */
63 Q_OBJECT
64
65public: // types:
66
67 enum TextPart {
68 Document, /* All text */
69 SelectedText, /* Only the selected text */
73 };
74
75public: // methods:
76
78 QWidget * parent = nullptr);
79
81
87
88 /** \brief Copies the currently selected text. */
89 void copySelectedText();
90
91 /**
92 \brief Copies the given text specified by asking user for first and last
93 references.
94 */
95 void copyByReferences();
96
97 /**
98 \brief Saves the given text with the specified format into the
99 applications clipboard.
100 */
101 void save(TextPart const part);
102
103 void print(TextPart const,
104 DisplayOptions const & displayOptions,
105 FilterOptions const & filterOptions);
106
107 void printAll(DisplayOptions const & displayOptions,
108 FilterOptions const & filterOptions)
109 { print(Document, displayOptions, filterOptions); }
110
111 void printAnchorOnly(DisplayOptions const & displayOptions,
112 FilterOptions const & filterOptions)
113 { print(AnchorOnly, displayOptions, filterOptions); }
114
115 void printAnchorWithText(DisplayOptions const & displayOptions,
116 FilterOptions const & filterOptions)
117 { print(AnchorWithText, displayOptions, filterOptions); }
118
119 #ifdef BUILD_TEXT_TO_SPEECH
120 /** \brief Speaks the currently selected text (text-to-speech). */
121 void speakSelectedText();
122 #endif
123
124 /**
125 \brief Installs the popup which should be opened when the right mouse
126 button was pressed.
127 */
128 void installPopup(QMenu * const popup) { m_popup = popup; }
129
130 /**
131 \param[in] format The format to use for the text.
132 \param[in] part The part of the text to return.
133 \returns the right text part in the specified format.
134 */
135 QString text(TextPart const part = Document);
136
137 void reloadModules();
138
139 void setDisplayFocus();
140
141 void setOptions(DisplayOptions const & displayOptions,
142 FilterOptions const & filterOptions);
143
144 void highlightText(const QString& text, bool caseSensitive);
145
146 void findText(bool const backward);
147
148 QString nodeInfo() const { return m_nodeInfo; }
149
150 void pageDown();
151
152 void pageUp();
153
154 void scrollToKey(CSwordKey * key);
155
156 void scroll(int pixels);
157
158 void setNodeInfo(QString const & newNodeInfo);
159
160 void setModules(QStringList const & modules);
161
162 void settingsChanged();
163
164 void updateReferenceText();
165
166 BtQuickWidget * quickWidget() const noexcept { return m_quickWidget; }
167
168 BtQmlInterface * qmlInterface() const noexcept { return m_qmlInterface; }
169
170Q_SIGNALS:
171
172 void nodeInfoChanged(QString newNodeInfo);
173 void activeAnchorChanged(QString newActiveAnchor);
174
175private Q_SLOTS:
176
177 void setBibleReference (const QString& reference);
178 void slotSliderMoved(int value);
179 void slotSliderPressed();
180 void slotSliderReleased();
181
182private: /* Methods: */
183
184 void copyAsPlainText(TextPart const part);
185 void contextMenuEvent(QContextMenuEvent * event) final override;
186
187private: // fields:
188
190 QMenu * m_popup = nullptr;
191 QString m_activeAnchor; //< Holds the current anchor
192
193 QString m_nodeInfo;
194
197 QScrollBar * const m_scrollBar;
199
200};
void printAll(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
void printAnchorOnly(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
void findText(bool const backward)
void highlightText(const QString &text, bool caseSensitive)
void copySelectedText()
Copies the currently selected text.
void setModules(QStringList const &modules)
void setNodeInfo(QString const &newNodeInfo)
QString text(TextPart const part=Document)
void installPopup(QMenu *const popup)
Installs the popup which should be opened when the right mouse button was pressed.
void activeAnchorChanged(QString newActiveAnchor)
void copyAsPlainText(TextPart const part)
void copyByReferences()
Copies the given text specified by asking user for first and last references.
BtQuickWidget * quickWidget() const noexcept
void save(TextPart const part)
Saves the given text with the specified format into the applications clipboard.
void setOptions(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
BtQmlInterface * qmlInterface() const noexcept
void printAnchorWithText(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
BtQuickWidget *const m_quickWidget
BtQmlInterface *const m_qmlInterface
void nodeInfoChanged(QString newNodeInfo)
void print(TextPart const, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
void contextMenuEvent(QContextMenuEvent *event) final override
void setBibleReference(const QString &reference)
~BtModelViewReadDisplay() override
The base class for all display windows of BibleTime.