annotate libgui/src/qtinfo/webinfo.cc @ 19495:17e6c770e6ac gui-release

check existence of uncompressed or compressed info files for doc viewer * parser.cc (set_info_path): return type changed to bool, checking existence of info file uncompressed and with all known compressed file extensions, returns false if no file was found and true after parsing the found file; * parser.h: return type of set_info_path changed to bool * webinfo.cc (ctor): do not check existence of info file since this is done via set_info_path; (set_info_path): return type changed to bool, load Top-node if parser::set_info_path returns true and return the related return value * webinfo.h: return type of set_info_path changed to bool
author Torsten <ttl@justmail.de>
date Fri, 02 Jan 2015 18:47:29 +0100
parents 834f6e604dc3
children ffc339cea115
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
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17739
diff changeset
4 Copyright (C) 2012-2013 Jacob Dawid
16768
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 ();
17750
94c7b2252490 add more recognizable icons for the font size in the doc browser
Torsten <ttl@justmail.de>
parents: 17744
diff changeset
52 hbox_layout->setMargin (0);
94c7b2252490 add more recognizable icons for the font size in the doc browser
Torsten <ttl@justmail.de>
parents: 17744
diff changeset
53 hbox_layout->setSpacing (0);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
54 vbox_layout->addLayout (hbox_layout);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
55
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
56 _tab_bar = new QTabBar (this);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
57 _tab_bar->setSizePolicy (QSizePolicy::Preferred,QSizePolicy::Preferred);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
58 _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
59 _tab_bar->setTabsClosable (true);
18234
0eeab61e07d8 smaller height of tabs in the document viewer
Torsten <ttl@justmail.de>
parents: 18184
diff changeset
60 #ifdef HAVE_QTABWIDGET_SETMOVABLE
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
61 _tab_bar->setMovable (true);
18234
0eeab61e07d8 smaller height of tabs in the document viewer
Torsten <ttl@justmail.de>
parents: 18184
diff changeset
62 #endif
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
63 hbox_layout->addWidget (_tab_bar);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
64
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
65 _zoom_in_button = new QToolButton (this);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
66 _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
67 hbox_layout->addWidget (_zoom_in_button);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
68
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
69 _zoom_out_button = new QToolButton (this);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
70 _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
71 hbox_layout->addWidget (_zoom_out_button);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
72
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
73 _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
74 vbox_layout->addWidget (_stacked_widget);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
75
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
76 hbox_layout = new QHBoxLayout ();
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
77 vbox_layout->addLayout (hbox_layout);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
78
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
79 _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
80 #ifdef HAVE_SETPLACEHOLDERTEXT
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
81 _search_line_edit->setPlaceholderText (
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
82 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
83 #endif
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
84 hbox_layout->addWidget (_search_line_edit);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
85
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
86 _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
87 hbox_layout->addWidget (_search_check_box);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
88
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
89 connect (_tab_bar, SIGNAL (tabCloseRequested (int)), this,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
90 SLOT (close_tab (int)));
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
91 connect (_tab_bar, SIGNAL (currentChanged (int)), this,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
92 SLOT (current_tab_changed (int)));
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
93 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
94 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
95 connect (_search_line_edit, SIGNAL (returnPressed ()), this, SLOT (search ()));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
96
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
97 resize (500, 300);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
98
19495
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
99 if (! set_info_path (QString::fromStdString (Vinfo_file)))
18184
d03a6d272fee display error message in document browser when info file is missing
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
100 { // Info file does not exist
d03a6d272fee display error message in document browser when info file is missing
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
101 _search_check_box->setEnabled (false);
d03a6d272fee display error message in document browser when info file is missing
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
102 _search_line_edit->setEnabled (false);
d03a6d272fee display error message in document browser when info file is missing
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
103
d03a6d272fee display error message in document browser when info file is missing
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
104 QTextBrowser *msg = addNewTab (tr ("Error"));
19495
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
105 QString msg_text = QString (
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
106 "<html><body><br><br><center><b>%1</b></center></body></html>").
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
107 arg (tr ("The info file<p>%1<p>or compressed versions do not exist").
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
108 arg(QString::fromStdString (Vinfo_file)));
18184
d03a6d272fee display error message in document browser when info file is missing
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
109 msg->setHtml (msg_text);
d03a6d272fee display error message in document browser when info file is missing
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
110 }
15055
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
19495
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
113 bool
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15291
diff changeset
114 webinfo::set_info_path (const QString& info_path)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
115 {
19495
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
116 if (_parser.set_info_path (info_path))
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
117 {
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
118 load_node ("Top");
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
119 return true;
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
120 }
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
121 else
17e6c770e6ac check existence of uncompressed or compressed info files for doc viewer
Torsten <ttl@justmail.de>
parents: 18724
diff changeset
122 return false;
15055
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
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
125 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15291
diff changeset
126 webinfo::load_node (const QString& node_name)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
127 {
17739
0640892429a8 remove XREF from tab names in the documentation browser
Torsten <ttl@justmail.de>
parents: 17030
diff changeset
128 // no XREF in the tabs
0640892429a8 remove XREF from tab names in the documentation browser
Torsten <ttl@justmail.de>
parents: 17030
diff changeset
129 QString tab_text = node_name;
0640892429a8 remove XREF from tab names in the documentation browser
Torsten <ttl@justmail.de>
parents: 17030
diff changeset
130 tab_text.replace("XREF","");
0640892429a8 remove XREF from tab names in the documentation browser
Torsten <ttl@justmail.de>
parents: 17030
diff changeset
131
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
132 //Check if node has been already opened.
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
133 for (int i = 0; i < _tab_bar->count (); i++)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
134 {
17739
0640892429a8 remove XREF from tab names in the documentation browser
Torsten <ttl@justmail.de>
parents: 17030
diff changeset
135 if (tab_text == _tab_bar->tabText (i))
15055
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 _tab_bar->setCurrentIndex (i);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
138 return;
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
139 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
140 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
141
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
142 QString text = _parser.search_node (node_name);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
143 int i = _parser.is_ref (node_name);
17739
0640892429a8 remove XREF from tab names in the documentation browser
Torsten <ttl@justmail.de>
parents: 17030
diff changeset
144 _text_browser = addNewTab (tab_text);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
145 _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
146
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
147 if (i != -1)
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 _text_browser->scrollToAnchor ("anchor");
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 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
152
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
153 void
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
154 webinfo::link_clicked (const QUrl & link)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
155 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
156 QString node = link.toString ();
17768
271c0cce0f64 remove XREF from the links in the docuemntation
Torsten <ttl@justmail.de>
parents: 17750
diff changeset
157 if (node.at (0) != '#')
271c0cce0f64 remove XREF from the links in the docuemntation
Torsten <ttl@justmail.de>
parents: 17750
diff changeset
158 load_node (node);
271c0cce0f64 remove XREF from the links in the docuemntation
Torsten <ttl@justmail.de>
parents: 17750
diff changeset
159 else
271c0cce0f64 remove XREF from the links in the docuemntation
Torsten <ttl@justmail.de>
parents: 17750
diff changeset
160 _text_browser->scrollToAnchor (node);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
161 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
162
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
163 void
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
164 webinfo::current_tab_changed (int index)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
165 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
166 QVariant tab_data = _tab_bar->tabData (index);
15494
05aee5a1ff37 silence some compilation warnings
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15368
diff changeset
167 _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
168
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
169 _stacked_widget->setCurrentIndex (_stacked_widget->indexOf (_text_browser));
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
170
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
171 if (_text_browser->font () != _font_web)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
172 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
173 _text_browser->setFont (_font_web);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
174 }
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
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
177 QTextBrowser *
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15291
diff changeset
178 webinfo::addNewTab (const QString& name)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
179 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
180 _text_browser = new QTextBrowser (this);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
181 _text_browser->setOpenLinks (false);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
182 _text_browser->show ();
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
183
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
184 connect (_text_browser, SIGNAL (anchorClicked (const QUrl &)), this,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
185 SLOT (link_clicked (const QUrl &)) );
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
186 disconnect(_tab_bar, SIGNAL (currentChanged(int)), this,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
187 SLOT (current_tab_changed (int)));
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
188
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
189 int ns = _stacked_widget->addWidget (_text_browser);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
190 _stacked_widget->setCurrentIndex (ns);
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 int nt = _tab_bar->addTab (name);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
193 _tab_bar->setCurrentIndex (nt);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15300
diff changeset
194 QVariant tab_data;
15494
05aee5a1ff37 silence some compilation warnings
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15368
diff changeset
195 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
196 _tab_bar->setTabData (nt, tab_data);
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
197
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
198 connect (_tab_bar, SIGNAL (currentChanged (int)), this,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
199 SLOT (current_tab_changed (int)));
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
200
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
201 if (_text_browser->font () != _font_web)
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
202 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
203 _text_browser->setFont (_font_web);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
204 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
205 return _text_browser;
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
206 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
207
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
208 void
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
209 webinfo::close_tab (int index)
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
210 {
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
211 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
212 {
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
213 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
214 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
215 _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
216 delete w;
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
217
16529
faccc20d5f39 allow doc browser tabs to be moved and individually closed
John W. Eaton <jwe@octave.org>
parents: 15494
diff changeset
218 _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
219 }
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
220 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
221
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
222 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
223 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
224 {
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
225 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
226 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
227 {
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
228 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
229 }
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
230 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
231 {
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
232 // not found
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
233 load_node("Top");
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
234 }
17030
05b8ad3b7d12 Display/focus documentation browser when running command doc 'xxxxx'
John Donoghue <john.donoghue@ieee.org>
parents: 17029
diff changeset
235
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
236 if (_text_browser)
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
237 _text_browser->setFocus();
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
238 }
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
239
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 16881
diff changeset
240 void
15055
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
241 webinfo::search ()
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
242 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
243 if (_search_check_box->isChecked ())
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
244 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
245 // Global search
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
246 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
247 _text_browser=addNewTab ("Results for: " + _search_line_edit->text ());
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
248 _text_browser->setHtml (results);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
249 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
250 else
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
251 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
252 // Local search
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
253 _text_browser->find (_search_line_edit->text ());
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
254 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
255 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
256
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
257 void
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
258 webinfo::zoom_in ()
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
259 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
260 _font_web.setPointSize (_font_web.pointSize() + 1);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
261 _text_browser->setFont (_font_web);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
262 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
263
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
264 void
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
265 webinfo::zoom_out ()
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
266 {
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
267 _font_web.setPointSize (_font_web.pointSize() - 1);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
268 _text_browser->setFont (_font_web);
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
269 }
48ae6a7c69c1 Integrated texinfo browser from QtOctave.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
diff changeset
270
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
271 void
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
272 webinfo::copyClipboard ()
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
273 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
274 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
275 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
276 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
277
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
278 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
279 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
280 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
281 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
282 _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
283 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
284 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
285
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
286 void
18568
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
287 webinfo::selectAll ()
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
288 {
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
289 if (_search_line_edit->hasFocus ())
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
290 {
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
291 _search_line_edit->selectAll ();
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
292 }
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
293 if (_text_browser->hasFocus ())
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
294 {
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
295 _text_browser->selectAll ();
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
296 }
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
297 }
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
298
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
299
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18234
diff changeset
300 void
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
301 webinfo::pasteClipboard ()
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
302 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
303 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
304 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
305 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
306 QString str = clipboard->text ();
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17768
diff changeset
307 if (str.length () > 0)
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
308 _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
309 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
310 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16768
diff changeset
311