annotate libgui/src/documentation-bookmarks.cc @ 30398:d4d83344d653 stable

maint: style check C++ files in src/ and libgui/ ahead of 7.1 release. * ButtonGroup.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc, Figure.h, FigureWindow.cc, GenericEventNotify.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Menu.cc, Object.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, RadioButtonControl.cc, SliderControl.cc, Table.cc, Table.h, TextControl.cc, ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, annotation-dialog.cc, qt-graphics-toolkit.cc, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-model.cc, gui-preferences-dw.h, gui-preferences-ed.h, gui-preferences-global.h, gui-settings.h, interpreter-qobject.cc, led-indicator.cc, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, octave-qscintilla.cc, octave-qscintilla.h, main-window.cc, main-window.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, octave-qtutils.h, qt-interpreter-events.cc, release-notes.cc, resource-manager.cc, set-path-dialog.cc, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, tab-bar.cc, tab-bar.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, workspace-model.cc, workspace-view.cc, mkoctfile.in.cc, octave-config.in.cc: Style check C++ files in src/ and libgui/ ahead of 7.1 release.
author Rik <rik@octave.org>
date Mon, 29 Nov 2021 15:58:51 -0800
parents 7a0be7c8b7ca
children 578fa8ca6437
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
1 ////////////////////////////////////////////////////////////////////////
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
2 //
29359
7854d5752dd2 maint: merge stable to default.
John W. Eaton <jwe@octave.org>
parents: 29330
diff changeset
3 // Copyright (C) 2018-2021 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>
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
31 #include <QMenu>
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
32 #include <QShortcut>
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
33 #include <QVBoxLayout>
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
34 #include <QWidget>
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
35
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
36 #include "documentation.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
37 #include "documentation-bookmarks.h"
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 "gui-settings.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
40 #include "gui-preferences-global.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
41 #include "gui-preferences-dc.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
42 #include "gui-preferences-sc.h"
29560
5b7e721844df provide QOverload template if it is not in <QtGlobal> (bug #60416)
John W. Eaton <jwe@octave.org>
parents: 29550
diff changeset
43 #include "octave-qtutils.h"
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
44 #include "shortcut-manager.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
45
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
46 #include "defaults.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
47 #include "file-ops.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
48 #include "oct-env.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
49
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
50 namespace octave
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
51 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
52 documentation_bookmarks::documentation_bookmarks (
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
53 documentation *doc, documentation_browser *browser,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
54 base_qobject& oct_qobj, QWidget *p)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
55 : QWidget (p),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
56 m_doc (doc), m_browser (browser), m_octave_qobj (oct_qobj),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
57 m_ctx_menu_item (nullptr)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
58 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
59 setObjectName ("documentation_tab_bookmarks");
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
60
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
61 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
62 gui_settings *settings = rmgr.get_settings ();
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
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
92 QFileInfo f (settings->fileName ());
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
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
124 m_filter->addItems (settings->value (dc_bookmark_filter_mru).toStringList ());
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);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
132 bool filter_state = settings->value (dc_bookmark_filter_active).toBool ();
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
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
147 m_filter_shown = settings->value (dc_bookmark_filter_shown).toBool ();
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 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
325 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
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);
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
329 menu.addAction (rmgr.icon ("window-close"), tr ("Remo&ve"),
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
29711
7a0be7c8b7ca restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29560
diff changeset
383 void documentation_bookmarks::save_settings (gui_settings *settings)
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
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
389 settings->setValue (dc_bookmark_filter_active.key, m_filter_checkbox->isChecked ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
390 settings->setValue (dc_bookmark_filter_shown.key, m_filter_shown);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
391
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
392 QStringList mru;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
393 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
394 mru.append (m_filter->itemText (i));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
395 settings->setValue (dc_bookmark_filter_mru.key, mru);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
396
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
397 settings->sync ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
398 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
399
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
400 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
401 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
402 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
403 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
404 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
405 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
406 "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
407 .arg (m_xbel_file.fileName ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
408 .arg (m_xbel_file.errorString()));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
409 return;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
410 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
411
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
412 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
413 xml_writer.setAutoFormatting (true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
414
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
415 xml_writer.writeStartDocument ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
416 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
417 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
418 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
419
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
420 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
421 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
422
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
423 xml_writer.writeEndDocument();
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 m_xbel_file.flush ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
426 m_xbel_file.close ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
427 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
428
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
429 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
430 const QTreeWidgetItem *item)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
431 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
432 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
433 {
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29711
diff changeset
434 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
435 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
436 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
437 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
438 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
439 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
440 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
441 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
442 break;
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
443
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29711
diff changeset
444 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
445 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
446 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
447 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
448 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
449 break;
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
450 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
451 }
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 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
454 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
455 QString error_message;
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 // Check the file
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
458 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
459 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
460 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
461 .arg (m_xbel_file.fileName ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
462 .arg (m_xbel_file.errorString());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
463 return error_message;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
464 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
465
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
466 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
467
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
468 if (! xml_reader.readNextStartElement ())
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 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
471 "Invalid bookmark file?")
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
472 .arg (m_xbel_file.fileName ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
473 return error_message;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
474 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
475
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
476 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
477 || 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
478 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
479 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
480 "%1\n"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
481 "is not a valid XBEL file verison 1.0.")
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
482 .arg (m_xbel_file.fileName ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
483 return error_message;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
484 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
485
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
486 // 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
487 while (xml_reader.readNextStartElement ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
488 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
489 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
490 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
491 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
492 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
493 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
494 xml_reader.skipCurrentElement ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
495 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
496
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29711
diff changeset
497 m_xbel_file.close ();
29330
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 return error_message;
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
500 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
501
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
502 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
503 item_tag tag, QTreeWidgetItem *item)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
504 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
505 QString title (tr ("Unknown title"));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
506 if (tag == folder_tag)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
507 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
508 // 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
509 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
510
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
511 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
512
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
513 // 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
514 // adding sub-items
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
515 while (xml_reader->readNextStartElement ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
516 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
517 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
518 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
519 title = xml_reader->readElementText();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
520 new_folder->setText (0, title);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
521 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
522 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
523 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
524 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
525 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
526 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
527 xml_reader->skipCurrentElement ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
528 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
529 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
530 else if (tag == bookmark_tag)
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 // 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
533 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
534 while (xml_reader->readNextStartElement ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
535 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
536 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
537 title = xml_reader->readElementText();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
538 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
539 xml_reader->skipCurrentElement ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
540 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
541 add_bookmark (title, url, item);
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 }
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 }