Mercurial > octave
annotate libgui/src/documentation-bookmarks.cc @ 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 | 2422fb7f1e6c |
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:
30525
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 (HAVE_CONFIG_H) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
27 # include "config.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
28 #endif |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
29 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
30 #include <QCompleter> |
31639
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
31621
diff
changeset
|
31 #include <QDir> |
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
31621
diff
changeset
|
32 #include <QFileInfo> |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
33 #include <QMenu> |
31639
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
31621
diff
changeset
|
34 #include <QMessageBox> |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
35 #include <QShortcut> |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
36 #include <QVBoxLayout> |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
37 #include <QWidget> |
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 #include "documentation.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
40 #include "documentation-bookmarks.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
41 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
42 #include "gui-preferences-global.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
43 #include "gui-preferences-dc.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
44 #include "gui-preferences-sc.h" |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
45 #include "gui-settings.h" |
29560
5b7e721844df
provide QOverload template if it is not in <QtGlobal> (bug #60416)
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
46 #include "octave-qtutils.h" |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
47 #include "shortcut-manager.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
48 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
49 #include "defaults.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
50 #include "file-ops.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
51 #include "oct-env.h" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
52 |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
53 OCTAVE_BEGIN_NAMESPACE(octave) |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
54 |
31639
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
31621
diff
changeset
|
55 documentation_bookmarks::documentation_bookmarks (documentation *doc, |
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
31621
diff
changeset
|
56 documentation_browser *browser, |
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
31621
diff
changeset
|
57 QWidget *p) |
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
31621
diff
changeset
|
58 : QWidget (p), m_doc (doc), m_browser (browser), m_ctx_menu_item (nullptr) |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
59 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
60 setObjectName ("documentation_tab_bookmarks"); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
61 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
62 gui_settings settings; |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
63 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
64 // Setup the tree view with the bookmarks |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
65 m_tree = new QTreeWidget (p); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
66 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
67 m_tree->setContextMenuPolicy (Qt::CustomContextMenu); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
68 m_tree->setSelectionMode (QAbstractItemView::ExtendedSelection); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
69 m_tree->setSortingEnabled (false); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
70 m_tree->setDragEnabled(true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
71 m_tree->viewport()->setAcceptDrops(true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
72 m_tree->setDropIndicatorShown(true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
73 m_tree->setDragDropMode(QAbstractItemView::InternalMove); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
74 m_tree->setColumnCount (1); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
75 m_tree->setHeaderHidden (true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
76 m_tree->setEditTriggers (QAbstractItemView::EditKeyPressed |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
77 | QAbstractItemView::SelectedClicked); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
78 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
79 connect (m_tree, &QTreeWidget::customContextMenuRequested, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
80 this, &documentation_bookmarks::ctx_menu); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
81 connect (m_tree, &QTreeWidget::itemDoubleClicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
82 this, &documentation_bookmarks::handle_double_click); |
29330
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 // Define the icons for the tree view |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
85 icon_folder.addPixmap (style ()->standardPixmap(QStyle::SP_DirClosedIcon), |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
86 QIcon::Normal, QIcon::Off); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
87 icon_folder.addPixmap (style ()->standardPixmap(QStyle::SP_DirOpenIcon), |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
88 QIcon::Normal, QIcon::On); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
89 icon_bookmark.addPixmap (style ()->standardPixmap(QStyle::SP_FileIcon)); |
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 // Setup and read the bookmarkfile |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
92 QFileInfo f (settings.fileName ()); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
93 QString f_path = f.absolutePath (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
94 f.setFile (QDir (f_path), dc_bookmark_file); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
95 m_xbel_file.setFileName (f.absoluteFilePath ()); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
96 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
97 if (m_xbel_file.exists ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
98 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
99 QString err = read_bookmarks (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
100 if ( !err.isEmpty ()) |
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 err.append (tr ("\nNo documentation bookmarks loaded!")); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
103 QMessageBox::warning (this, |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
104 tr ("Octave: Loading Documentation Bookmarks"), |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
105 err); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
106 m_xbel_file.close (); |
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 } |
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 // Setup the filter widget |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
111 m_filter_widget = new QWidget (p); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
112 m_filter = new QComboBox (m_filter_widget); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
113 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
114 m_filter->setToolTip (tr ("Enter text to search the bookmarks")); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
115 m_filter->setEditable (true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
116 m_filter->setInsertPolicy (QComboBox::NoInsert); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
117 m_filter->setMaxCount (10); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
118 m_filter->setMaxVisibleItems (10); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
119 m_filter->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
120 QSizePolicy size_pol (QSizePolicy::Expanding, QSizePolicy::Preferred); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
121 m_filter->setSizePolicy (size_pol); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
122 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
123 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
124 m_filter->addItems (settings.value (dc_bookmark_filter_mru).toStringList ()); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
125 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
126 connect (m_filter, &QComboBox::editTextChanged, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
127 this, &documentation_bookmarks::filter_bookmarks); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
128 connect (m_filter->lineEdit (), &QLineEdit::editingFinished, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
129 this, &documentation_bookmarks::update_filter_history); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
130 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
131 m_filter_checkbox = new QCheckBox (m_filter_widget); |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
132 bool filter_state = settings.value (dc_bookmark_filter_active).toBool (); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
133 m_filter_checkbox->setChecked (filter_state); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
134 filter_activate (filter_state); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
135 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
136 connect (m_filter_checkbox, &QCheckBox::toggled, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
137 this, &documentation_bookmarks::filter_activate); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
138 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
139 QLabel *filter_label = new QLabel (tr ("Filter"), m_filter_widget); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
140 QHBoxLayout *h_box_bm = new QHBoxLayout (m_filter_widget); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
141 h_box_bm->addWidget (filter_label); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
142 h_box_bm->addWidget (m_filter_checkbox); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
143 h_box_bm->addWidget (m_filter); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
144 h_box_bm->setMargin (2); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
145 m_filter_widget->setLayout (h_box_bm); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
146 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
147 m_filter_shown = settings.value (dc_bookmark_filter_shown).toBool (); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
148 m_filter_widget->setVisible (m_filter_shown); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
149 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
150 // Resulting Layout of this widget |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
151 QVBoxLayout *v_box_bm = new QVBoxLayout (this); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
152 v_box_bm->addWidget (m_filter_widget); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
153 v_box_bm->addWidget (m_tree); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
154 setLayout (v_box_bm); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
155 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
156 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
157 // Slot for adding the current page as a bookmark |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
158 void documentation_bookmarks::add_bookmark (void) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
159 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
160 QUrl url = m_browser->historyUrl (0); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
161 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
162 // Check if bookmark already exists and select if yes |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
163 QTreeWidgetItemIterator it (m_tree); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
164 while (*it) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
165 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
166 QUrl url_i = (*it)->data (0, url_role).toUrl (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
167 if (url == url_i) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
168 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
169 m_tree->setCurrentItem (*it); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
170 (*it)->setExpanded (true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
171 return; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
172 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
173 it++; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
174 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
175 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
176 // Add the anchor name to the title of the page and add the bookmark |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
177 // as top-level-item |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
178 QString title = m_doc->title_and_anchor (m_browser->historyTitle (0), url); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
179 add_bookmark (title, url.toString ()); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
180 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
181 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
182 // Function for actually adding a bookmark to the tree |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
183 void documentation_bookmarks::add_bookmark (const QString& title, |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
184 const QString& url, |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
185 QTreeWidgetItem* item) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
186 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
187 // Create new bookmark |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
188 QTreeWidgetItem *new_item = new QTreeWidgetItem (QStringList (title)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
189 new_item->setData (0, tag_role, QVariant (bookmark_tag)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
190 new_item->setData (0, url_role, QVariant (url)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
191 new_item->setFlags ((new_item->flags () & (~Qt::ItemIsDropEnabled)) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
192 | Qt::ItemIsEditable |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
193 | Qt::ItemIsDragEnabled); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
194 new_item->setIcon (0, icon_bookmark); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
195 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
196 // Insert as top level or child item |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
197 // TODO: Open dialog allowing to select a target folder if this |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
198 // bookmark is added manually and not by reading a bookmark file |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
199 if (item) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
200 item->addChild (new_item); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
201 else |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
202 m_tree->addTopLevelItem (new_item); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
203 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
204 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
205 // Slot for adding a folder from the context menu |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
206 void documentation_bookmarks::add_folder (bool) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
207 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
208 QTreeWidgetItem *parent_item = nullptr; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
209 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
210 if (m_ctx_menu_item) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
211 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
212 if (m_ctx_menu_item->data (0, tag_role).toInt () == folder_tag) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
213 parent_item = m_ctx_menu_item; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
214 else |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
215 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
216 QTreeWidgetItem *p = m_ctx_menu_item->parent (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
217 if (p) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
218 parent_item = p; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
219 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
220 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
221 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
222 QTreeWidgetItem *new_folder = add_folder (tr ("New Folder"), parent_item); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
223 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
224 m_tree->setCurrentItem (new_folder); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
225 m_tree->editItem (new_folder); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
226 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
227 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
228 // Function for actually adding a folder to the tree |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
229 QTreeWidgetItem* documentation_bookmarks::add_folder (const QString& folder, |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
230 QTreeWidgetItem *item, bool expanded) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
231 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
232 QTreeWidgetItem *new_folder = new QTreeWidgetItem (QStringList (folder)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
233 new_folder->setData (0, tag_role, QVariant (folder_tag)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
234 new_folder->setFlags (new_folder->flags() | Qt::ItemIsEditable |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
235 | Qt::ItemIsDragEnabled |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
236 | Qt::ItemIsDropEnabled); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
237 new_folder->setChildIndicatorPolicy (QTreeWidgetItem::DontShowIndicatorWhenChildless); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
238 new_folder->setIcon (0, icon_folder); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
239 new_folder->setExpanded (expanded); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
240 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
241 // Insert as top level or child item |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
242 if (item) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
243 item->addChild (new_folder); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
244 else |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
245 m_tree->addTopLevelItem (new_folder); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
246 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
247 return new_folder; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
248 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
249 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
250 void documentation_bookmarks::filter_bookmarks (const QString& pattern) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
251 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
252 QTreeWidgetItemIterator it (m_tree); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
253 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
254 while (*it) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
255 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
256 if ((*it)->text (0).contains (pattern, Qt::CaseInsensitive)) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
257 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
258 (*it)->setHidden (false); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
259 (*it)->setExpanded (true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
260 QTreeWidgetItem *p = (*it)->parent (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
261 while (p) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
262 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
263 p->setHidden (false); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
264 p->setExpanded (true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
265 p = p->parent (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
266 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
267 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
268 else |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
269 (*it)->setHidden (true); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
270 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
271 it++; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
272 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
273 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
274 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
275 void documentation_bookmarks::filter_activate (bool state) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
276 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
277 m_filter->setEnabled (state); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
278 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
279 QString pattern; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
280 if (state) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
281 pattern = m_filter->currentText (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
282 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
283 filter_bookmarks (pattern); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
284 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
285 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
286 void documentation_bookmarks::update_filter_history (void) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
287 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
288 QString text = m_filter->currentText (); // get current text |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
289 int index = m_filter->findText (text); // and its actual index |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
290 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
291 if (index > -1) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
292 m_filter->removeItem (index); // remove if already existing |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
293 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
294 m_filter->insertItem (0, text); // (re)insert at beginning |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
295 m_filter->setCurrentIndex (0); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
296 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
297 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
298 void documentation_bookmarks::handle_double_click (QTreeWidgetItem *item, int) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
299 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
300 int tag = item->data (0, tag_role).toInt (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
301 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
302 if (tag == folder_tag) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
303 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
304 item->setExpanded (! item->isExpanded ()); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
305 return; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
306 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
307 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
308 if (tag == bookmark_tag) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
309 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
310 QUrl url = item->data (0, url_role).toUrl (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
311 if (! url.isEmpty ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
312 m_browser->setSource (url); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
313 return; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
314 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
315 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
316 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
317 void documentation_bookmarks::ctx_menu (const QPoint& xpos) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
318 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
319 QMenu menu (this); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
320 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
321 m_ctx_menu_item = m_tree->itemAt (xpos); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
322 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
323 if (m_ctx_menu_item) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
324 { |
31621
0645ea65ca6b
handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
325 gui_settings settings; |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
326 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
327 menu.addAction (tr ("&Open"), this, &documentation_bookmarks::open); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
328 menu.addAction (tr ("&Rename"), this, &documentation_bookmarks::edit); |
31621
0645ea65ca6b
handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
329 menu.addAction (settings.icon ("window-close"), tr ("Remo&ve"), |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
330 this, &documentation_bookmarks::remove); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
331 menu.addSeparator (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
332 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
333 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
334 menu.addAction (tr ("&Add Folder"), this, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
335 QOverload<bool>::of (&documentation_bookmarks::add_folder)); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
336 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
337 menu.addSeparator (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
338 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
339 if (m_filter_shown) |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
340 menu.addAction (tr ("Hide &Filter"), |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
341 this, &documentation_bookmarks::show_filter); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
342 else |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
343 menu.addAction (tr ("Show &Filter"), |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
344 this, &documentation_bookmarks::show_filter); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
345 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
346 menu.exec (m_tree->mapToGlobal (xpos)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
347 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
348 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
349 void documentation_bookmarks::open (bool) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
350 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
351 QList<QTreeWidgetItem *> items = m_tree->selectedItems (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
352 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
353 if (items.size () > 0) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
354 handle_double_click (items.at (0)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
355 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
356 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
357 void documentation_bookmarks::edit (bool) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
358 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
359 QList<QTreeWidgetItem *> items = m_tree->selectedItems (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
360 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
361 if (items.size () > 0) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
362 m_tree->editItem (items.at (0)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
363 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
364 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
365 void documentation_bookmarks::remove (bool) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
366 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
367 QList<QTreeWidgetItem *> items = m_tree->selectedItems (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
368 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
369 for (auto it = items.begin () ; it != items.end (); it++) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
370 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
371 if (*it) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
372 m_tree->takeTopLevelItem ( |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
373 m_tree->indexOfTopLevelItem (*it)); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
374 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
375 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
376 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
377 void documentation_bookmarks::show_filter (bool) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
378 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
379 m_filter_shown = ! m_filter_shown; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
380 m_filter_widget->setVisible (m_filter_shown); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
381 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
382 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
383 void documentation_bookmarks::save_settings (void) |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
384 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
385 // Write the bookmarks to the xbel-file |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
386 write_bookmarks (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
387 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
388 // Store settings |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
389 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
390 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
391 settings.setValue (dc_bookmark_filter_active.key, m_filter_checkbox->isChecked ()); |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
392 settings.setValue (dc_bookmark_filter_shown.key, m_filter_shown); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
393 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
394 QStringList mru; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
395 for (int i = 0; i < m_filter->count (); i++) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
396 mru.append (m_filter->itemText (i)); |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
397 settings.setValue (dc_bookmark_filter_mru.key, mru); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
398 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
399 settings.sync (); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
400 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
401 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
402 void documentation_bookmarks::write_bookmarks (void) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
403 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
404 if (! m_xbel_file.open (QFile::WriteOnly | QFile::Text)) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
405 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
406 QMessageBox::warning (this, tr("Octave: Saving Documentation Bookmarks"), |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
407 tr("Unable to write file %1:\n%2.\n\n" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
408 "Documentation bookmarks are not saved!\n") |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
409 .arg (m_xbel_file.fileName ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
410 .arg (m_xbel_file.errorString())); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
411 return; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
412 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
413 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
414 QXmlStreamWriter xml_writer (&m_xbel_file); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
415 xml_writer.setAutoFormatting (true); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
416 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
417 xml_writer.writeStartDocument (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
418 xml_writer.writeDTD (dc_xbel_doctype); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
419 xml_writer.writeStartElement (dc_xbel_name_format); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
420 xml_writer.writeAttribute (dc_xbel_attr_version, dc_xbel_value_version); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
421 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
422 for (int i = 0; i < m_tree->topLevelItemCount(); i++) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
423 write_tree_item (&xml_writer, m_tree->topLevelItem (i)); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
424 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
425 xml_writer.writeEndDocument(); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
426 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
427 m_xbel_file.flush (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
428 m_xbel_file.close (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
429 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
430 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
431 void documentation_bookmarks::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
|
432 const QTreeWidgetItem *item) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
433 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
434 switch (item->data (0, tag_role).toInt ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
435 { |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
436 case folder_tag: |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
437 xml_writer->writeStartElement (dc_xbel_name_folder); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
438 xml_writer->writeAttribute (dc_xbel_attr_folded, |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
439 item->isExpanded () ? dc_xbel_value_no : dc_xbel_value_yes); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
440 xml_writer->writeTextElement (dc_xbel_name_title, item->text(0)); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
441 for (int i = 0; i < item->childCount (); i++) |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
442 write_tree_item (xml_writer, item->child (i)); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
443 xml_writer->writeEndElement (); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
444 break; |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
445 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
446 case bookmark_tag: |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
447 xml_writer->writeStartElement (dc_xbel_name_bookmark); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
448 xml_writer->writeAttribute (dc_xbel_attr_href, item->data (0, url_role).toString ()); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
449 xml_writer->writeTextElement (dc_xbel_name_title, item->text (0)); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
450 xml_writer->writeEndElement (); |
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
451 break; |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
452 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
453 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
454 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
455 QString documentation_bookmarks::read_bookmarks (void) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
456 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
457 QString error_message; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
458 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
459 // Check the file |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
460 if (! m_xbel_file.open (QFile::ReadOnly | QFile::Text)) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
461 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
462 error_message = tr ("Unable to read file %1:\n%2.") |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
463 .arg (m_xbel_file.fileName ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
464 .arg (m_xbel_file.errorString()); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
465 return error_message; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
466 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
467 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
468 QXmlStreamReader xml_reader (&m_xbel_file); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
469 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
470 if (! xml_reader.readNextStartElement ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
471 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
472 error_message = tr ("No start element found in %1.\n" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
473 "Invalid bookmark file?") |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
474 .arg (m_xbel_file.fileName ()); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
475 return error_message; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
476 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
477 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
478 if (xml_reader.name() != dc_xbel_name_format |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
479 || xml_reader.attributes ().value (dc_xbel_attr_version) != dc_xbel_value_version) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
480 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
481 error_message = tr ("The file\n" |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
482 "%1\n" |
30525
578fa8ca6437
* documentation-bookmarks.cc: fixed typo
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
483 "is not a valid XBEL file version 1.0.") |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
484 .arg (m_xbel_file.fileName ()); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
485 return error_message; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
486 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
487 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
488 // Read the elements from the file |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
489 while (xml_reader.readNextStartElement ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
490 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
491 if (xml_reader.name () == dc_xbel_name_folder) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
492 read_next_item (&xml_reader, folder_tag); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
493 else if (xml_reader.name () == dc_xbel_name_bookmark) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
494 read_next_item (&xml_reader, bookmark_tag); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
495 else |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
496 xml_reader.skipCurrentElement (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
497 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
498 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
499 m_xbel_file.close (); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
500 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29711
diff
changeset
|
501 return error_message; |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
502 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
503 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
504 void documentation_bookmarks::read_next_item (QXmlStreamReader *xml_reader, |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
505 item_tag tag, QTreeWidgetItem *item) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
506 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
507 QString title (tr ("Unknown title")); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
508 if (tag == folder_tag) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
509 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
510 // Next item is a folder, which might also have children |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
511 bool expanded = (xml_reader->attributes().value (dc_xbel_attr_folded) == dc_xbel_value_no); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
512 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
513 QTreeWidgetItem *new_folder = add_folder (title, item, expanded); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
514 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
515 // Check elements of this folder for title and for recursively |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
516 // adding sub-items |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
517 while (xml_reader->readNextStartElement ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
518 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
519 if (xml_reader->name () == dc_xbel_name_title) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
520 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
521 title = xml_reader->readElementText(); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
522 new_folder->setText (0, title); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
523 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
524 else if (xml_reader->name () == dc_xbel_name_folder) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
525 read_next_item (xml_reader, folder_tag, new_folder); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
526 else if (xml_reader->name () == dc_xbel_name_bookmark) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
527 read_next_item (xml_reader, bookmark_tag, new_folder); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
528 else |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
529 xml_reader->skipCurrentElement (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
530 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
531 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
532 else if (tag == bookmark_tag) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
533 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
534 // Next item is a bookmark, without children |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
535 QString url = xml_reader->attributes().value (dc_xbel_attr_href).toString (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
536 while (xml_reader->readNextStartElement ()) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
537 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
538 if (xml_reader->name() == dc_xbel_name_title) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
539 title = xml_reader->readElementText(); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
540 else |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
541 xml_reader->skipCurrentElement (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
542 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
543 add_bookmark (title, url, item); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
544 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
545 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff
changeset
|
546 |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
547 OCTAVE_END_NAMESPACE(octave) |