annotate libgui/src/history-dock-widget.h @ 31619:ad014fc78bd6

use individual local gui_settings objects Previously, we created a single gui_settings object (derived from QSettings) and accessed it from the resource_manager object. That design is not necessary and is not the way QSettings was designed to be used. Instead of managing a single object, we should be using individual QSettings objects where needed. Each individual QSettings object manages thread-safe access to a single global collection of settings. The Qt docs say that operations on QSettings are not thread safe, but that means that you can't create a QSettings object in one thread and use it in another without some locking. I'm not sure whether we were doing that correctly, but with this change it no longer matters. Each QSettings object does perform locking when reading or writing the underlying global data. * resource-manager.h, resource-manager.cc (resource_manager::m_settings): Delete data member. (resource_manager::get_settings): Delete. * annotation-dialog.cc, QTerminal.cc, QTerminal.h, command-widget.cc, command-widget.h, community-news.cc, dialog.cc, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, history-dock-widget.cc, history-dock-widget.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, octave-qscintilla.cc, main-window.cc, main-window.h, news-reader.cc, octave-dock-widget.cc, octave-dock-widget.h, qt-interpreter-events.cc, qt-interpreter-events.h, release-notes.cc, resource-manager.cc, resource-manager.h, set-path-dialog.cc, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, workspace-model.cc, workspace-model.h, workspace-view.cc: Use local gui_settings objects instead of accessing a pointer to a single gui_settings object owned by the resource_manager object.
author John W. Eaton <jwe@octave.org>
date Fri, 02 Dec 2022 14:23:53 -0500
parents 796f54d4ddbf
children 431f80aba37a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29767
diff changeset
3 // Copyright (C) 2011-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
25
21203
710e700cdd7f maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents: 20945
diff changeset
26 #if ! defined (octave_history_dock_widget_h)
710e700cdd7f maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents: 20945
diff changeset
27 #define octave_history_dock_widget_h 1
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
28
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 26871
diff changeset
29 #include <QCheckBox>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 26871
diff changeset
30 #include <QComboBox>
13545
ffc2e1d1ad5f History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13536
diff changeset
31 #include <QLineEdit>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
32 #include <QListView>
13545
ffc2e1d1ad5f History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13536
diff changeset
33 #include <QSortFilterProxyModel>
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
34 #include <QStringListModel>
19563
a402493c0605 provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
35
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15552
diff changeset
36 #include "octave-dock-widget.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
37
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
38 namespace octave
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
39 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
40 class base_qobject;
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
41
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
42 class history_dock_widget : public octave_dock_widget
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
43 {
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
44 Q_OBJECT
16447
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16431
diff changeset
45
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
46 public:
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
47
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
48 history_dock_widget (QWidget *parent, base_qobject& oct_qobj);
24011
9107bae20480 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
49
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
50 ~history_dock_widget (void) = default;
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
51
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
52 signals:
16447
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16431
diff changeset
53
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27629
diff changeset
54 //! Signal emitted whenever the user double-clicks a command in the
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
55 //! history.
24109
1d6c940a1b37 doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24011
diff changeset
56
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
57 void command_double_clicked (const QString& command);
14863
3ff18e21c742 Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14814
diff changeset
58
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27629
diff changeset
59 //! Signal emitted whenever the user selects commands and chooses
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
60 //! "Create script" from the popup menu.
24109
1d6c940a1b37 doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24011
diff changeset
61
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
62 void command_create_script (const QString& commands);
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
63
27590
f6b729077ebd use consistent order for signal/slot/other decls in libgui/src files
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
64 public slots:
f6b729077ebd use consistent order for signal/slot/other decls in libgui/src files
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
65
f6b729077ebd use consistent order for signal/slot/other decls in libgui/src files
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
66 void set_history (const QStringList& hist);
f6b729077ebd use consistent order for signal/slot/other decls in libgui/src files
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
67 void append_history (const QString& hist_entry);
f6b729077ebd use consistent order for signal/slot/other decls in libgui/src files
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
68 void clear_history (void);
f6b729077ebd use consistent order for signal/slot/other decls in libgui/src files
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
69 void save_settings (void);
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
70 void notice_settings (void);
27590
f6b729077ebd use consistent order for signal/slot/other decls in libgui/src files
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
71
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
72 private slots:
16447
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16431
diff changeset
73
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
74 void update_filter_history (void);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
75 void filter_activate (bool enable);
19563
a402493c0605 provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
76
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
77 void ctxMenu (const QPoint& pos);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
78 void handle_double_click (QModelIndex modelIndex);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
79 void handle_contextmenu_copy (bool flag);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
80 void handle_contextmenu_evaluate (bool flag);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
81 void handle_contextmenu_create_script (bool flag);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
82 void handle_contextmenu_filter (void);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
83
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
84 void copyClipboard (void);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
85 void pasteClipboard (void);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
86 void selectAll (void);
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16461
diff changeset
87
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
88 virtual void handle_visibility (bool visible);
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
89
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
90 private:
20692
950c8a092db7 check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
91
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
92 void construct (void);
29340
0e97c97044ee improve handling focus of filter widgets in history and workspace view
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
93 void set_filter_focus (bool focus);
24011
9107bae20480 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
94
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
95 QListView *m_history_list_view;
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
96 QSortFilterProxyModel m_sort_filter_proxy_model;
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
97
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
98 //! Stores the current history_model.
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
99
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
100 QStringListModel *m_history_model;
24109
1d6c940a1b37 doc: Improve Doxygen documentation for some files in libgui.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24011
diff changeset
101
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
102 QCheckBox *m_filter_checkbox;
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
103 QComboBox *m_filter;
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
104 QWidget *m_filter_widget;
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
105 bool m_filter_shown;
19563
a402493c0605 provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
106
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
107 enum { MaxFilterHistory = 10 };
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
108 };
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
109 }
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
110
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20697
diff changeset
111 #endif