annotate libgui/src/documentation.cc @ 25155:17387d4edd1d stable

Add standard key bindings and actions to in-page Documentation find (bug #53006) * documentation.cc (documentation::documentation): Connect m_doc_browser cursor position change signal to slot that records position. Connect m_find_line_edit text-edited signal to find_forward_from_anchor() to provide search-while-type. Replace QKeySequence "Ctrl+F" definition with Qt's pre-defined QKeySequence::Find. Change the context of the key press from Qt::WidgetWithChildrenShortcut to the broader Qt::WindowShortcut and rename the sequence show_shortcut. Connect show_shortcut object's activated() signal to parent widget's show() slot and to m_find_line_edit's selectAll() and setFocus() slots. Create a hide_shortcut QShortcut with QKeySequence "Escape" and connect its activated() signal to parent widget's hide() slot and m_doc_browser's setFocus() slot. Create a findnext_shortcut and connect its activated() signal to the documentation class's find_forward() slot. Create a findnext_shortcut and connect its activated() signal to the documentation class's find_backward() slot. Set m_search_anchor_position to zero. (documentation::find_forward): After doing the find operation, record the current "anchor" position of the QTextEdit's cursor position. (documentation::find_backward): Ditto. (documentation::toggle_hidden_find): Removed. (documentation::find_forward_from_anchor): Added. For search-while-type, set the QTextEdit's cursor position back to the anchor position before calling the find() routine and allow "undoing" the search-while-type. (documentation::record_anchor_position): Added. Record the QTextEdit cursor's current position. (documentation::handle_cursor_position_change): Added. Upon the QTextEdit's cursor change, call record_anchor_position() but only if that position change was due to user action within the window. * documentation.h (documentation:public QSplitter): Add new integer member variable m_search_anchor_position. (documentation::find_forward_from_anchor): Added. Slot declaration. (documentation::record_anchor_position): Ditto. (documentation::handle_cursor_position_change): Ditto.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Thu, 05 Apr 2018 11:35:58 -0500
parents 9578133ca03e
children 512b68611097 e74d85f7ac47
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 (HAVE_CONFIG_H)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
24 # include "config.h"
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
25 #endif
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
26
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
27 #include "defaults.h"
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
28 #include "file-ops.h"
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
29 #include "oct-env.h"
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
30
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
31 #include <QApplication>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
32 #include <QCompleter>
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
33 #include <QDir>
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
34 #include <QFile>
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
35 #include <QFileInfo>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
36 #include <QHelpContentWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
37 #include <QHelpIndexWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
38 #include <QHelpSearchEngine>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
39 #include <QHelpSearchQueryWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
40 #include <QHelpSearchResultWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
41 #include <QLabel>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
42 #include <QLineEdit>
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
43 #include <QMessageBox>
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: 25103
diff changeset
44 #include <QShortcut>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
45 #include <QTabWidget>
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: 25103
diff changeset
46 #include <QToolButton>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
47 #include <QVBoxLayout>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
48
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
49 #include "documentation.h"
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: 25103
diff changeset
50 #include "resource-manager.h"
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
51
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
52 namespace octave
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 // The documentation splitter, which is the main widget
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
55 // of the doc dock widget
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
56 documentation::documentation (QWidget *p)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
57 : QSplitter (Qt::Horizontal, p)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
58 {
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
59 // Get original collection
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
60 QString collection = getenv ("OCTAVE_QTHELP_COLLECTION");
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
61 if (collection.isEmpty ())
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
62 collection = QString::fromStdString (octave::config::oct_doc_dir ()
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
63 + octave::sys::file_ops::dir_sep_str ()
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
64 + "octave_interpreter.qhc");
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
65
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
66 // Setup the help engine with the original collection, use a writable copy
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
67 // of the original collection and load the help data
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
68 m_help_engine = new QHelpEngine (collection, this);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
69
25101
29641449ca90 use qt routines for determining users tmp directory (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25094
diff changeset
70 QString tmpdir = QDir::tempPath();
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
71 m_collection
25101
29641449ca90 use qt routines for determining users tmp directory (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25094
diff changeset
72 = QString::fromStdString (octave::sys::tempnam (tmpdir.toStdString (),
29641449ca90 use qt routines for determining users tmp directory (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25094
diff changeset
73 "oct-qhelp-"));
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
74
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
75 if (m_help_engine->copyCollectionFile (m_collection))
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
76 m_help_engine->setCollectionFile (m_collection);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
77 else
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
78 QMessageBox::warning (this, tr ("Octave Documentation"),
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
79 tr ("Could not copy help collection to temporary\n"
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
80 "file. Search capabilities may be affected.\n"
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
81 "%1").arg (m_help_engine->error ()));
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 connect(m_help_engine, SIGNAL(setupFinished()),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
84 m_help_engine->searchEngine(), SLOT(indexDocumentation()));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
85
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
86 if (! m_help_engine->setupData())
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
87 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
88 QMessageBox::warning (this, tr ("Octave Documentation"),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
89 tr ("Could not setup the data required for the\n"
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
90 "documentation viewer. Only help texts in\n"
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
91 "the Console Widget will be available."));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
92 if (m_help_engine)
25102
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
93 delete m_help_engine;
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
94 m_help_engine = 0;
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
95 return;
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
96 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
97
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
98 // The 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: 25103
diff changeset
99 QWidget *browser_find = new QWidget (this);
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: 25103
diff changeset
100 m_doc_browser = new documentation_browser (m_help_engine, browser_find);
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
101 connect (m_doc_browser, SIGNAL (cursorPositionChanged (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
102 this, SLOT(handle_cursor_position_change (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: 25103
diff changeset
103
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: 25103
diff changeset
104 QWidget *find_footer = new QWidget (browser_find);
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: 25103
diff changeset
105 QLabel *find_label = new QLabel (tr ("Find:"), find_footer);
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: 25103
diff changeset
106 m_find_line_edit = new QLineEdit (find_footer);
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: 25103
diff changeset
107 connect (m_find_line_edit, SIGNAL (returnPressed (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: 25103
diff changeset
108 this, SLOT(find_forward (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
109 connect (m_find_line_edit, SIGNAL (textEdited (const QString&)),
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
110 this, SLOT(find_forward_from_anchor (const QString&)));
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: 25103
diff changeset
111 QToolButton *forward_button = new QToolButton (find_footer);
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: 25103
diff changeset
112 forward_button->setText (tr ("Search forward"));
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: 25103
diff changeset
113 forward_button->setToolTip (tr ("Search forward"));
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: 25103
diff changeset
114 forward_button->setIcon (resource_manager::icon ("go-down"));
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: 25103
diff changeset
115 connect (forward_button, SIGNAL (pressed (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: 25103
diff changeset
116 this, SLOT(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: 25103
diff changeset
117 QToolButton *backward_button = new QToolButton (find_footer);
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: 25103
diff changeset
118 backward_button->setText (tr ("Search backward"));
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: 25103
diff changeset
119 backward_button->setToolTip (tr ("Search backward"));
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: 25103
diff changeset
120 backward_button->setIcon (resource_manager::icon ("go-up"));
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: 25103
diff changeset
121 connect (backward_button, SIGNAL (pressed (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: 25103
diff changeset
122 this, SLOT(find_backward (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: 25103
diff changeset
123 QHBoxLayout *h_box_find_footer = new QHBoxLayout (find_footer);
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: 25103
diff changeset
124 h_box_find_footer->addWidget (find_label);
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: 25103
diff changeset
125 h_box_find_footer->addWidget (m_find_line_edit);
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: 25103
diff changeset
126 h_box_find_footer->addWidget (forward_button);
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: 25103
diff changeset
127 h_box_find_footer->addWidget (backward_button);
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: 25103
diff changeset
128 h_box_find_footer->setMargin (2);
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: 25103
diff changeset
129 find_footer->setLayout (h_box_find_footer);
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: 25103
diff changeset
130
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: 25103
diff changeset
131 QVBoxLayout *v_box_browser_find = new QVBoxLayout (browser_find);
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: 25103
diff changeset
132 v_box_browser_find->addWidget (m_doc_browser);
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: 25103
diff changeset
133 v_box_browser_find->addWidget (find_footer);
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: 25103
diff changeset
134 browser_find->setLayout (v_box_browser_find);
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: 25103
diff changeset
135
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
136 QShortcut *show_shortcut = new QShortcut (QKeySequence (QKeySequence::Find), browser_find);
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
137 show_shortcut->setContext(Qt::WindowShortcut);
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
138 connect (show_shortcut, SIGNAL (activated (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
139 m_find_line_edit->parentWidget (), SLOT (show (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
140 connect (show_shortcut, SIGNAL (activated (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
141 m_find_line_edit, SLOT (selectAll (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
142 connect (show_shortcut, SIGNAL (activated (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
143 m_find_line_edit, SLOT (setFocus (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
144 QShortcut *hide_shortcut = new QShortcut (QKeySequence (tr ("Escape")), m_find_line_edit);
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
145 hide_shortcut->setContext(Qt::WindowShortcut);
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
146 connect (hide_shortcut, SIGNAL (activated (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
147 m_find_line_edit->parentWidget (), SLOT(hide (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
148 connect (hide_shortcut, SIGNAL (activated (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
149 m_doc_browser, SLOT (setFocus (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
150 QShortcut *findnext_shortcut = new QShortcut (QKeySequence (QKeySequence::FindNext), browser_find);
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
151 findnext_shortcut->setContext(Qt::WindowShortcut);
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
152 connect (findnext_shortcut, SIGNAL (activated (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
153 this, SLOT(find_forward (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
154 QShortcut *findprev_shortcut = new QShortcut (QKeySequence (QKeySequence::FindPrevious), browser_find);
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
155 findprev_shortcut->setContext(Qt::WindowShortcut);
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
156 connect (findprev_shortcut, SIGNAL (activated (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
157 this, SLOT(find_backward (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: 25103
diff changeset
158 find_footer->hide ();
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
159 m_search_anchor_position = 0;
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
160
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
161 // Layout contents, index and search
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
162 QTabWidget *navi = new QTabWidget (this);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
163 navi->setTabsClosable (false);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
164 navi->setMovable (true);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
165
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
166 // Contents
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
167 QHelpContentWidget *content = m_help_engine->contentWidget ();
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
168 navi->addTab (content, tr ("Contents"));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
169
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
170 connect(m_help_engine->contentWidget (),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
171 SIGNAL (linkActivated (const QUrl&)),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
172 m_doc_browser, SLOT(handle_index_clicked (const QUrl&)));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
173
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
174 // Index
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
175 QHelpIndexWidget *index = m_help_engine->indexWidget ();
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
176
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
177 m_filter = new QComboBox (this);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
178 m_filter->setToolTip (tr ("Enter text to search the indices"));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
179 m_filter->setEditable (true);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
180 m_filter->setInsertPolicy (QComboBox::NoInsert);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
181 m_filter->setMaxCount (10);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
182 m_filter->setMaxVisibleItems (10);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
183 m_filter->setSizeAdjustPolicy (
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
184 QComboBox::AdjustToMinimumContentsLengthWithIcon);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
185 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
186 m_filter->setSizePolicy (sizePol);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
187 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
188 QLabel *filter_label = new QLabel (tr ("Search"));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
189
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
190 QWidget *filter_all = new QWidget (navi);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
191 QHBoxLayout *h_box_index = new QHBoxLayout (filter_all);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
192 h_box_index->addWidget (filter_label);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
193 h_box_index->addWidget (m_filter);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
194 h_box_index->setMargin (2);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
195 filter_all->setLayout (h_box_index);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
196
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
197 QWidget *index_all = new QWidget (navi);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
198 QVBoxLayout *v_box_index = new QVBoxLayout (index_all);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
199 v_box_index->addWidget (filter_all);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
200 v_box_index->addWidget (index);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
201 index_all->setLayout (v_box_index);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
202
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
203 navi->addTab (index_all, tr ("Index"));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
204
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
205 connect(m_help_engine->indexWidget (),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
206 SIGNAL (linkActivated (const QUrl&, const QString&)),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
207 m_doc_browser, SLOT(handle_index_clicked (const QUrl&,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
208 const QString&)));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
209
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
210 connect (m_filter, SIGNAL (editTextChanged (const QString&)),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
211 this, SLOT(filter_update (const QString&)));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
212
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
213 connect (m_filter->lineEdit (), SIGNAL (editingFinished (void)),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
214 this, SLOT(filter_update_history (void)));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
215
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
216 // Search
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
217 QHelpSearchEngine *search_engine = m_help_engine->searchEngine ();
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
218 QHelpSearchQueryWidget *search = search_engine->queryWidget ();
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
219 QHelpSearchResultWidget *result = search_engine->resultWidget ();
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
220 QWidget *search_all = new QWidget (navi);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
221 QVBoxLayout *v_box_search = new QVBoxLayout (search_all);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
222 v_box_search->addWidget (search);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
223 v_box_search->addWidget (result);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
224 search_all->setLayout (v_box_search);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
225 navi->addTab (search_all, tr ("Search"));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
226
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
227 connect (search, SIGNAL (search (void)),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
228 this, SLOT(global_search (void)));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
229
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
230 connect (search_engine, SIGNAL (searchingStarted (void)),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
231 this, SLOT(global_search_started (void)));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
232 connect (search_engine, SIGNAL (searchingFinished (int)),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
233 this, SLOT(global_search_finished (int)));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
234
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
235 connect (search_engine->resultWidget (),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
236 SIGNAL (requestShowLink (const QUrl&)),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
237 m_doc_browser,
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
238 SLOT(handle_index_clicked (const QUrl&)));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
239
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
240 // Fill the splitter
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
241 insertWidget (0, navi);
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: 25103
diff changeset
242 insertWidget (1, browser_find);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
243 setStretchFactor (1, 1);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
244
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
245 // Initial view: Contents
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
246 m_doc_browser->setSource (QUrl (
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
247 "qthelp://org.octave.interpreter-1.0/doc/octave.html/index.html"));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
248 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
249
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
250 documentation::~documentation (void)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
251 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
252 if (m_help_engine)
25102
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
253 delete m_help_engine;
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
254
25102
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
255 // Cleanup temporary file and directory
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
256 QFile file (m_collection);
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
257 if (file.exists ())
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
258 {
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
259 QFileInfo finfo (file);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
260 QString bname = finfo.fileName ();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
261 QDir dir = finfo.absoluteDir ();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
262 dir.setFilter (QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
263 QStringList namefilter;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
264 namefilter.append ("*" + bname + "*");
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
265 foreach (QFileInfo fi, dir.entryInfoList (namefilter))
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
266 {
25094
c0d48cfbb59a use Octave system functions to avoid build failure with Qt 4 (bug #53540)
Mike Miller <mtmiller@octave.org>
parents: 25061
diff changeset
267 std::string file_name = fi.absoluteFilePath ().toStdString ();
c0d48cfbb59a use Octave system functions to avoid build failure with Qt 4 (bug #53540)
Mike Miller <mtmiller@octave.org>
parents: 25061
diff changeset
268 sys::recursive_rmdir (file_name);
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
269 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
270
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
271 file.remove();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
272 }
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
273 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
274
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
275 void documentation::global_search (void)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
276 {
25061
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
277 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT)
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
278 QString queries
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
279 = m_help_engine->searchEngine ()->queryWidget ()->searchInput ();
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
280 #else
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
281 QList<QHelpSearchQuery> queries
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
282 = m_help_engine->searchEngine ()->queryWidget ()->query ();
25061
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
283 #endif
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
284
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
285 m_help_engine->searchEngine ()->search (queries);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
286 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
287
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
288 void documentation::global_search_started (void)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
289 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
290 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
291 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
292
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
293 void documentation::global_search_finished (int)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
294 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
295 qApp->restoreOverrideCursor();
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
296 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
297
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
298 void documentation::notice_settings (const QSettings *) { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
299
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
300 void documentation::copyClipboard (void) { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
301
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
302 void documentation::pasteClipboard (void) { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
303
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
304 void documentation::selectAll (void) { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
305
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
306 void documentation::load_ref (const QString& ref_name)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
307 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
308 if (m_help_engine)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
309 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
310 QMap<QString, QUrl> found_links
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
311 = m_help_engine->linksForIdentifier (ref_name);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
312 if (found_links.count() > 0)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
313 m_doc_browser->setSource (found_links.constBegin().value());
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
314 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
315 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
316
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
317 void documentation::filter_update (const QString& expression)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
318 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
319 if (! m_help_engine)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
320 return;
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
321
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
322 QString wildcard;
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
323 if (expression.contains (QLatin1Char('*')))
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
324 wildcard = expression;
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
325
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
326 m_help_engine->indexWidget ()->filterIndices(expression, wildcard);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
327 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
328
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
329 void documentation::filter_update_history (void)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
330 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
331 QString text = m_filter->currentText (); // get current text
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
332 int index = m_filter->findText (text); // and its actual index
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
333
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
334 if (index > -1)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
335 m_filter->removeItem (index); // remove if already existing
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
336
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
337 m_filter->insertItem (0, text); // (re)insert at beginning
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
338 m_filter->setCurrentIndex (0);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
339 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
340
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: 25103
diff changeset
341 void documentation::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: 25103
diff changeset
342 {
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: 25103
diff changeset
343 if (! m_help_engine)
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: 25103
diff changeset
344 return;
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: 25103
diff changeset
345
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: 25103
diff changeset
346 m_doc_browser->find (m_find_line_edit->text ());
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
347 record_anchor_position ();
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: 25103
diff changeset
348 }
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: 25103
diff changeset
349
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: 25103
diff changeset
350 void documentation::find_backward (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: 25103
diff changeset
351 {
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: 25103
diff changeset
352 if (! m_help_engine)
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: 25103
diff changeset
353 return;
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: 25103
diff changeset
354
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: 25103
diff changeset
355 m_doc_browser->find (m_find_line_edit->text (), QTextDocument::FindBackward);
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
356 record_anchor_position ();
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: 25103
diff changeset
357 }
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: 25103
diff changeset
358
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
359 void documentation::find_forward_from_anchor (const QString& text)
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: 25103
diff changeset
360 {
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: 25103
diff changeset
361 if (! m_help_engine)
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: 25103
diff changeset
362 return;
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: 25103
diff changeset
363
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
364 QTextCursor textcur = m_doc_browser->textCursor ();
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
365 textcur.setPosition (m_search_anchor_position);
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
366 m_doc_browser->setTextCursor (textcur);
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
367 m_doc_browser->find (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
368 }
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
369
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
370 void documentation::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
371 {
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
372 if (! m_help_engine)
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
373 return;
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
374
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
375 m_search_anchor_position = m_doc_browser->textCursor ().position ();
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
376 }
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
377
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
378 void documentation::handle_cursor_position_change (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
379 {
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
380 if (! m_help_engine)
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
381 return;
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
382
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
383 if (m_doc_browser->hasFocus ())
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
384 record_anchor_position ();
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: 25103
diff changeset
385 }
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: 25103
diff changeset
386
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
387 void documentation::registerDoc (const QString& qch)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
388 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
389 if (m_help_engine)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
390 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
391 QString ns = m_help_engine->namespaceName (qch);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
392 bool do_setup = true;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
393 if (m_help_engine->registeredDocumentations ().contains (ns))
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
394 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
395 if (m_help_engine->documentationFileName (ns) == qch)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
396 do_setup = false;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
397 else
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
398 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
399 m_help_engine->unregisterDocumentation (ns);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
400 m_help_engine->registerDocumentation (qch);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
401 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
402 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
403 else if (! m_help_engine->registerDocumentation (qch))
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
404 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
405 QMessageBox::warning (this, tr ("Octave Documentation"),
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
406 tr ("Unable to register help file %1.").
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
407 arg (qch));
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
408 do_setup = false;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
409 return;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
410 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
411
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
412 if (do_setup)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
413 m_help_engine->setupData();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
414 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
415 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
416
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
417 void documentation::unregisterDoc (const QString& qch)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
418 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
419 QString ns = m_help_engine->namespaceName (qch);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
420 if (m_help_engine
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
421 && m_help_engine->registeredDocumentations ().contains (ns)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
422 && m_help_engine->documentationFileName (ns) == qch)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
423 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
424 m_help_engine->unregisterDocumentation (ns);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
425 m_help_engine->setupData ();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
426 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
427 }
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
428
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
429
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
430 // The documentation browser
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
431 documentation_browser::documentation_browser (QHelpEngine *he, QWidget *p)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
432 : QTextBrowser (p), m_help_engine (he)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
433 { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
434
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
435 documentation_browser::~documentation_browser (void)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
436 { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
437
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
438 void documentation_browser::handle_index_clicked (const QUrl& url,
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
439 const QString&)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
440 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
441 setSource (url);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
442 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
443
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
444 void documentation_browser::notice_settings (const QSettings *)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
445 { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
446
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
447 QVariant documentation_browser::loadResource (int type, const QUrl &url)
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
448 {
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
449 if (url.scheme () == "qthelp")
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
450 return QVariant (m_help_engine->fileData(url));
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
451 else
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
452 return QTextBrowser::loadResource(type, url);
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
453 }
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
454
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
455 }