annotate libgui/src/documentation.cc @ 27676:ea7d36e9f197

use standard C++ range-based for loops instead of Qt foreach macro * documentation.cc, file-editor.cc, octave-qscintilla.cc, main-window.cc, resource-manager.cc, variable-editor.cc: Replace uses of Qt foreach macros with standard C++ range-based for loops.
author John W. Eaton <jwe@octave.org>
date Tue, 12 Nov 2019 13:51:22 -0500
parents a36443e94f8a
children fa0582694fda
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
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26318
diff changeset
3 Copyright (C) 2018-2019 Torsten <mttl@maibox.org>
25042
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
26050
ce46820c5e9f fix build failure for documentation.cc (bug #55003)
Torsten <mttl@mailbox.org>
parents: 26017
diff changeset
27 #include <QAction>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
28 #include <QApplication>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
29 #include <QCompleter>
27612
62236e51a8c6 eliminate unnecessary includes from resource-manager.h
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
30 #include <QDesktopServices>
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
31 #include <QDir>
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
32 #include <QFile>
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
33 #include <QFileInfo>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
34 #include <QHelpContentWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
35 #include <QHelpIndexWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
36 #include <QHelpSearchEngine>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
37 #include <QHelpSearchQueryWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
38 #include <QHelpSearchResultWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
39 #include <QLabel>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
40 #include <QLineEdit>
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
41 #include <QMessageBox>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
42 #include <QTabWidget>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
43 #include <QVBoxLayout>
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
44
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
45 #include "documentation.h"
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
46 #include "gui-preferences-global.h"
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
47 #include "octave-qobject.h"
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
48 #include "shortcut-manager.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
49
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
50 #include "defaults.h"
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
51 #include "file-ops.h"
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
52 #include "oct-env.h"
25042
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 namespace octave
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 // 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
57 // of the doc dock widget
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
58 documentation::documentation (QWidget *p, base_qobject& oct_qobj)
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
59 : QSplitter (Qt::Horizontal, p),
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
60 m_octave_qobj (oct_qobj), m_doc_widget (p),
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
61 m_tool_bar (new QToolBar (p)),
26245
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
62 m_query_string (QString ()),
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
63 m_prev_pages_menu (new QMenu (p)),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
64 m_next_pages_menu (new QMenu (p)),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
65 m_prev_pages_count (0),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
66 m_next_pages_count (0),
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
67 m_findnext_shortcut (new QShortcut (p)),
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
68 m_findprev_shortcut (new QShortcut (p))
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
69 {
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
70 // Get original collection
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
71 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
72 if (collection.isEmpty ())
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
73 collection = QString::fromStdString (config::oct_doc_dir ()
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
74 + sys::file_ops::dir_sep_str ()
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
75 + "octave_interpreter.qhc");
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
76
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
77 // 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
78 // 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
79 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
80
26729
c66f509d9f5c Mark qt documentation as readonly (bug #53841).
John Donoghue
parents: 26554
diff changeset
81 // Mark help as readonly to avoid error if collection file is stored in a
c66f509d9f5c Mark qt documentation as readonly (bug #53841).
John Donoghue
parents: 26554
diff changeset
82 // readonly location
c66f509d9f5c Mark qt documentation as readonly (bug #53841).
John Donoghue
parents: 26554
diff changeset
83 m_help_engine->setProperty ("_q_readonly",
c66f509d9f5c Mark qt documentation as readonly (bug #53841).
John Donoghue
parents: 26554
diff changeset
84 QVariant::fromValue<bool> (true));
c66f509d9f5c Mark qt documentation as readonly (bug #53841).
John Donoghue
parents: 26554
diff changeset
85
25101
29641449ca90 use qt routines for determining users tmp directory (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25094
diff changeset
86 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
87 m_collection
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25258
diff changeset
88 = QString::fromStdString (sys::tempnam (tmpdir.toStdString (),
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25258
diff changeset
89 "oct-qhelp-"));
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
90
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
91 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
92 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
93 else
26064
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
94 #ifdef ENABLE_DOCS
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
95 // FIXME: Perhaps a better way to do this would be to keep a count
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
96 // in the GUI preferences file. After issuing this warning 3 times
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
97 // it would be disabled. The count would need to be reset when a new
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
98 // version of Octave is installed.
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
99 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
100 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
101 "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
102 "%1").arg (m_help_engine->error ()));
26064
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
103 #endif
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
104
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
105 connect(m_help_engine, SIGNAL(setupFinished()),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
106 m_help_engine->searchEngine(), SLOT(indexDocumentation()));
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
107
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
108 if (! m_help_engine->setupData())
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
109 {
26064
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
110 #ifdef ENABLE_DOCS
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
111 QMessageBox::warning (this, tr ("Octave Documentation"),
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
112 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
113 "documentation viewer. Only help texts in\n"
25163
3aed4f0ba3cd Update some GUI strings identified as unclear by translators.
Rik <rik@octave.org>
parents: 25121
diff changeset
114 "the Command Window will be available."));
26064
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
115 #endif
26746
3d0f687e4a21 avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26729
diff changeset
116
3d0f687e4a21 avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26729
diff changeset
117 disconnect (m_help_engine, 0, 0, 0);
3d0f687e4a21 avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26729
diff changeset
118
3d0f687e4a21 avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26729
diff changeset
119 delete m_help_engine;
3d0f687e4a21 avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26729
diff changeset
120 m_help_engine = nullptr;
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
121 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
122
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
123 // 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
124 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
125 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
126 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
127 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
128
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
129 // Tool bar
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
130 construct_tool_bar ();
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
131
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
132 // Find bar
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
133 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
134 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
135 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
136 connect (m_find_line_edit, SIGNAL (returnPressed (void)),
27092
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
137 this, SLOT(find (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
138 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
139 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
140 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
141 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
142 forward_button->setToolTip (tr ("Search forward"));
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
143 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
144 forward_button->setIcon (rmgr.icon ("go-down"));
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
145 connect (forward_button, SIGNAL (pressed (void)),
27092
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
146 this, SLOT(find (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
147 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
148 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
149 backward_button->setToolTip (tr ("Search backward"));
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
150 backward_button->setIcon (rmgr.icon ("go-up"));
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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160
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
161 QVBoxLayout *v_box_browser_find = new QVBoxLayout (browser_find);
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
162 v_box_browser_find->addWidget (m_tool_bar);
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
163 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
164 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
165 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
166
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
167 notice_settings (rmgr.get_settings ());
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
168
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
169 m_findnext_shortcut->setContext (Qt::WidgetWithChildrenShortcut);
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
170 connect (m_findnext_shortcut, SIGNAL (activated (void)),
27092
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
171 this, SLOT(find (void)));
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
172 m_findprev_shortcut->setContext (Qt::WidgetWithChildrenShortcut);
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
173 connect (m_findprev_shortcut, SIGNAL (activated (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
174 this, SLOT(find_backward (void)));
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
175
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
176 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
177 m_search_anchor_position = 0;
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
178
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
179 if (m_help_engine)
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
180 {
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
181 // Layout contents, index and search
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
182 QTabWidget *navi = new QTabWidget (this);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
183 navi->setTabsClosable (false);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
184 navi->setMovable (true);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
185
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
186 // Contents
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
187 QHelpContentWidget *content = m_help_engine->contentWidget ();
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
188 content->setObjectName ("documentation_tab_contents");
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
189 navi->addTab (content, tr ("Contents"));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
190
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
191 connect(m_help_engine->contentWidget (),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
192 SIGNAL (linkActivated (const QUrl&)),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
193 m_doc_browser, SLOT(handle_index_clicked (const QUrl&)));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
194
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
195 // Index
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
196 QHelpIndexWidget *index = m_help_engine->indexWidget ();
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
197
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
198 m_filter = new QComboBox (this);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
199 m_filter->setToolTip (tr ("Enter text to search the indices"));
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
200 m_filter->setEditable (true);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
201 m_filter->setInsertPolicy (QComboBox::NoInsert);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
202 m_filter->setMaxCount (10);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
203 m_filter->setMaxVisibleItems (10);
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27124
diff changeset
204 m_filter->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon);
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
205 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
206 m_filter->setSizePolicy (sizePol);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
207 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
208 QLabel *filter_label = new QLabel (tr ("Search"));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
209
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
210 QWidget *filter_all = new QWidget (navi);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
211 QHBoxLayout *h_box_index = new QHBoxLayout (filter_all);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
212 h_box_index->addWidget (filter_label);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
213 h_box_index->addWidget (m_filter);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
214 h_box_index->setMargin (2);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
215 filter_all->setLayout (h_box_index);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
216
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
217 QWidget *index_all = new QWidget (navi);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
218 index_all->setObjectName ("documentation_tab_index");
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
219 QVBoxLayout *v_box_index = new QVBoxLayout (index_all);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
220 v_box_index->addWidget (filter_all);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
221 v_box_index->addWidget (index);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
222 index_all->setLayout (v_box_index);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
223
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
224 navi->addTab (index_all, tr ("Function Index"));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
225
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
226 connect(m_help_engine->indexWidget (),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
227 SIGNAL (linkActivated (const QUrl&, const QString&)),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
228 m_doc_browser, SLOT(handle_index_clicked (const QUrl&,
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
229 const QString&)));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
230
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
231 connect (m_filter, SIGNAL (editTextChanged (const QString&)),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
232 this, SLOT(filter_update (const QString&)));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
233
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
234 connect (m_filter->lineEdit (), SIGNAL (editingFinished (void)),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
235 this, SLOT(filter_update_history (void)));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
236
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
237 // Search
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
238 QHelpSearchEngine *search_engine = m_help_engine->searchEngine ();
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
239 QHelpSearchQueryWidget *search = search_engine->queryWidget ();
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
240 QHelpSearchResultWidget *result = search_engine->resultWidget ();
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
241 QWidget *search_all = new QWidget (navi);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
242 QVBoxLayout *v_box_search = new QVBoxLayout (search_all);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
243 v_box_search->addWidget (search);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
244 v_box_search->addWidget (result);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
245 search_all->setLayout (v_box_search);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
246 search_all->setObjectName ("documentation_tab_search");
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
247 navi->addTab (search_all, tr ("Search"));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
248
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
249 connect (search, SIGNAL (search (void)),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
250 this, SLOT(global_search (void)));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
251
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
252 connect (search_engine, SIGNAL (searchingStarted (void)),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
253 this, SLOT(global_search_started (void)));
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
254 connect (search_engine, SIGNAL (searchingFinished (int)),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
255 this, SLOT(global_search_finished (int)));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
256
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
257 connect (search_engine->resultWidget (),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
258 SIGNAL (requestShowLink (const QUrl&)),
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
259 this,
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
260 SLOT(handle_search_result_clicked (const QUrl&)));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
261
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
262 // Fill the splitter
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
263 insertWidget (0, navi);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
264 insertWidget (1, browser_find);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
265 setStretchFactor (1, 1);
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
266 }
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
267
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
268 // Initial view: Contents
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27124
diff changeset
269 m_doc_browser->setSource
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27124
diff changeset
270 (QUrl ("qthelp://org.octave.interpreter-1.0/doc/octave.html/index.html"));
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
271 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
272
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
273 documentation::~documentation (void)
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 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
276 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
277
25102
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
278 // 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
279 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
280 if (file.exists ())
65b7380655f2 prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25101
diff changeset
281 {
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
282 QFileInfo finfo (file);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
283 QString bname = finfo.fileName ();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
284 QDir dir = finfo.absoluteDir ();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
285 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
286 QStringList namefilter;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
287 namefilter.append ("*" + bname + "*");
27676
ea7d36e9f197 use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents: 27672
diff changeset
288 for (const auto& fi : dir.entryInfoList (namefilter))
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
289 {
25094
c0d48cfbb59a use Octave system functions to avoid build failure with Qt 4 (bug #53540)
Mike Miller <mtmiller@octave.org>
parents: 25061
diff changeset
290 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
291 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
292 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
293
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
294 file.remove();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
295 }
25042
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
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
298 QAction * documentation::add_action (const QIcon& icon, const QString& text,
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
299 const char *member, QWidget *receiver,
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
300 QToolBar *tool_bar)
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
301 {
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
302 QAction *a;
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
303 QWidget *r = this;
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
304 if (receiver != nullptr)
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
305 r = receiver;
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
306
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
307 a = new QAction (icon, text, this);
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
308 connect (a, SIGNAL (triggered ()), r, member);
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
309
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
310 if (tool_bar)
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
311 tool_bar->addAction (a);
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
312
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
313 m_doc_widget->addAction (a); // important for shortcut context
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
314 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
315
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
316 return a;
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
317 }
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
318
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
319 void documentation::construct_tool_bar (void)
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
320 {
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
321 // Home, Previous, Next
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
322 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
323 m_action_go_home
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
324 = add_action (rmgr.icon ("go-home"), tr ("Go home"), SLOT (home (void)),
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
325 m_doc_browser, m_tool_bar);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
326 m_action_go_prev
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
327 = add_action (rmgr.icon ("go-previous"), tr ("Go back"),
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
328 SLOT (backward (void)), m_doc_browser, m_tool_bar);
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
329 m_action_go_prev->setEnabled (false);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
330
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
331 // popdown menu with prev pages files
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
332 QToolButton *popdown_button_prev_pages = new QToolButton ();
26300
ef7f95f89407 updated language files for translation (bug #55279)
Torsten <mttl@mailbox.org>
parents: 26257
diff changeset
333 popdown_button_prev_pages->setToolTip (tr ("Previous pages"));
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
334 popdown_button_prev_pages->setMenu (m_prev_pages_menu);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
335 popdown_button_prev_pages->setPopupMode (QToolButton::InstantPopup);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
336 popdown_button_prev_pages->setToolButtonStyle (Qt::ToolButtonTextOnly);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
337 popdown_button_prev_pages->setCheckable (false);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
338 popdown_button_prev_pages->setArrowType(Qt::DownArrow);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
339 m_tool_bar->addWidget (popdown_button_prev_pages);
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
340 m_action_go_next
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
341 = add_action (rmgr.icon ("go-next"), tr ("Go forward"),
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
342 SLOT (forward (void)), m_doc_browser, m_tool_bar);
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
343 m_action_go_next->setEnabled (false);
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
344
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
345 // popdown menu with prev pages files
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
346 QToolButton *popdown_button_next_pages = new QToolButton ();
26300
ef7f95f89407 updated language files for translation (bug #55279)
Torsten <mttl@mailbox.org>
parents: 26257
diff changeset
347 popdown_button_next_pages->setToolTip (tr ("Next pages"));
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
348 popdown_button_next_pages->setMenu (m_next_pages_menu);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
349 popdown_button_next_pages->setPopupMode (QToolButton::InstantPopup);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
350 popdown_button_next_pages->setToolButtonStyle (Qt::ToolButtonTextOnly);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
351 popdown_button_next_pages->setArrowType(Qt::DownArrow);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
352 m_tool_bar->addWidget (popdown_button_next_pages);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
353
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
354 connect (m_doc_browser, SIGNAL (backwardAvailable (bool)),
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
355 m_action_go_prev, SLOT (setEnabled (bool)));
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
356 connect (m_doc_browser, SIGNAL (backwardAvailable (bool)),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
357 popdown_button_prev_pages, SLOT (setEnabled (bool)));
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
358 connect (m_doc_browser, SIGNAL (forwardAvailable (bool)),
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
359 m_action_go_next, SLOT (setEnabled (bool)));
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
360 connect (m_doc_browser, SIGNAL (forwardAvailable (bool)),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
361 popdown_button_next_pages, SLOT (setEnabled (bool)));
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
362 connect (m_doc_browser, SIGNAL (historyChanged (void)),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
363 this, SLOT (update_history_menus (void)));
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
364
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
365 // Init prev/next menus
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
366 for (int i = 0; i < max_history_entries; ++i)
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
367 {
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
368 m_prev_pages_actions[i] = new QAction (this);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
369 m_prev_pages_actions[i]->setVisible (false);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
370 m_next_pages_actions[i] = new QAction (this);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
371 m_next_pages_actions[i]->setVisible (false);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
372 m_prev_pages_menu->addAction (m_prev_pages_actions[i]);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
373 m_next_pages_menu->addAction (m_next_pages_actions[i]);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
374 }
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
375
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
376 connect (m_prev_pages_menu, SIGNAL (triggered (QAction *)),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
377 this, SLOT (open_hist_url (QAction *)));
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
378 connect (m_next_pages_menu, SIGNAL (triggered (QAction *)),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
379 this, SLOT (open_hist_url (QAction *)));
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
380
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
381 // Find
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
382 m_tool_bar->addSeparator ();
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
383 m_action_find
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
384 = add_action (rmgr.icon ("edit-find"), tr ("Find"),
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
385 SLOT (activate_find (void)), this, m_tool_bar);
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
386
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
387 // Zoom
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
388 m_tool_bar->addSeparator ();
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
389 m_action_zoom_in
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
390 = add_action (rmgr.icon ("zoom-in"), tr ("Zoom in"),
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
391 SLOT (zoom_in (void)), m_doc_browser, m_tool_bar);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
392 m_action_zoom_out
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
393 = add_action (rmgr.icon ("zoom-out"), tr ("Zoom out"),
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
394 SLOT (zoom_out (void)), m_doc_browser, m_tool_bar);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
395 m_action_zoom_original
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
396 = add_action (rmgr.icon ("zoom-original"), tr ("Zoom original"),
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
397 SLOT (zoom_original (void)), m_doc_browser, m_tool_bar);
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
398 }
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
399
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
400 void documentation::global_search (void)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
401 {
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
402 if (! m_help_engine)
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
403 return;
26318
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
404
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
405 QString query_string;
25061
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
406 #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
407 QString queries
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
408 = m_help_engine->searchEngine ()->queryWidget ()->searchInput ();
26318
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
409 query_string = queries;
25061
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
410 #else
26318
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
411 // FIXME: drop this part when support for Qt4 is dropped
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
412 QList<QHelpSearchQuery> queries
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
413 = m_help_engine->searchEngine ()->queryWidget ()->query ();
26245
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
414 if (queries.count ())
26318
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
415 query_string = queries.first ().wordList.join (" ");
26245
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
416 else
26318
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
417 query_string = "";
25061
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
418 #endif
5fef743c34d7 build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents: 25060
diff changeset
419
27112
f8434681af15 * documentation.cc (global_search): just return if query string is empty (bug #56388)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
420 if (query_string.isEmpty ())
f8434681af15 * documentation.cc (global_search): just return if query string is empty (bug #56388)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
421 return;
f8434681af15 * documentation.cc (global_search): just return if query string is empty (bug #56388)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
422
26318
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
423 // Get quoted search strings first, then take first string as fall back
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
424 QRegExp rx ("\"([^\"]*)\"");
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
425 if (rx.indexIn (query_string, 0) != -1)
26497
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
426 m_internal_search = rx.cap (1);
26318
e1b849489e73 improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26300
diff changeset
427 else
26497
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
428 m_internal_search = query_string.split (" ", QString::SkipEmptyParts).first ();
26245
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
429
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
430 m_help_engine->searchEngine ()->search (queries);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
431 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
432
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
433 void documentation::global_search_started (void)
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 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
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::global_search_finished (int)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
439 {
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
440 if (! m_help_engine)
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
441 return;
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
442
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
443 if (! m_internal_search.isEmpty ())
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
444 {
26497
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
445 m_query_string = m_internal_search;
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
446
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
447 QHelpSearchEngine *search_engine = m_help_engine->searchEngine ();
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
448 if (search_engine)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
449 {
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
450 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
451 QVector<QHelpSearchResult> res
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
452 = search_engine->searchResults (0, search_engine->searchResultCount ());
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
453 #else
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
454 QList< QPair<QString, QString> > res
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
455 = search_engine->hits (0, search_engine->hitCount ());
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
456 #endif
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
457
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
458 if (res.count ())
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
459 {
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
460 QUrl url;
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
461
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
462 if (res.count () == 1)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
463 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
464 url = res.front ().url ();
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
465 #else
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
466 url = res.front ().first;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
467 #endif
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
468 else
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
469 {
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
470 // Remove the quotes we added
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
471 QString search_string = m_internal_search;
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
472
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
473 for (auto r = res.begin (); r != res.end (); r++)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
474 {
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
475 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
476 QString title = r->title ().toLower ();
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
477 QUrl tmpurl = r->url ();
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
478 #else
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
479 QString title = r->second.toLower ();
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
480 QUrl tmpurl = r->first;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
481 #endif
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
482 if (title.contains (search_string.toLower ()))
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
483 {
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
484 if (title.indexOf (search_string.toLower ()) == 0)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
485 {
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
486 url = tmpurl;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
487 break;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
488 }
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
489 else if (url.isEmpty ())
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
490 url = tmpurl;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
491 }
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
492 }
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
493 }
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
494
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
495 if (! url.isEmpty ())
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
496 {
26497
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
497 connect (this, SIGNAL (show_single_result (const QUrl&)),
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
498 this,
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
499 SLOT (handle_search_result_clicked (const QUrl&)));
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
500
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
501 emit show_single_result (url);
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
502 }
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
503 }
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
504 }
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
505
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
506 m_internal_search = QString ();
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
507 }
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
508
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
509 qApp->restoreOverrideCursor();
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
510 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
511
26245
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
512 void documentation::handle_search_result_clicked (const QUrl& url)
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
513 {
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
514 // Open url with matching text
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
515 m_doc_browser->handle_index_clicked (url);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
516
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
517 // Select all occurrences of matching text
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
518 select_all_occurrences (m_query_string);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
519
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
520 // Open search widget with matching text as search string
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
521 m_find_line_edit->setText (m_query_string);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
522 m_find_line_edit->parentWidget ()->show ();
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
523
26497
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
524 // If no occurrence can be found go to the top of the page
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
525 if (! m_doc_browser->find (m_find_line_edit->text ()))
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
526 m_doc_browser->moveCursor (QTextCursor::Start);
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
527 else
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
528 {
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
529 // Go to to first occurrence of search text. Going to the end and then
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
530 // search backwards until the last occurrence ensures the search text
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
531 // is visible in the first line of the visible part of the text.
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
532 m_doc_browser->moveCursor (QTextCursor::End);
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
533 while (m_doc_browser->find (m_find_line_edit->text (),
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
534 QTextDocument::FindBackward));
6e0bf8212b40 improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents: 26408
diff changeset
535 }
26245
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
536 }
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
537
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
538 void documentation::select_all_occurrences (const QString& text)
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
539 {
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
540 // Get highlight background and text color
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
541 QPalette pal = QApplication::palette ();
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
542 QTextCharFormat format;
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
543 QColor col = pal.color (QPalette::Highlight);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
544 col.setAlphaF (0.25);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
545 format.setBackground (QBrush (col));
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
546 format.setForeground (QBrush (pal.color (QPalette::Text)));
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
547
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
548 // Create list for extra selected items
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
549 QList<QTextEdit::ExtraSelection> selected;
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
550 m_doc_browser->moveCursor (QTextCursor::Start);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
551
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
552 // Find all occurrences and add them to the selection
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
553 while ( m_doc_browser->find (text) )
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
554 {
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
555 QTextEdit::ExtraSelection selected_item;
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
556 selected_item.cursor = m_doc_browser->textCursor ();
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
557 selected_item.format = format;
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
558 selected.append (selected_item);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
559 }
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
560
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
561 // Apply selection and move back to the beginning
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
562 m_doc_browser->setExtraSelections (selected);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
563 m_doc_browser->moveCursor (QTextCursor::Start);
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
564 }
af99ea9c325f Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents: 26190
diff changeset
565
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
566 void documentation::notice_settings (const gui_settings *settings)
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
567 {
26408
25dfa8c96b7b * documentation.cc (notice_settings): prevent segfault if help engine does not exist
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
568 // If m_help_engine is not defined, the object accessed by this method
25dfa8c96b7b * documentation.cc (notice_settings): prevent segfault if help engine does not exist
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
569 // are not valid. Thus, just return in this case
25dfa8c96b7b * documentation.cc (notice_settings): prevent segfault if help engine does not exist
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
570 if (! m_help_engine)
25dfa8c96b7b * documentation.cc (notice_settings): prevent segfault if help engine does not exist
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
571 return;
25dfa8c96b7b * documentation.cc (notice_settings): prevent segfault if help engine does not exist
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
572
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
573 // Icon size in the toolbar.
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27630
diff changeset
574 int size_idx = settings->value (global_icon_size).toInt ();
26058
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 26050
diff changeset
575 size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
576
26058
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 26050
diff changeset
577 QStyle *st = style ();
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 26050
diff changeset
578 int icon_size = st->pixelMetric (global_icon_sizes[size_idx]);
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
579 m_tool_bar->setIconSize (QSize (icon_size, icon_size));
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
580
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
581 // Shortcuts
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
582 shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager ();
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
583
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
584 scmgr.set_shortcut (m_action_find, "editor_edit:find_replace");
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
585 scmgr.shortcut (m_findnext_shortcut, "editor_edit:find_next");
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
586 scmgr.shortcut (m_findprev_shortcut, "editor_edit:find_previous");
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
587 scmgr.set_shortcut (m_action_zoom_in, "editor_view:zoom_in");
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
588 scmgr.set_shortcut (m_action_zoom_out, "editor_view:zoom_out");
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
589 scmgr.set_shortcut (m_action_zoom_original, "editor_view:zoom_normal");
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
590 scmgr.set_shortcut (m_action_go_home, "doc_browser:go_home");
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
591 scmgr.set_shortcut (m_action_go_prev, "doc_browser:go_back");
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
592 scmgr.set_shortcut (m_action_go_next, "doc_browser:go_next");
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25336
diff changeset
593 }
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
594
25962
12ad5eb2328e Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents: 25609
diff changeset
595 void documentation::copyClipboard (void)
12ad5eb2328e Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents: 25609
diff changeset
596 {
12ad5eb2328e Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents: 25609
diff changeset
597 if (m_doc_browser->hasFocus ())
12ad5eb2328e Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents: 25609
diff changeset
598 {
12ad5eb2328e Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents: 25609
diff changeset
599 m_doc_browser->copy();
12ad5eb2328e Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents: 25609
diff changeset
600 }
12ad5eb2328e Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents: 25609
diff changeset
601 }
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
602
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
603 void documentation::pasteClipboard (void) { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
604
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
605 void documentation::selectAll (void) { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
606
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
607 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
608 {
26770
2f550a8122d5 Simply show the doc browser when the search query is empty (bug #55756).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26755
diff changeset
609 if (! m_help_engine || ref_name.isEmpty ())
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
610 return;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
611
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
612 // First search in the function index
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
613 QMap<QString, QUrl> found_links
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
614 = m_help_engine->linksForIdentifier (ref_name);
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
615
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
616 QTabWidget *navi = static_cast<QTabWidget*> (widget (0));
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
617
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
618 if (found_links.count() > 0)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
619 {
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
620 m_doc_browser->setSource (found_links.constBegin().value());
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
621
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
622 // Switch to function index tab
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
623 m_help_engine->indexWidget()->filterIndices (ref_name);
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
624 QWidget *index_tab
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
625 = navi->findChild<QWidget*> ("documentation_tab_index");
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
626 navi->setCurrentWidget (index_tab);
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
627 }
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
628 else
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
629 {
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
630 // Use full text search to provide the best match
25609
506419b5f817 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25541
diff changeset
631 QHelpSearchEngine *search_engine = m_help_engine->searchEngine ();
25541
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
632 QHelpSearchQueryWidget *search_query = search_engine->queryWidget ();
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
633
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
634 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
635 QString query = ref_name;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
636 query.prepend ("\"").append ("\"");
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
637 #else
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
638 QList<QHelpSearchQuery> query;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
639 query << QHelpSearchQuery (QHelpSearchQuery::DEFAULT,
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
640 QStringList (QString("\"") + ref_name + QString("\"")));
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
641 #endif
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
642 m_internal_search = ref_name;
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
643 search_engine->search (query);
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
644
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
645 // Switch to search tab
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
646 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT)
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
647 search_query->setSearchInput (query);
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
648 #else
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
649 search_query->setQuery (query);
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
650 #endif
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
651 QWidget *search_tab
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
652 = navi->findChild<QWidget*> ("documentation_tab_search");
517c73173011 doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25460
diff changeset
653 navi->setCurrentWidget (search_tab);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
654 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
655 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
656
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
657 void documentation::activate_find (void)
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
658 {
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
659 if (m_find_line_edit->parentWidget ()->isVisible ())
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
660 {
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
661 m_find_line_edit->parentWidget ()->hide ();
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
662 m_doc_browser->setFocus ();
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
663 }
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
664 else
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
665 {
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
666 m_find_line_edit->parentWidget ()->show ();
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
667 m_find_line_edit->selectAll ();
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
668 m_find_line_edit->setFocus ();
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
669 }
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
670 }
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
671
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
672 void documentation::filter_update (const QString& expression)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
673 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
674 if (! m_help_engine)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
675 return;
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
676
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
677 QString wildcard;
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
678 if (expression.contains (QLatin1Char('*')))
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
679 wildcard = expression;
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
680
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
681 m_help_engine->indexWidget ()->filterIndices(expression, wildcard);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
682 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
683
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
684 void documentation::filter_update_history (void)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
685 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
686 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
687 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
688
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
689 if (index > -1)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
690 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
691
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
692 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
693 m_filter->setCurrentIndex (0);
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
694 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
695
27092
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
696 void documentation::find_backward (void)
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
697 {
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
698 find (true);
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
699 }
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
700
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
701 void documentation::find (bool backward)
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
702 {
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
703 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
704 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
705
27092
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
706 QTextDocument::FindFlags find_flags = 0;
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
707 if (backward)
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
708 find_flags = QTextDocument::FindBackward;
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
709
27092
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
710 if (! m_doc_browser->find (m_find_line_edit->text (), find_flags))
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
711 {
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
712 // Nothing was found, restart search from the begin or end of text
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
713 QTextCursor textcur = m_doc_browser->textCursor ();
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
714 if (backward)
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
715 textcur.movePosition (QTextCursor::End);
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
716 else
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
717 textcur.movePosition (QTextCursor::Start);
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
718 m_doc_browser->setTextCursor (textcur);
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
719 m_doc_browser->find (m_find_line_edit->text (), find_flags);
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
720 }
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
721
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
722 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
723 }
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
724
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
725 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
726 {
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
727 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
728 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
729
27091
dcc3a8065ccd wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
730 // Search from the current position
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
731 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
732 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
733 m_doc_browser->setTextCursor (textcur);
27091
dcc3a8065ccd wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
734
dcc3a8065ccd wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
735 if (! m_doc_browser->find (text))
dcc3a8065ccd wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
736 {
dcc3a8065ccd wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
737 // Nothing was found, restart search from the beginning
27092
d1fe5bd5e005 wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27091
diff changeset
738 textcur.movePosition (QTextCursor::Start);
27091
dcc3a8065ccd wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
739 m_doc_browser->setTextCursor (textcur);
dcc3a8065ccd wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
740 m_doc_browser->find (text);
dcc3a8065ccd wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26770
diff changeset
741 }
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
742 }
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
743
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
744 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
745 {
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
746 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
747 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
748
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
749 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
750 }
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
751
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
752 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
753 {
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
754 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
755 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
756
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
757 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
758 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
759 }
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
760
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
761 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
762 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
763 if (m_help_engine)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
764 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
765 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
766 bool do_setup = true;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
767 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
768 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
769 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
770 do_setup = false;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
771 else
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
772 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
773 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
774 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
775 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
776 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
777 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
778 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
779 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
780 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
781 arg (qch));
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
782 return;
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
783 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
784
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
785 if (do_setup)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
786 m_help_engine->setupData();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
787 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
788 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
789
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
790 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
791 {
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
792 if (! m_help_engine)
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
793 return;
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
794
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
795 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
796 if (m_help_engine
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
797 && 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
798 && 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
799 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
800 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
801 m_help_engine->setupData ();
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
802 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25042
diff changeset
803 }
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
804
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
805 void documentation::update_history_menus (void)
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
806 {
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
807 if (m_prev_pages_count != m_doc_browser->backwardHistoryCount ())
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
808 {
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
809 update_history (m_doc_browser->backwardHistoryCount (),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
810 m_prev_pages_actions);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
811 m_prev_pages_count = m_doc_browser->backwardHistoryCount ();
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
812 }
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
813
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
814 if (m_next_pages_count != m_doc_browser->forwardHistoryCount ())
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
815 {
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
816 update_history (m_doc_browser->forwardHistoryCount (),
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
817 m_next_pages_actions);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
818 m_next_pages_count = m_doc_browser->forwardHistoryCount ();
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
819 }
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
820 }
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
821
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
822 void documentation::update_history (int new_count, QAction **actions)
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
823 {
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
824 // Which menu has to be updated?
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
825 int prev_next = -1;
26133
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
826 QAction *a = m_action_go_prev;
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
827 if (actions == m_next_pages_actions)
26133
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
828 {
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
829 prev_next = 1;
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
830 a = m_action_go_next;
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
831 }
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
832
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
833 // Get maximal count limited by array size
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
834 int count = qMin (new_count, int (max_history_entries));
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
835
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
836 // Fill used menu entries
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
837 for (int i = 0; i < count; i++)
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
838 {
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
839 QString title = m_doc_browser->historyTitle (prev_next*(i+1));
26143
c7f845bf4fec doc browser: improve filtering of octave version in history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26134
diff changeset
840 title.remove (QRegExp ("\\s*\\(*GNU Octave \\(version [^\\)]*\\)[: \\)]*"));
26133
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
841
26144
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
842 // Sinve the title only contains the section name and not the
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
843 // specific anchor, extract the latter from the url and append
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
844 // it to the title
26190
c2137ac45dd9 fix build failure with Qt4.8 (bug #55191)
Torsten <mttl@mailbox.org>
parents: 26144
diff changeset
845 QString url = m_doc_browser->historyUrl (prev_next*(i+1)).toString ();
26144
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
846 if (url.contains ('#'))
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
847 {
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
848 // Get the anchor from the url
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
849 QString anchor = url.split ('#').last ();
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
850
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
851 // Remove internal string parts
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
852 anchor.remove (QRegExp ("^index-"));
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
853 anchor.remove (QRegExp ("^SEC_"));
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
854 anchor.remove (QRegExp ("^XREF"));
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
855 anchor.remove ("Concept-Index_cp_letter-");
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
856 anchor.replace ("-"," ");
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
857
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
858 // replace encoded special chars by there unencoded versions
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
859 QRegExp rx = QRegExp ("_00([0-7][0-9a-f])");
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
860 int pos = 0;
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
861 while ((pos = rx.indexIn(anchor, pos)) != -1)
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
862 {
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
863 anchor.replace ("_00"+rx.cap (1), QChar (rx.cap (1).toInt (nullptr,16)));
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
864 pos += rx.matchedLength();
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
865 }
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
866
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
867 if (title != anchor)
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
868 title = title + ": " + anchor;
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
869 }
494452db0477 doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26143
diff changeset
870
26133
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
871 if (i == 0)
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
872 a->setText (title); // set tool tip for prev/next buttons
84cd950f0f75 fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26128
diff changeset
873
26128
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
874 actions[i]->setText (title);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
875 actions[i]->setData (m_doc_browser->historyUrl (prev_next*(i+1)));
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
876 actions[i]->setEnabled (true);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
877 actions[i]->setVisible (true);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
878 }
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
879
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
880 // Hide unused menu entries
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
881 for (int j = count; j < max_history_entries; j++)
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
882 {
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
883 actions[j]->setEnabled (false);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
884 actions[j]->setVisible (false);
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
885 }
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
886 }
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
887
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
888 void documentation::open_hist_url (QAction *a)
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
889 {
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
890 m_doc_browser->setSource (a->data ().toUrl ());
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
891 }
20b87596b99a add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents: 26064
diff changeset
892
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
893
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
894 // The documentation browser
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
895 documentation_browser::documentation_browser (QHelpEngine *he, QWidget *p)
25976
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
896 : QTextBrowser (p), m_help_engine (he), m_zoom_level (0)
26134
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
897 {
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
898 setOpenLinks (false);
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
899 connect (this, SIGNAL (anchorClicked (QUrl)),
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
900 this, SLOT (handle_index_clicked (QUrl)));
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
901 }
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
902
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
903 documentation_browser::~documentation_browser (void)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
904 { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
905
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
906 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
907 const QString&)
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
908 {
26134
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
909 if (url.scheme () == "qthelp")
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
910 setSource (url);
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
911 else
3a38afebf949 open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents: 26133
diff changeset
912 QDesktopServices::openUrl (url);
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
913 }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
914
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
915 void documentation_browser::notice_settings (const gui_settings *)
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
916 { }
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff changeset
917
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
918 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
919 {
26755
c39d26971f4b avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents: 26746
diff changeset
920 if (m_help_engine && url.scheme () == "qthelp")
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
921 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
922 else
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
923 return QTextBrowser::loadResource(type, url);
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25102
diff changeset
924 }
25976
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
925
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
926 void documentation_browser::zoom_in (void)
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
927 {
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
928 if (m_zoom_level < max_zoom_level)
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
929 {
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
930 zoomIn ();
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
931 m_zoom_level++;
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
932 }
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
933 }
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
934
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
935 void documentation_browser::zoom_out (void)
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
936 {
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
937 if (m_zoom_level > min_zoom_level)
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
938 {
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
939 zoomOut ();
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
940 m_zoom_level--;
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
941 }
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
942 }
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
943
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25985
diff changeset
944 void documentation_browser::zoom_original (void)
25976
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
945 {
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
946 zoomIn (- m_zoom_level);
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
947 m_zoom_level = 0;
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25962
diff changeset
948 }
25985
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
949
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
950 void documentation_browser::wheelEvent (QWheelEvent *we)
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
951 {
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
952 if (we->modifiers () == Qt::ControlModifier)
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
953 {
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
954 if (we->delta () > 0)
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
955 zoom_in ();
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
956 else
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
957 zoom_out ();
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
958
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
959 we->accept ();
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
960 }
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
961 else
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
962 QTextEdit::wheelEvent (we);
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
963 }
49ffd0e0242d enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
964
26064
673b1af42143 Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents: 26058
diff changeset
965 }