annotate libgui/src/documentation-bookmarks.cc @ 29359:7854d5752dd2

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 10:10:40 -0500
parents b92614cfdfed
children 3d34b70b5a49
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"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
43 #include "shortcut-manager.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
44
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
45 #include "defaults.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
46 #include "file-ops.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
47 #include "oct-env.h"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
48
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
49 namespace octave
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
50 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
51 documentation_bookmarks::documentation_bookmarks (
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
52 documentation *doc, documentation_browser *browser,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
53 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
54 : QWidget (p),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
55 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
56 m_ctx_menu_item (nullptr)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
57 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
58 setObjectName ("documentation_tab_bookmarks");
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
59
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
60 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
61 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
62
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
63 // 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
64 m_tree = new QTreeWidget (p);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
65
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
66 m_tree->setContextMenuPolicy (Qt::CustomContextMenu);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
67 m_tree->setSelectionMode (QAbstractItemView::ExtendedSelection);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
68 m_tree->setSortingEnabled (false);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
69 m_tree->setDragEnabled(true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
70 m_tree->viewport()->setAcceptDrops(true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
71 m_tree->setDropIndicatorShown(true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
72 m_tree->setDragDropMode(QAbstractItemView::InternalMove);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
73 m_tree->setColumnCount (1);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
74 m_tree->setHeaderHidden (true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
75 m_tree->setEditTriggers (QAbstractItemView::EditKeyPressed
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
76 | QAbstractItemView::SelectedClicked);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
77
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
78 connect (m_tree, SIGNAL (customContextMenuRequested (const QPoint &)),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
79 this, SLOT (ctx_menu (const QPoint &)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
80 connect (m_tree, SIGNAL (itemDoubleClicked (QTreeWidgetItem*, int)),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
81 this, SLOT (handle_double_click (QTreeWidgetItem*, int)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
82
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
83 // 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
84 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
85 QIcon::Normal, QIcon::Off);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
86 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
87 QIcon::Normal, QIcon::On);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
88 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
89
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
90 // Setup and read the bookmarkfile
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
91 QFileInfo f (settings->fileName ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
92 QString f_path = f.absolutePath ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
93 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
94 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
95
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
96 if (m_xbel_file.exists ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
97 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
98 QString err = read_bookmarks ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
99 if ( !err.isEmpty ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
100 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
101 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
102 QMessageBox::warning (this,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
103 tr ("Octave: Loading Documentation Bookmarks"),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
104 err);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
105 m_xbel_file.close ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
106 }
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 // Setup the filter widget
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
110 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
111 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
112
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
113 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
114 m_filter->setEditable (true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
115 m_filter->setInsertPolicy (QComboBox::NoInsert);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
116 m_filter->setMaxCount (10);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
117 m_filter->setMaxVisibleItems (10);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
118 m_filter->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
119 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
120 m_filter->setSizePolicy (size_pol);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
121 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
122
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
123 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
124
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
125 connect (m_filter, SIGNAL (editTextChanged (const QString &)),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
126 this, SLOT (filter_bookmarks (const QString &)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
127 connect (m_filter->lineEdit (), SIGNAL (editingFinished (void)),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
128 this, SLOT (update_filter_history (void)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
129
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
130 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
131 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
132 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
133 filter_activate (filter_state);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
134
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
135 connect (m_filter_checkbox, SIGNAL (toggled (bool)),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
136 this, SLOT (filter_activate (bool)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
137
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
138 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
139 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
140 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
141 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
142 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
143 h_box_bm->setMargin (2);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
144 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
145
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
146 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
147 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
148
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
149 // Resulting Layout of this widget
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
150 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
151 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
152 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
153 setLayout (v_box_bm);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
154 }
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 documentation_bookmarks::~documentation_bookmarks (void)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
157 { }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
158
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
159 // 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
160 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
161 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
162 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
163
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
164 // 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
165 QTreeWidgetItemIterator it (m_tree);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
166 while (*it)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
167 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
168 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
169 if (url == url_i)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
170 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
171 m_tree->setCurrentItem (*it);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
172 (*it)->setExpanded (true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
173 return;
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 it++;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
176 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
177
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
178 // 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
179 // as top-level-item
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
180 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
181 add_bookmark (title, url.toString ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
182 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
183
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
184 // 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
185 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
186 const QString& url,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
187 QTreeWidgetItem* item)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
188 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
189 // Create new bookmark
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
190 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
191 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
192 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
193 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
194 | Qt::ItemIsEditable
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
195 | Qt::ItemIsDragEnabled);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
196 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
197
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
198 // 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
199 // 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
200 // 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
201 if (item)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
202 item->addChild (new_item);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
203 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
204 m_tree->addTopLevelItem (new_item);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
205 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
206
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
207 // 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
208 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
209 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
210 QTreeWidgetItem *parent_item = nullptr;
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)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
213 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
214 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
215 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
216 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
217 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
218 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
219 if (p)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
220 parent_item = p;
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 }
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 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
225
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
226 m_tree->setCurrentItem (new_folder);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
227 m_tree->editItem (new_folder);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
228 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
229
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
230 // 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
231 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
232 QTreeWidgetItem *item, bool expanded)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
233 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
234 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
235 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
236 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
237 | Qt::ItemIsDragEnabled
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
238 | Qt::ItemIsDropEnabled);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
239 new_folder->setChildIndicatorPolicy (QTreeWidgetItem::DontShowIndicatorWhenChildless);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
240 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
241 new_folder->setExpanded (expanded);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
242
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
243 // 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
244 if (item)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
245 item->addChild (new_folder);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
246 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
247 m_tree->addTopLevelItem (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 return new_folder;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
250 }
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 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
253 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
254 QTreeWidgetItemIterator it (m_tree);
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 while (*it)
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 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
259 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
260 (*it)->setHidden (false);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
261 (*it)->setExpanded (true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
262 QTreeWidgetItem *p = (*it)->parent ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
263 while (p)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
264 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
265 p->setHidden (false);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
266 p->setExpanded (true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
267 p = p->parent ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
268 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
269 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
270 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
271 (*it)->setHidden (true);
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 it++;
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 }
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 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
278 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
279 m_filter->setEnabled (state);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
280
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
281 QString pattern;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
282 if (state)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
283 pattern = m_filter->currentText ();
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 filter_bookmarks (pattern);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
286 }
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 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
289 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
290 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
291 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
292
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
293 if (index > -1)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
294 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
295
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
296 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
297 m_filter->setCurrentIndex (0);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
298 }
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 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
301 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
302 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
303
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
304 if (tag == folder_tag)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
305 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
306 item->setExpanded (! item->isExpanded ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
307 return;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
308 }
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 if (tag == bookmark_tag)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
311 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
312 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
313 if (! url.isEmpty ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
314 m_browser->setSource (url);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
315 return;
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 }
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 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
320 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
321 QMenu menu (this);
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 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
324
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
325 if (m_ctx_menu_item)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
326 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
327 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
328
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
329 menu.addAction (tr ("&Open"), this, SLOT (open (bool)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
330 menu.addAction (tr ("&Rename"), this, SLOT (edit (bool)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
331 menu.addAction (rmgr.icon ("window-close"), tr ("Remo&ve"), this,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
332 SLOT (remove (bool)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
333 menu.addSeparator ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
334 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
335
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
336 menu.addAction (tr ("&Add Folder"), this, SLOT (add_folder (bool)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
337
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
338 menu.addSeparator ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
339
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
340 if (m_filter_shown)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
341 menu.addAction (tr ("Hide &Filter"), this, SLOT (show_filter (bool)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
342 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
343 menu.addAction (tr ("Show &Filter"), this, SLOT (show_filter (bool)));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
344
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
345 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
346 }
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 void documentation_bookmarks::open (bool)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
349 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
350 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
351
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
352 if (items.size () > 0)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
353 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
354 }
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 void documentation_bookmarks::edit (bool)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
357 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
358 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
359
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
360 if (items.size () > 0)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
361 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
362 }
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 void documentation_bookmarks::remove (bool)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
365 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
366 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
367
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
368 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
369 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
370 if (*it)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
371 m_tree->takeTopLevelItem (
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
372 m_tree->indexOfTopLevelItem (*it));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
373 }
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 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
377 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
378 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
379 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
380 }
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 void documentation_bookmarks::save_settings (void)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
383 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
384 // 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
385 write_bookmarks ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
386
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
387 // Store settings
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
388 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
389 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
390
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
391 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
392 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
393
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
394 QStringList mru;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
395 for (int i = 0; i < m_filter->count (); i++)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
396 mru.append (m_filter->itemText (i));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
397 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
398
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
399 settings->sync ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
400 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
401
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
402 void documentation_bookmarks::write_bookmarks (void)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
403 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
404 if (! m_xbel_file.open (QFile::WriteOnly | QFile::Text))
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
405 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
406 QMessageBox::warning (this, tr("Octave: Saving Documentation Bookmarks"),
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
407 tr("Unable to write file %1:\n%2.\n\n"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
408 "Documentation bookmarks are not saved!\n")
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
409 .arg (m_xbel_file.fileName ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
410 .arg (m_xbel_file.errorString()));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
411 return;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
412 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
413
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
414 QXmlStreamWriter xml_writer (&m_xbel_file);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
415 xml_writer.setAutoFormatting (true);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
416
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
417 xml_writer.writeStartDocument ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
418 xml_writer.writeDTD (dc_xbel_doctype);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
419 xml_writer.writeStartElement (dc_xbel_name_format);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
420 xml_writer.writeAttribute (dc_xbel_attr_version, dc_xbel_value_version);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
421
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
422 for (int i = 0; i < m_tree->topLevelItemCount(); i++)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
423 write_tree_item (&xml_writer, m_tree->topLevelItem (i));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
424
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
425 xml_writer.writeEndDocument();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
426
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
427 m_xbel_file.flush ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
428 m_xbel_file.close ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
429 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
430
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
431 void documentation_bookmarks::write_tree_item (QXmlStreamWriter* xml_writer,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
432 const QTreeWidgetItem *item)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
433 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
434 switch (item->data (0, tag_role).toInt ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
435 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
436 case folder_tag:
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
437 xml_writer->writeStartElement (dc_xbel_name_folder);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
438 xml_writer->writeAttribute (dc_xbel_attr_folded,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
439 item->isExpanded () ? dc_xbel_value_no : dc_xbel_value_yes);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
440 xml_writer->writeTextElement (dc_xbel_name_title, item->text(0));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
441 for (int i = 0; i < item->childCount (); i++)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
442 write_tree_item (xml_writer, item->child (i));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
443 xml_writer->writeEndElement ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
444 break;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
445
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
446 case bookmark_tag:
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
447 xml_writer->writeStartElement (dc_xbel_name_bookmark);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
448 xml_writer->writeAttribute (dc_xbel_attr_href, item->data (0, url_role).toString ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
449 xml_writer->writeTextElement (dc_xbel_name_title, item->text (0));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
450 xml_writer->writeEndElement ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
451 break;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
452 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
453 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
454
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
455 QString documentation_bookmarks::read_bookmarks (void)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
456 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
457 QString error_message;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
458
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
459 // Check the file
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
460 if (! m_xbel_file.open (QFile::ReadOnly | QFile::Text))
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
461 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
462 error_message = tr ("Unable to read file %1:\n%2.")
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
463 .arg (m_xbel_file.fileName ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
464 .arg (m_xbel_file.errorString());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
465 return error_message;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
466 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
467
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
468 QXmlStreamReader xml_reader (&m_xbel_file);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
469
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
470 if (! xml_reader.readNextStartElement ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
471 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
472 error_message = tr ("No start element found in %1.\n"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
473 "Invalid bookmark file?")
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
474 .arg (m_xbel_file.fileName ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
475 return error_message;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
476 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
477
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
478 if (xml_reader.name() != dc_xbel_name_format
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
479 || xml_reader.attributes ().value (dc_xbel_attr_version) != dc_xbel_value_version)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
480 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
481 error_message = tr ("The file\n"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
482 "%1\n"
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
483 "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
484 .arg (m_xbel_file.fileName ());
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
485 return error_message;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
486 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
487
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
488 // Read the elements from the file
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
489 while (xml_reader.readNextStartElement ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
490 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
491 if (xml_reader.name () == dc_xbel_name_folder)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
492 read_next_item (&xml_reader, folder_tag);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
493 else if (xml_reader.name () == dc_xbel_name_bookmark)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
494 read_next_item (&xml_reader, bookmark_tag);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
495 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
496 xml_reader.skipCurrentElement ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
497 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
498
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
499 m_xbel_file.close ();
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 return error_message;
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
502 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
503
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
504 void documentation_bookmarks::read_next_item (QXmlStreamReader *xml_reader,
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
505 item_tag tag, QTreeWidgetItem *item)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
506 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
507 QString title (tr ("Unknown title"));
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
508 if (tag == folder_tag)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
509 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
510 // Next item is a folder, which might also have children
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
511 bool expanded = (xml_reader->attributes().value (dc_xbel_attr_folded) == dc_xbel_value_no);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
512
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
513 QTreeWidgetItem *new_folder = add_folder (title, item, expanded);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
514
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
515 // Check elements of this folder for title and for recursively
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
516 // adding sub-items
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
517 while (xml_reader->readNextStartElement ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
518 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
519 if (xml_reader->name () == dc_xbel_name_title)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
520 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
521 title = xml_reader->readElementText();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
522 new_folder->setText (0, title);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
523 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
524 else if (xml_reader->name () == dc_xbel_name_folder)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
525 read_next_item (xml_reader, folder_tag, new_folder);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
526 else if (xml_reader->name () == dc_xbel_name_bookmark)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
527 read_next_item (xml_reader, bookmark_tag, new_folder);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
528 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
529 xml_reader->skipCurrentElement ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
530 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
531 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
532 else if (tag == bookmark_tag)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
533 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
534 // Next item is a bookmark, without children
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
535 QString url = xml_reader->attributes().value (dc_xbel_attr_href).toString ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
536 while (xml_reader->readNextStartElement ())
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
537 {
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
538 if (xml_reader->name() == dc_xbel_name_title)
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
539 title = xml_reader->readElementText();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
540 else
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
541 xml_reader->skipCurrentElement ();
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
542 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
543 add_bookmark (title, url, item);
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
544 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
545 }
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
546
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
547 }