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 /**
120 \brief Installs the popup which should be opened when the right mouse
121 button was pressed.
122 */
123 void installPopup(QMenu * const popup) { m_popup = popup; }
124
125 /**
126 \param[in] format The format to use for the text.
127 \param[in] part The part of the text to return.
128 \returns the right text part in the specified format.
129 */
130 QString text(TextPart const part = Document);
131
132 void reloadModules();
133
134 void setDisplayFocus();
135
136 void setOptions(DisplayOptions const & displayOptions,
137 FilterOptions const & filterOptions);
138
139 void highlightText(const QString& text, bool caseSensitive);
140
141 void findText(bool const backward);
142
143 QString nodeInfo() const { return m_nodeInfo; }
144
145 void pageDown();
146
147 void pageUp();
148
149 void scrollToKey(CSwordKey * key);
150
151 void scroll(int pixels);
152
153 void setNodeInfo(QString const & newNodeInfo);
154
155 void setModules(QStringList const & modules);
156
157 void settingsChanged();
158
159 void updateReferenceText();
160
161 BtQuickWidget * quickWidget() const noexcept { return m_quickWidget; }
162
163 BtQmlInterface * qmlInterface() const noexcept { return m_qmlInterface; }
164
165Q_SIGNALS:
166
167 void nodeInfoChanged(QString newNodeInfo);
168 void activeAnchorChanged(QString newActiveAnchor);
169
170private Q_SLOTS:
171
172 void setBibleReference (const QString& reference);
173 void slotSliderMoved(int value);
174 void slotSliderPressed();
175 void slotSliderReleased();
176
177private: /* Methods: */
178
179 void copyAsPlainText(TextPart const part);
180 void contextMenuEvent(QContextMenuEvent * event) final override;
181
182private: // fields:
183
185 QMenu * m_popup = nullptr;
186 QString m_activeAnchor; //< Holds the current anchor
187
188 QString m_nodeInfo;
189
192 QScrollBar * const m_scrollBar;
194
195};
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.