GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
documentation.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2018-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_documentation_h)
27 #define octave_documentation_h 1
28 
29 #include <QComboBox>
30 #include <QMenu>
31 #include <QShortcut>
32 #include <QSplitter>
33 #include <QTextBrowser>
34 #include <QToolBar>
35 #include <QListWidget>
36 #include <QToolButton>
37 #include <QWidget>
38 #include <QtHelp/QHelpEngine>
39 
40 #include "gui-settings.h"
41 
43 
44 class base_qobject;
45 class documentation;
47 
48 //! Documentation browser derived from Textbrowser
49 
51 {
52  Q_OBJECT
53 
54 public:
55 
56  documentation_browser (QHelpEngine *help_engine, QWidget *parent = nullptr);
57  ~documentation_browser (void) = default;
58 
59  virtual QVariant loadResource (int type, const QUrl& url);
60 
61 public slots:
62 
63  void handle_index_clicked (const QUrl& url,
64  const QString& keyword = QString ());
67 
68  //! Zooming in and out while taking care of the zoom level
69  //!@{
70  void zoom_in (void);
71  void zoom_out (void);
72  void zoom_original (void);
73  //!@}
74 
75 protected:
76 
77  void wheelEvent (QWheelEvent *we);
78 
79 private:
80 
81  QHelpEngine *m_help_engine;
82 
83  //! Store the current zoom level
85 
86  //! Minimal and maximal zoom level avoiding calling
87  //! zoom_in and zoom_out without actually zooming but
88  //! with changing the stored zoom level
89  enum
90  {
92  max_zoom_level = 10
93  };
94 };
95 
96 //! The documentation main class derived from QSplitter
97 
98 class documentation : public QSplitter
99 {
100  Q_OBJECT
101 
102 public:
103 
104  documentation (QWidget *parent, base_qobject& oct_qobj);
105  ~documentation (void);
106 
107  /*!
108  Generate a string with page name @p title and current anchor
109  from @p url for using in prev/next or bookmarks menu:
110 
111  @param title current title of the page as QString
112  @param url current url as QUrl
113 
114  @return QString "title: anchor"
115  */
116  QString title_and_anchor (const QString& title, const QUrl& url);
117 
118 signals:
119 
120  void show_single_result (const QUrl&);
121 
122 public slots:
123 
124  void notice_settings (const gui_settings *settings);
125  void save_settings (void);
126 
127  void copyClipboard (void);
128  void pasteClipboard (void);
129  void selectAll (void);
130 
131  void load_index (void);
132  void load_ref (const QString& name = QString ());
133  void registerDoc (const QString& name);
134  void unregisterDoc (const QString& name);
135 
136 private slots:
137 
138  void activate_find (void);
139  void global_search (void);
140  void global_search_started (void);
141  void global_search_finished (int hits);
142  void filter_update (const QString& expression);
143  void filter_update_history (void);
144  void find (bool backward = false);
145  void find_backward (void);
146  void find_forward_from_anchor (const QString& text);
147  void record_anchor_position (void);
148  void handle_cursor_position_change (void);
149  void handle_search_result_clicked (const QUrl& url);
150 
151  void update_history_menus (void);
152  void open_hist_url (QAction *a);
153 
154 private:
155 
156  void construct_tool_bar (void);
157  QAction * add_action (const QIcon& icon, const QString& text,
158  const char *member, QWidget *receiver = nullptr,
159  QToolBar *tool_bar = nullptr);
160  void update_history (int new_count, QAction **actions);
161 
162  //! Select all occurrences of a string in the doc browser
163  void select_all_occurrences (const QString& text);
164 
166 
167  QHelpEngine *m_help_engine;
173  QComboBox *m_filter;
174  QString m_collection;
175 
177  QToolBar *m_tool_bar;
178  QString m_query_string;
179 
180  bool m_indexed;
182 
190 
191  enum { max_history_entries = 10 };
194 
196 
197  QAction *m_action_find;
200 
204 };
205 
207 
208 #endif
OCTAVE_END_NAMESPACE(octave)
Base class for Octave interfaces that use Qt.
Documentation browser derived from Textbrowser.
Definition: documentation.h:51
documentation_browser(QHelpEngine *help_engine, QWidget *parent=nullptr)
~documentation_browser(void)=default
void zoom_out(void)
Zooming in and out while taking care of the zoom level.
void save_settings(gui_settings *settings)
void wheelEvent(QWheelEvent *we)
void zoom_in(void)
Zooming in and out while taking care of the zoom level.
int m_zoom_level
Store the current zoom level.
Definition: documentation.h:84
virtual QVariant loadResource(int type, const QUrl &url)
QHelpEngine * m_help_engine
Definition: documentation.h:81
void notice_settings(const gui_settings *settings)
void zoom_original(void)
Zooming in and out while taking care of the zoom level.
void handle_index_clicked(const QUrl &url, const QString &keyword=QString())
The documentation main class derived from QSplitter.
Definition: documentation.h:99
void load_index(void)
QAction * m_action_zoom_out
void pasteClipboard(void)
void find_forward_from_anchor(const QString &text)
QAction * m_action_go_next
void select_all_occurrences(const QString &text)
Select all occurrences of a string in the doc browser.
void show_single_result(const QUrl &)
QShortcut * m_findprev_shortcut
QAction * m_action_go_prev
QToolBar * m_tool_bar
void global_search(void)
void find(bool backward=false)
QString m_current_ref_name
QAction * m_action_zoom_original
documentation_bookmarks * m_bookmarks
void global_search_finished(int hits)
QLineEdit * m_find_line_edit
QMenu * m_prev_pages_menu
QAction * m_action_bookmark
void notice_settings(const gui_settings *settings)
QString title_and_anchor(const QString &title, const QUrl &url)
int m_search_anchor_position
void record_anchor_position(void)
QString m_internal_search
base_qobject & m_octave_qobj
QWidget * m_doc_widget
void handle_search_result_clicked(const QUrl &url)
QAction * m_action_find
QAction * add_action(const QIcon &icon, const QString &text, const char *member, QWidget *receiver=nullptr, QToolBar *tool_bar=nullptr)
void copyClipboard(void)
void update_history_menus(void)
void save_settings(void)
void open_hist_url(QAction *a)
void load_ref(const QString &name=QString())
QHelpEngine * m_help_engine
void activate_find(void)
void filter_update(const QString &expression)
QString m_query_string
QShortcut * m_findnext_shortcut
void handle_cursor_position_change(void)
QAction * m_action_zoom_in
documentation_browser * m_doc_browser
QAction * m_action_go_home
void unregisterDoc(const QString &name)
void filter_update_history(void)
void global_search_started(void)
void registerDoc(const QString &name)
QComboBox * m_filter
QAction * m_next_pages_actions[max_history_entries]
void selectAll(void)
documentation(QWidget *parent, base_qobject &oct_qobj)
QMenu * m_next_pages_menu
void update_history(int new_count, QAction **actions)
void find_backward(void)
void construct_tool_bar(void)
QAction * m_prev_pages_actions[max_history_entries]
QString m_collection
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
static double we[256]
Definition: randmtzig.cc:466