annotate libgui/src/qtinfo/webinfo.cc @ 17029:359c5ca795cd

Display doc info pages using documentation browser when in GUI mode (Bug #39451) * scripts/help/doc.m: call __octave_link_show_doc if in gui mode. * libinterp/corefcn/octave-link.h, libinterp/corefcn/octave-link.cc (octave_link::show_doc): New function. (octave_link::do_show_doc): New virtual function. (__octave_link_show_doc__): New function. * libgui/src/octave-qt-link.h (octave_qt_link::show_doc_signal): New signal. (octave_qt_link::do_show_doc): New function. * libgui/src/documentation-dock-widget.cc, libgui/src/documentation-dock-widget.h (documentation_dock_widget::showDoc): New function. * libgui/src/main-window.cc, libgui/src/main-window.h (main_window::construct_octave_qt_link): connect handle_show_doc. (main_window::handle_show_doc): New function. (main_window::show_doc_signal): New signal. * libgui/src/qtinfo/parser.cc, libgui/src/qtinfo/parser.h (parser::find_ref): New function. * libgui/src/qtinfo/webinfo.cc, libgui/src/qtinfo/webinfo.h (webinfo::load_ref): New function.
author John Donoghue <john.donoghue@ieee.org>
date Sat, 20 Jul 2013 22:13:51 -0400
parents 944ade6e7f66
children 05b8ad3b7d12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16768
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
1 /*
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
2
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
3 Copyright (C) 2009 P. L. Lucas
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
4 Copyright (C) 2012 Jacob Dawid
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
5
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
6 This file is part of Octave.
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
7
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
9 under the terms of the GNU General Public License as published by the
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
11 option) any later version.
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
12
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
16 for more details.
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
17
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
18 You should have received a copy of the GNU General Public License
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
19 along with Octave; see the file COPYING. If not, see
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
20 <http://www.gnu.org/licenses/>.
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
21
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
22 */
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
23
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
24 // Author: P. L. Lucas
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16529
diff changeset
25 // Author: Jacob Dawid <jacob.dawid@gmail.com>
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
26
15265
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
27 #ifdef HAVE_CONFIG_H
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
28 #include <config.h>
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
29 #endif
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
30
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
31 #include "webinfo.h"
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
32 #include <QVBoxLayout>
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
33 #include <QHBoxLayout>
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
34 #include <QApplication>
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
35 #include <QClipboard>
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
36
15265
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
37 #include "file-ops.h"
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
38 #include "help.h"
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
39 #include "defaults.h"
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
40
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
41
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
42 webinfo::webinfo (QWidget *p)
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
43 : QWidget (p)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
44 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
45 _font_web = font ();
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
46
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
47 QVBoxLayout *vbox_layout = new QVBoxLayout ();
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
48 vbox_layout->setMargin (0);
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
49 setLayout (vbox_layout);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
50
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
51 QHBoxLayout *hbox_layout = new QHBoxLayout ();
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
52 hbox_layout->setMargin (2);
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
53 vbox_layout->addLayout (hbox_layout);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
54
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
55 _tab_bar = new QTabBar (this);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
56 _tab_bar->setSizePolicy (QSizePolicy::Preferred,QSizePolicy::Preferred);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
57 _tab_bar->setExpanding (false);
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
58 _tab_bar->setTabsClosable (true);
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
59 _tab_bar->setMovable (true);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
60 hbox_layout->addWidget (_tab_bar);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
61
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
62 _zoom_in_button = new QToolButton (this);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
63 _zoom_in_button->setSizePolicy (QSizePolicy::Fixed,QSizePolicy::Preferred);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
64 _zoom_in_button->setIcon (QIcon (":/actions/icons/zoom-in.png"));
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
65 hbox_layout->addWidget (_zoom_in_button);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
66
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
67 _zoom_out_button = new QToolButton (this);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
68 _zoom_out_button->setSizePolicy (QSizePolicy::Fixed,QSizePolicy::Preferred);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
69 _zoom_out_button->setIcon (QIcon (":/actions/icons/zoom-out.png"));
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
70 hbox_layout->addWidget (_zoom_out_button);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
71
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
72 _stacked_widget = new QStackedWidget (this);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
73 vbox_layout->addWidget (_stacked_widget);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
74
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
75 hbox_layout = new QHBoxLayout ();
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
76 vbox_layout->addLayout (hbox_layout);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
77
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
78 _search_line_edit = new QLineEdit(this);
15291
7ae14907ae43 build: Add tests for specific Qt functions to configure.ac
Rik <rik@octave.org>
parents: 15287
diff changeset
79 #ifdef HAVE_SETPLACEHOLDERTEXT
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
80 _search_line_edit->setPlaceholderText (tr ("Type here and press \'Return\' to search"));
15287
8639a450a89e build: Test for QT setPlaceholderText function before using it.
Rik <rik@octave.org>
parents: 15265
diff changeset
81 #endif
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
82 hbox_layout->addWidget (_search_line_edit);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
83
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
84 _search_check_box = new QCheckBox (tr ("Global search"));
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
85 hbox_layout->addWidget (_search_check_box);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
86
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
87 connect (_tab_bar, SIGNAL (tabCloseRequested (int)), this, SLOT (close_tab (int)));
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
88 connect (_tab_bar, SIGNAL (currentChanged (int)), this, SLOT (current_tab_changed (int)));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
89 connect (_zoom_in_button, SIGNAL (clicked ()), this, SLOT (zoom_in ()));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
90 connect (_zoom_out_button, SIGNAL (clicked ()), this, SLOT (zoom_out ()));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
91 connect (_search_line_edit, SIGNAL (returnPressed ()), this, SLOT (search ()));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
92
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
93 resize (500, 300);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
94
15265
f463154f1c1b provide correct name of info file for the doc viewer (bug #37229)
Torsten <ttl@justmail.de>
parents: 15196
diff changeset
95 set_info_path (QString::fromStdString (Vinfo_file));
17029
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
96
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
97 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
98
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
99 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15291
diff changeset
100 webinfo::set_info_path (const QString& info_path)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
101 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
102 _parser.set_info_path (info_path);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
103 load_node ("Top");
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
104 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
105
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
106 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15291
diff changeset
107 webinfo::load_node (const QString& node_name)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
108 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
109 //Check if node has been already opened.
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
110 for (int i = 0;i < _tab_bar->count (); i++)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
111 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
112 if (node_name == _tab_bar->tabText (i))
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
113 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
114 _tab_bar->setCurrentIndex (i);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
115 return;
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
116 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
117 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
118
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
119 QString text = _parser.search_node (node_name);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
120 int i = _parser.is_ref (node_name);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
121 _text_browser = addNewTab (node_name);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
122 _text_browser->setHtml (_parser.node_text_to_html (text, i - 1, "anchor"));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
123
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
124 if (i != -1)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
125 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
126 _text_browser->scrollToAnchor ("anchor");
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
127 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
128 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
129
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
130 void
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
131 webinfo::link_clicked (const QUrl & link)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
132 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
133 QString node = link.toString ();
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
134 load_node (node);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
135 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
136
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
137 void
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
138 webinfo::current_tab_changed (int index)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
139 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
140 QVariant tab_data = _tab_bar->tabData (index);
15494
05aee5a1ff37 silence some compilation warnings
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15368
diff changeset
141 _text_browser = static_cast<QTextBrowser*> (tab_data.value<void*> ());
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
142
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
143 _stacked_widget->setCurrentIndex (_stacked_widget->indexOf (_text_browser));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
144
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
145 if (_text_browser->font () != _font_web)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
146 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
147 _text_browser->setFont (_font_web);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
148 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
149 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
150
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
151 QTextBrowser *
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15291
diff changeset
152 webinfo::addNewTab (const QString& name)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
153 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
154 _text_browser = new QTextBrowser (this);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
155 _text_browser->setOpenLinks (false);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
156 _text_browser->show ();
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
157
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
158 connect (_text_browser, SIGNAL (anchorClicked (const QUrl &)), this, SLOT (link_clicked (const QUrl &)) );
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
159 disconnect(_tab_bar, SIGNAL (currentChanged(int)), this, SLOT (current_tab_changed (int)));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
160
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
161 int ns = _stacked_widget->addWidget (_text_browser);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
162 _stacked_widget->setCurrentIndex (ns);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
163
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
164 int nt = _tab_bar->addTab (name);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
165 _tab_bar->setCurrentIndex (nt);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
166 QVariant tab_data;
15494
05aee5a1ff37 silence some compilation warnings
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15368
diff changeset
167 tab_data.setValue (static_cast<void*> (_text_browser));
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
168 _tab_bar->setTabData (nt, tab_data);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
169
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
170 connect (_tab_bar, SIGNAL (currentChanged (int)), this, SLOT (current_tab_changed (int)));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
171
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
172 if (_text_browser->font () != _font_web)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
173 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
174 _text_browser->setFont (_font_web);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
175 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
176 return _text_browser;
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
177 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
178
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
179 void
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
180 webinfo::close_tab (int index)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
181 {
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
182 if (_tab_bar->count () > 1)
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
183 {
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
184 QVariant tab_data = _tab_bar->tabData (index);
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
185 QWidget *w = static_cast<QWidget*> (tab_data.value<void*> ());
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
186 _stacked_widget->removeWidget (w);
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
187 delete w;
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
188
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
189 _tab_bar->removeTab (index);
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
190 }
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
191 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
192
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
193 void
17029
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
194 webinfo::load_ref (const QString &ref_name)
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
195 {
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
196 QString text = _parser.find_ref (ref_name);
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
197 if (text.length () > 0)
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
198 {
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
199 load_node (text);
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
200 }
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
201 else
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
202 {
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
203 // not found
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
204 load_node("Top");
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
205 }
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
206 }
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
207
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
208 void
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
209 webinfo::search ()
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
210 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
211 if (_search_check_box->isChecked ())
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
212 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
213 // Global search
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
214 QString results = _parser.global_search (_search_line_edit->text (), 5);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
215 _text_browser=addNewTab ("Results for: " + _search_line_edit->text ());
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
216 _text_browser->setHtml (results);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
217 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
218 else
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
219 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
220 // Local search
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
221 _text_browser->find (_search_line_edit->text ());
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
222 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
223 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
224
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
225 void
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
226 webinfo::zoom_in ()
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
227 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
228 _font_web.setPointSize (_font_web.pointSize() + 1);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
229 _text_browser->setFont (_font_web);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
230 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
231
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
232 void
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
233 webinfo::zoom_out ()
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
234 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
235 _font_web.setPointSize (_font_web.pointSize() - 1);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
236 _text_browser->setFont (_font_web);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
237 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
238
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
239 void
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
240 webinfo::copyClipboard ()
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
241 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
242 if (_search_line_edit->hasFocus () && _search_line_edit->hasSelectedText ())
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
243 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
244 QClipboard *clipboard = QApplication::clipboard ();
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
245
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
246 clipboard->setText (_search_line_edit->selectedText ());
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
247 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
248 if (_text_browser->hasFocus ())
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
249 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
250 _text_browser->copy ();
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
251 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
252 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
253
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
254 void
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
255 webinfo::pasteClipboard ()
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
256 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
257 if (_search_line_edit->hasFocus ())
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
258 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
259 QClipboard *clipboard = QApplication::clipboard ();
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
260 QString str = clipboard->text ();
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
261 if (str.length () > 0)
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
262 _search_line_edit->insert (str);
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
263 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
264 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
265