annotate libgui/src/documentation-bookmarks.h @ 31649:deb553ac2c54

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Dec 2022 15:45:27 -0500
parents 431f80aba37a 29d734430e5f
children 5f11de0e7440
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
1 ////////////////////////////////////////////////////////////////////////
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30398
diff changeset
3 // Copyright (C) 2018-2022 The Octave Project Developers
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
4 //
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
6 // distribution or <https://octave.org/copyright/>.
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
7 //
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
8 // This file is part of Octave.
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
9 //
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
11 // under the terms of the GNU General Public License as published by
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
13 // (at your option) any later version.
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
14 //
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
16 // WiTHOUT ANY WARRANTY; without even the implied warranty of
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
18 // GNU General Public License for more details.
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
19 //
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
20 // You should have received a copy of the GNU General Public License
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
21 // along with Octave; see the file COPYING. If not, see
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
22 // <https://www.gnu.org/licenses/>.
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
23 //
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
24 ////////////////////////////////////////////////////////////////////////
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
25
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
26 #if ! defined (octave_documentation_bookmarks_h)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
27 #define octave_documentation_bookmarks_h 1
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
28
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
29 #include <QCheckBox>
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
30 #include <QComboBox>
31639
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
31 #include <QFile>
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
32 #include <QTreeWidget>
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
33 #include <QXmlStreamWriter>
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
34
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
35 #include "documentation.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
36
31646
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
37 OCTAVE_BEGIN_NAMESPACE(octave)
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
38
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
39 class documentation;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
40
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
41 class documentation_bookmarks : public QWidget
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
42 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
43 Q_OBJECT
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
44
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
45 public:
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
46
31639
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
47 documentation_bookmarks (documentation *doc,
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
48 documentation_browser *browser,
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
49 QWidget *p = nullptr);
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
50
29550
8dd0fca2a3d9 where possible, use default destructors in GUI classes
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
51 ~documentation_bookmarks (void) = default;
8dd0fca2a3d9 where possible, use default destructors in GUI classes
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
52
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
53 public slots:
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
54
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
55 void add_bookmark (void);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
56 void add_folder (bool);
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
57 void save_settings (void);
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
58
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
59 private slots:
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
60
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
61 void filter_bookmarks (const QString& pattern);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
62 void filter_activate (bool state);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
63 void update_filter_history (void);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
64 void handle_double_click (QTreeWidgetItem *item, int col = 0);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
65 void ctx_menu (const QPoint& xpos);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
66 void open (bool);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
67 void edit (bool);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
68 void remove (bool);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
69 void show_filter (bool);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
70
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
71 private:
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
72
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
73 enum item_role
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
74 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
75 url_role = Qt::UserRole,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
76 tag_role = Qt::UserRole + 1
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
77 };
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
78 enum item_tag
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
79 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
80 bookmark_tag,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
81 folder_tag
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
82 };
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
83
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
84 void add_bookmark (const QString& title, const QString& url,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
85 QTreeWidgetItem *item = nullptr);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
86 QTreeWidgetItem* add_folder (const QString& folder,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
87 QTreeWidgetItem *item = nullptr,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
88 bool expanded = true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
89
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
90 /*!
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
91 Writing to and reading bookmarks from an xbel-file as
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
92 proposed in the qt example
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
93 [QXmlStream Bookmarks Example](https://doc.qt.io/qt-5/qtxml-streambookmarks-example.html)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
94 */
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
95 void write_bookmarks (void);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
96 void write_tree_item (QXmlStreamWriter *xml_writer,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
97 const QTreeWidgetItem *item);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
98 QString read_bookmarks (void);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
99 void read_next_item (QXmlStreamReader *xml_writer, item_tag tag,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
100 QTreeWidgetItem *item = nullptr);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
101
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
102 documentation *m_doc;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
103 documentation_browser *m_browser;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
104
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
105 QComboBox *m_filter;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
106 QTreeWidget *m_tree;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
107
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
108 QTreeWidgetItem *m_ctx_menu_item;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
109
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
110 QIcon icon_folder;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
111 QIcon icon_bookmark;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
112
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
113 QWidget *m_filter_widget;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
114 QCheckBox *m_filter_checkbox;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
115 bool m_filter_shown;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
116
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
117 QFile m_xbel_file;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
118 };
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
119
31646
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
120 OCTAVE_END_NAMESPACE(octave)
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
121
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
122 #endif