annotate libgui/src/documentation.h @ 25541:517c73173011

doc.m: allow full text search in GUI mode (bug #54053). * documentation.h(cc) (documentation::m_internal_search): new data member (documentation::documentation): Set tabs objectName for further search. Rename "Index" tab to "Function Index" for consistency. (documentation::load_ref): If index search works, switch to "Function Index" tab and filter results. Otherwise, initialize m_internal_search, switch to "Search" tab and start a full text search. . (documentation::global_search_finished): If m_internal_search is not empty, analyse search results: if there is only one result or if one of the results contains the searched string, display the corresponding page in text browser
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Thu, 21 Jun 2018 10:52:44 +0200
parents 41bbdf17f51a
children 506419b5f817
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
1 /*
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
2
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
3 Copyright (C) 2018 Torsten <mttl@maibox.org>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
4
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
5 This file is part of Octave.
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
6
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
10 (at your option) any later version.
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
11
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
15 GNU General Public License for more details.
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
16
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
19 <https://www.gnu.org/licenses/>.
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
20
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
21 */
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
22
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
23 #if ! defined (octave_documentation_h)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
24 #define octave_documentation_h 1
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
25
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
26 #include <QComboBox>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
27 #include <QWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
28 #include <QSettings>
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25155
diff changeset
29 #include <QShortcut>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
30 #include <QSplitter>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
31 #include <QTextBrowser>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
32 #include <QtHelp/QHelpEngine>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
33
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
34 namespace octave
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
35 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
36 // The documentation browser
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
37 class documentation_browser : public QTextBrowser
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
38 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
39 Q_OBJECT
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
40
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
41 public:
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
42
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
43 documentation_browser (QHelpEngine *help_engine, QWidget *parent = nullptr);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
44 ~documentation_browser (void);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
45
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
46 virtual QVariant loadResource (int type, const QUrl &url);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
47
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
48 public slots:
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
49
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
50 void handle_index_clicked (const QUrl& url,
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
51 const QString& keyword = QString ());
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
52 void notice_settings (const QSettings *settings);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
53
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
54 private:
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
55
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
56 QHelpEngine *m_help_engine;
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
57
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
58 };
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
59
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
60
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
61 // The documentaiton main class (splitter)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
62 class documentation : public QSplitter
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
63 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
64 Q_OBJECT
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
65
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
66 public:
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
67
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
68 documentation (QWidget *parent = nullptr);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
69 ~documentation (void);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
70
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
71 public slots:
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
72
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
73 void notice_settings (const QSettings *settings);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
74
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
75 void copyClipboard (void);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
76 void pasteClipboard (void);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
77 void selectAll (void);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
78
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
79 void load_ref (const QString & name);
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
80 void registerDoc (const QString & name);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
81 void unregisterDoc (const QString & name);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
82
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
83 private slots:
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
84
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
85 void global_search (void);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
86 void global_search_started (void);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
87 void global_search_finished (int hits);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
88 void filter_update (const QString& expression);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
89 void filter_update_history (void);
25121
9578133ca03e Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25060
diff changeset
90 void find_forward (void);
9578133ca03e Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25060
diff changeset
91 void find_backward (void);
25155
17387d4edd1d Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25121
diff changeset
92 void find_forward_from_anchor (const QString& text);
17387d4edd1d Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25121
diff changeset
93 void record_anchor_position (void);
17387d4edd1d Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25121
diff changeset
94 void handle_cursor_position_change (void);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
95
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25371
diff changeset
96 signals:
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25371
diff changeset
97 void show_single_result (const QUrl);
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25371
diff changeset
98
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
99 private:
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
100
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
101 QHelpEngine *m_help_engine;
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25371
diff changeset
102 QString m_internal_search;
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
103 documentation_browser *m_doc_browser;
25121
9578133ca03e Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25060
diff changeset
104 QLineEdit *m_find_line_edit;
25155
17387d4edd1d Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25121
diff changeset
105 int m_search_anchor_position;
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
106 QComboBox *m_filter;
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
107 QString m_collection;
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25155
diff changeset
108 QShortcut *m_show_shortcut;
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25155
diff changeset
109 QShortcut *m_findnext_shortcut;
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25155
diff changeset
110 QShortcut *m_findprev_shortcut;
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
111 };
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
112
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
113 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
114
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
115 #endif