annotate libgui/src/variable-editor.cc @ 25249:65f201566857 stable

Mark missing Variable Editor GUI strings for translation (bug #53526). * variable-editor.cc (color_names): Mark all strings in function for translation.
author Rik <rik@octave.org>
date Sat, 14 Apr 2018 18:11:14 -0700
parents 07bddddc5856
children d56ff4681065 7a507e71d922
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1 /*
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
2
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25000
diff changeset
3 Copyright (C) 2013-2018 John W. Eaton
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
4 Copyright (C) 2015 Michael Barnes
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
5 Copyright (C) 2013 RĂ¼diger Sonderfeld
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
6
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
7 This file is part of Octave.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
8
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24135
diff changeset
9 Octave is free software: you can redistribute it and/or modify it
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24135
diff changeset
11 Free Software Foundation, either version 3 of the License, or (at your
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
12 option) any later version.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
13
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
17 for more details.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
18
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
20 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24135
diff changeset
21 <https://www.gnu.org/licenses/>.
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
22
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
23 */
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
24
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
23978
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
26 # include "config.h"
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
27 #endif
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
28
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
29 #include <limits>
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
30
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
31 #include <QApplication>
23978
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
32 #include <QClipboard>
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
33 #include <QFileDialog>
23978
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
34 #include <QHeaderView>
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
35 #include <QLabel>
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
36 #include <QMdiArea>
23978
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
37 #include <QMenu>
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
38 #include <QPalette>
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
39 #include <QScreen>
24762
ed2d9ef336a7 resize varible editor model on scrollbar actions
John W. Eaton <jwe@octave.org>
parents: 24758
diff changeset
40 #include <QScrollBar>
23978
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
41 #include <QSignalMapper>
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
42 #include <QStackedWidget>
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
43 #include <QTableView>
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
44 #include <QTextEdit>
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
45 #include <QTabWidget>
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
46 #include <QToolBar>
23978
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
47 #include <QToolButton>
665507c3c29d Use Octave coding conventions for Variable Editor code.
Rik <rik@octave.org>
parents: 23969
diff changeset
48 #include <QVBoxLayout>
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
49
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
50 #include "resource-manager.h"
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
51 #include "shortcut-manager.h"
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
52 #include "variable-editor.h"
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
53 #include "variable-editor-model.h"
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
54
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
55 // Code reuse functions
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
56
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
57 static QString
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
58 idx_to_expr (int32_t from, int32_t to)
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
59 {
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
60 return (from == to
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
61 ? QString ("%1").arg (from)
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
62 : QString ("%1:%2").arg (from).arg (to));
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
63 }
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
64
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
65 static QSignalMapper *
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
66 make_plot_mapper (QMenu *menu)
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
67 {
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
68 QList<QString> list;
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
69 list << "plot" << "bar" << "stem" << "stairs" << "area" << "pie" << "hist";
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
70
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
71 QSignalMapper *plot_mapper = new QSignalMapper (menu);
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
72
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
73 for (int i = 0; i < list.size(); ++i)
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
74 {
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
75 plot_mapper->setMapping
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
76 (menu->addAction (list.at (i), plot_mapper, SLOT (map ())),
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
77 "figure (); " + list.at (i) + " (%1); title (\"%1\");");
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
78 }
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
79
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
80 return plot_mapper;
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
81 }
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
82
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
83 namespace octave
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
84 {
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
85 // Variable dock widget
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
86
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
87 variable_dock_widget::variable_dock_widget (QWidget *p)
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
88 : label_dock_widget (p)
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
89 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
90 setFocusPolicy (Qt::StrongFocus);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
91 setAttribute (Qt::WA_DeleteOnClose);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
92
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
93 connect (m_dock_action, SIGNAL (triggered (bool)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
94 this, SLOT (change_floating (bool)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
95 connect (m_close_action, SIGNAL (triggered (bool)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
96 this, SLOT (change_existence (bool)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
97 connect (this, SIGNAL (topLevelChanged(bool)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
98 this, SLOT (toplevel_change (bool)));
24834
6daf8a9bd1ed hide floating variable widgets when variable editor is hidden
Torsten <mttl@mailbox.org>
parents: 24832
diff changeset
99 connect (p, SIGNAL (visibilityChanged (bool)),
6daf8a9bd1ed hide floating variable widgets when variable editor is hidden
Torsten <mttl@mailbox.org>
parents: 24832
diff changeset
100 this, SLOT (setVisible (bool)));
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
101
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
102 #if defined (HAVE_QGUIAPPLICATION)
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
103 #define DOCKED_FULLSCREEN_BUTTON_TOOLTIP "Fullscreen undock"
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
104 #define UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP "Fullscreen"
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
105 // Add a fullscreen button
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
106
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
107 m_fullscreen_action = nullptr;
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
108 m_full_screen = false;
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
109 m_prev_floating = false;
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
110 m_prev_geom = QRect (0, 0, 0, 0);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
111
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
112 QHBoxLayout *h_layout = findChild<QHBoxLayout *> ();
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
113 if (h_layout != nullptr && titleBarWidget () != nullptr)
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
114 {
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
115 m_fullscreen_action = new QAction
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
116 (resource_manager::icon ("view-fullscreen", false), "", this);
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
117 m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP));
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
118 QToolButton *fullscreen_button = new QToolButton (titleBarWidget ());
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
119 fullscreen_button->setDefaultAction (m_fullscreen_action);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
120 fullscreen_button->setFocusPolicy (Qt::NoFocus);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
121 fullscreen_button->setIconSize (QSize (m_icon_size,m_icon_size));
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
122 QString css_button = QString ("QToolButton {background: transparent; border: 0px;}");
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
123 fullscreen_button->setStyleSheet (css_button);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
124
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
125 connect (m_fullscreen_action, SIGNAL (triggered ()),
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
126 this, SLOT (change_fullscreen ()));
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
127
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
128 int index = -1;
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
129 QToolButton *first = titleBarWidget ()->findChild<QToolButton *> ();
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
130 if (first != nullptr)
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
131 index = h_layout->indexOf (first);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
132 h_layout->insertWidget (index, fullscreen_button);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
133 }
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
134 #endif
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
135
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
136 // Custom title bars cause loss of decorations, add a frame
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
137 m_frame = new QFrame (this);
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
138 m_frame->setFrameStyle (QFrame::Box | QFrame::Sunken);
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
139 m_frame->setAttribute (Qt::WA_TransparentForMouseEvents);
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
140 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
141
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
142 // slot for (un)dock action
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
143 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
144 variable_dock_widget::change_floating (bool)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
145 {
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
146 #if defined (HAVE_QGUIAPPLICATION)
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
147 if (isFloating ())
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
148 {
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
149 if (m_full_screen)
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
150 {
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
151 setGeometry (m_prev_geom);
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
152 m_fullscreen_action->setIcon (resource_manager::icon ("view-fullscreen", false));
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
153 m_full_screen = false;
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
154 }
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
155 m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP));
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
156 }
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
157 else
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
158 m_fullscreen_action->setToolTip (tr (UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP));
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
159 #endif
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
160
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
161 setFloating (! isFloating ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
162 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
163
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
164 // slot for hiding the widget
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
165 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
166 variable_dock_widget::change_existence (bool)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
167 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
168 close ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
169 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
170
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
171 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
172 variable_dock_widget::toplevel_change (bool toplevel)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
173 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
174 if (toplevel)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
175 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
176 m_dock_action->setIcon (QIcon (":/actions/icons/widget-dock.png"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
177 m_dock_action->setToolTip (tr ("Dock widget"));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
178
25168
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
179 activateWindow();
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
180 setFocus (Qt::OtherFocusReason);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
181 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
182 else
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
183 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
184 m_dock_action->setIcon (QIcon (":/actions/icons/widget-undock.png"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
185 m_dock_action->setToolTip (tr ("Undock widget"));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
186
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
187 setFocus (Qt::OtherFocusReason);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
188 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
189 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
190
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
191 void
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
192 variable_dock_widget::change_fullscreen (void)
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
193 {
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
194 #if defined (HAVE_QGUIAPPLICATION)
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
195 if (! m_full_screen)
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
196 {
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
197 m_prev_floating = isFloating ();
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
198 m_prev_geom = geometry ();
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
199
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
200 m_fullscreen_action->setIcon (resource_manager::icon ("view-restore", false));
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
201 if (m_prev_floating)
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
202 m_fullscreen_action->setToolTip (tr ("Restore geometry"));
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
203 else
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
204 {
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
205 m_fullscreen_action->setToolTip (tr ("Redock"));
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
206 setFloating (true);
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
207 }
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
208
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
209 // showFullscreen() and setWindowState() only work for QWindow objects.
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
210 QScreen *pscreen = QGuiApplication::primaryScreen ();
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
211 QRect rect (0, 0, 0, 0);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
212 rect = pscreen->availableGeometry ();
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
213 setGeometry (rect);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
214
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
215 m_full_screen = true;
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
216 }
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
217 else
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
218 {
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
219 m_fullscreen_action->setIcon (resource_manager::icon ("view-fullscreen", false));
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
220 setGeometry (m_prev_geom);
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
221 if (m_prev_floating)
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
222 m_fullscreen_action->setToolTip (tr (UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP));
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
223 else
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
224 {
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
225 setFloating (false);
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
226 m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP));
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
227 }
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
228
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
229 m_full_screen = false;
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
230 }
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
231 #undef DOCKED_FULLSCREEN_BUTTON_TOOLTIP
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
232 #undef UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP
24858
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
233 #endif
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
234 }
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
235
8ce66fe46f18 Improve fullscreen action for variable editor panes (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24843
diff changeset
236 void
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
237 variable_dock_widget::closeEvent (QCloseEvent *e)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
238 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
239 QDockWidget::closeEvent (e);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
240 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
241
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
242 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
243 variable_dock_widget::handle_focus_change (QWidget *old, QWidget *now)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
244 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
245 octave_unused_parameter (now);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
246
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
247 // The is a proxied test
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
248 if (hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
249 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
250 QLabel *label = titleBarWidget ()->findChild<QLabel *> ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
251 if (label != nullptr)
24843
bf1bace6d01d Use OS GUI highlight backgroud color for variable editor name label (bug #53274)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24834
diff changeset
252 {
bf1bace6d01d Use OS GUI highlight backgroud color for variable editor name label (bug #53274)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24834
diff changeset
253 label->setBackgroundRole (QPalette::Highlight);
bf1bace6d01d Use OS GUI highlight backgroud color for variable editor name label (bug #53274)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24834
diff changeset
254 label->setAutoFillBackground (true);
bf1bace6d01d Use OS GUI highlight backgroud color for variable editor name label (bug #53274)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24834
diff changeset
255 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
256
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
257 emit variable_focused_signal (objectName ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
258 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
259 else if (old == focusWidget())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
260 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
261 QLabel *label = titleBarWidget ()->findChild<QLabel *> ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
262 if (label != NULL)
24843
bf1bace6d01d Use OS GUI highlight backgroud color for variable editor name label (bug #53274)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24834
diff changeset
263 label->setBackgroundRole (QPalette::NoRole);
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
264 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
265 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
266
24865
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
267 void variable_dock_widget::resizeEvent (QResizeEvent *)
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
268 {
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
269 if (m_frame)
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
270 m_frame->resize (size ());
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
271 }
5f7b9ee5b878 Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24858
diff changeset
272
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
273
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
274 // Variable editor stack
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
275
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
276 variable_editor_stack::variable_editor_stack (QWidget *p)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
277 : QStackedWidget (p), m_edit_view (new variable_editor_view (this))
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
278 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
279 setFocusPolicy (Qt::StrongFocus);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
280
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
281 m_disp_view = make_disp_view (this);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
282
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
283 addWidget (m_edit_view);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
284 addWidget (m_disp_view);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
285 }
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
286
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
287 QTextEdit *
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
288 variable_editor_stack::make_disp_view (QWidget *parent)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
289 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
290 QTextEdit *viewer = new QTextEdit (parent);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
291
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
292 viewer->setLineWrapMode (QTextEdit::NoWrap);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
293 viewer->setReadOnly (true);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
294
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
295 return viewer;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
296 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
297
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
298 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
299 variable_editor_stack::set_editable (bool editable)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
300 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
301 // The QTableView is for editable data models
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
302 // and the QTextEdit is for non-editable models.
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
303
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
304 if (editable)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
305 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
306 if (m_edit_view != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
307 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
308 setCurrentWidget (m_edit_view);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
309 setFocusProxy (m_edit_view);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
310 m_edit_view->setFocusPolicy (Qt::StrongFocus);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
311 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
312
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
313 if (m_disp_view != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
314 m_disp_view->setFocusPolicy (Qt::NoFocus);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
315 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
316 else
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
317 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
318 if (m_disp_view != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
319 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
320 setCurrentWidget (m_disp_view);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
321 setFocusProxy (m_disp_view);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
322
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
323 QAbstractTableModel *model = findChild<QAbstractTableModel *> ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
324 if (model != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
325 m_disp_view->setPlainText (model->data (QModelIndex ()).toString ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
326 else
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
327 m_disp_view->setPlainText ("");
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
328 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
329
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
330 if (m_edit_view != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
331 m_edit_view->setFocusPolicy (Qt::NoFocus);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
332 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
333 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
334
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
335 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
336 variable_editor_stack::levelUp (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
337 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
338 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
339 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
340
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
341 QString name = objectName ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
342
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
343 // FIXME: Is there a better way?
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
344
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
345 if (name.endsWith (')') || name.endsWith ('}'))
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
346 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
347 name.remove (QRegExp ("(\\(|\\{)[^({]*(\\)|\\})$"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
348 emit edit_variable_signal (name, octave_value ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
349 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
350 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
351
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
352 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
353 variable_editor_stack::save (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
354 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
355 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
356 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
357
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
358 QString name = objectName ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
359 QString file
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
360 = QFileDialog::getSaveFileName (this,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
361 tr ("Save Variable %1 As").arg (name),
25062
32a7222d637a [mq]: tr
Rik <rik@octave.org>
parents: 25054
diff changeset
362 // FIXME: Should determine extension from save_default_options
32a7222d637a [mq]: tr
Rik <rik@octave.org>
parents: 25054
diff changeset
363 QString ("./%1.txt").arg (name),
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
364 0, 0,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
365 QFileDialog::DontUseNativeDialog);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
366
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
367 // FIXME: Type? binary, float-binary, ascii, text, hdf5, matlab format?
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
368 // FIXME: Call octave_value::save_* directly?
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
369
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
370 if (! file.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
371 emit command_signal (QString ("save (\"%1\", \"%2\");")
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
372 .arg (file)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
373 .arg (name));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
374 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
375
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
376
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
377 // Custom editable variable table view
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
378
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
379 variable_editor_view::variable_editor_view (QWidget *p)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
380 : QTableView (p), m_var_model (nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
381 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
382 setWordWrap (false);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
383 setContextMenuPolicy (Qt::CustomContextMenu);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
384 setSelectionMode (QAbstractItemView::ContiguousSelection);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
385
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
386 horizontalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
387 verticalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
388
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
389 setHorizontalScrollMode (QAbstractItemView::ScrollPerPixel);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
390 setVerticalScrollMode (QAbstractItemView::ScrollPerPixel);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
391
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24821
diff changeset
392 #if defined (HAVE_QHEADERVIEW_SETSECTIONRESIZEMODE)
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
393 verticalHeader ()->setSectionResizeMode (QHeaderView::Interactive);
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24821
diff changeset
394 #else
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
395 verticalHeader ()->setResizeMode (QHeaderView::Interactive);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
396 #endif
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
397 }
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
398
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
399 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
400 variable_editor_view::setModel (QAbstractItemModel *model)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
401 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
402 QTableView::setModel (model);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
403
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24821
diff changeset
404 #if defined (HAVE_QHEADERVIEW_SETSECTIONRESIZEMODE)
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
405 horizontalHeader ()->setSectionResizeMode (QHeaderView::Interactive);
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24821
diff changeset
406 #else
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
407 horizontalHeader ()->setResizeMode (QHeaderView::Interactive);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
408 #endif
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
409
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
410 m_var_model = parent ()->findChild<variable_editor_model *> ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
411
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
412 if (m_var_model != nullptr && m_var_model->column_width () > 0)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
413 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
414 // col_width is in characters. The font should be a fixed-width
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
415 // font, so any character will do. If not, you lose!
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
416
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
417 QFontMetrics fm (font ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
418 int w = m_var_model->column_width () * fm.width ('0');
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
419 horizontalHeader ()->setDefaultSectionSize (w);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
420 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
421 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
422
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
423 QList<int>
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
424 variable_editor_view::range_selected (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
425 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
426 QItemSelectionModel *sel = selectionModel ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
427
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
428 // Return early if nothing selected.
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
429 if (! sel->hasSelection ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
430 return QList<int> ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
431
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
432 QList<QModelIndex> indices = sel->selectedIndexes ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
433
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
434 // FIXME: Shouldn't this be keyed to octave_idx_type?
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
435
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
436 int32_t from_row = std::numeric_limits<int32_t>::max ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
437 int32_t to_row = 0;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
438 int32_t from_col = std::numeric_limits<int32_t>::max ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
439 int32_t to_col = 0;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
440
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
441 for (const auto& idx : indices)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
442 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
443 from_row = std::min (from_row, idx.row ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
444 to_row = std::max (to_row, idx.row ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
445 from_col = std::min (from_col, idx.column ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
446 to_col = std::max (to_col, idx.column ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
447 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
448
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
449 QVector<int> vect;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
450 vect << from_row + 1 << to_row + 1 << from_col + 1 << to_col + 1;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
451 QList<int> range = QList<int>::fromVector(vect);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
452
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
453 return range;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
454 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
455
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
456 QString
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
457 variable_editor_view::selected_to_octave (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
458 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
459 QList<int> range = range_selected ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
460 if (range.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
461 return objectName ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
462
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
463 QString rows = idx_to_expr (range.at (0), range.at (1));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
464 QString cols = idx_to_expr (range.at (2), range.at (3));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
465
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
466 // FIXME: Does cell need separate handling? Maybe use '{.,.}'?
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
467
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
468 return QString ("%1(%2, %3)").arg (objectName ()).arg (rows).arg (cols);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
469 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
470
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
471 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
472 variable_editor_view::selected_command_requested (const QString& cmd)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
473 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
474 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
475 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
476
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
477 QString selarg = selected_to_octave ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
478 if (! selarg.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
479 emit command_signal (cmd.arg (selarg));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
480 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
481
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
482 void
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
483 variable_editor_view::add_edit_actions (QMenu *menu,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
484 const QString& qualifier_string)
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
485 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
486 menu->addAction (resource_manager::icon ("edit-cut"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
487 tr ("Cut") + qualifier_string,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
488 this, SLOT (cutClipboard ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
489
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
490 menu->addAction (resource_manager::icon ("edit-copy"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
491 tr ("Copy") + qualifier_string,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
492 this, SLOT (copyClipboard ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
493
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
494 menu->addAction (resource_manager::icon ("edit-paste"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
495 tr ("Paste"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
496 this, SLOT (pasteClipboard ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
497
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
498 // FIXME: Different icon for Paste Table?
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
499
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
500 menu->addAction (resource_manager::icon ("edit-paste"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
501 tr ("Paste Table"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
502 this, SLOT (pasteTableClipboard ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
503
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
504 menu->addSeparator ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
505
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
506 menu->addAction (resource_manager::icon ("edit-delete"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
507 tr ("Clear") + qualifier_string,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
508 this, SLOT (clearContent ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
509
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
510 menu->addAction (resource_manager::icon ("edit-delete"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
511 tr ("Delete") + qualifier_string,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
512 this, SLOT (delete_selected ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
513
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
514 menu->addAction (resource_manager::icon ("document-new"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
515 tr ("Variable from Selection"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
516 this, SLOT (createVariable ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
517 }
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
518
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
519 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
520 variable_editor_view::createContextMenu (const QPoint& qpos)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
521 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
522 QModelIndex index = indexAt (qpos);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
523
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
524 if (index.isValid ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
525 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
526 QMenu *menu = new QMenu (this);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
527
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
528 add_edit_actions (menu, tr (""));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
529
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
530 // FIXME: addAction for sort?
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
531 // FIXME: Add icon for transpose.
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
532
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
533 menu->addAction (tr ("Transpose"), this, SLOT (transposeContent ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
534
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
535 QItemSelectionModel *sel = selectionModel ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
536
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
537 QList<QModelIndex> indices = sel->selectedIndexes ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
538
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
539 if (! indices.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
540 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
541 menu->addSeparator ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
542
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
543 QSignalMapper *plot_mapper = make_plot_mapper (menu);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
544
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
545 connect (plot_mapper, SIGNAL (mapped (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
546 this, SLOT (selected_command_requested (const QString&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
547 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
548
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
549 menu->exec (mapToGlobal (qpos));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
550 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
551 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
552
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
553 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
554 variable_editor_view::createColumnMenu (const QPoint& pt)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
555 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
556 int index = horizontalHeader ()->logicalIndexAt (pt);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
557
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
558 if (index < 0 || index > model ()->columnCount ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
559 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
560
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
561 QList<int> coords = range_selected ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
562
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
563 bool nothingSelected = coords.isEmpty ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
564
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
565 bool whole_columns_selected
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
566 = (nothingSelected
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
567 ? false
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
568 : (coords[0] == 1 && coords[1] == model ()->rowCount ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
569
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
570 bool current_column_selected
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
571 = nothingSelected ? false : (coords[2] <= index+1 && coords[3] > index);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
572
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
573 int column_selection_count
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
574 = nothingSelected ? 0 : (coords[3] - coords[2] + 1);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
575
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
576 if (! whole_columns_selected || ! current_column_selected)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
577 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
578 selectColumn (index);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
579 column_selection_count = 1;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
580 current_column_selected = true;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
581 whole_columns_selected = true;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
582 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
583
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
584 QString column_string
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
585 = tr (column_selection_count > 1 ? " columns" : " column");
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
586
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
587 QMenu *menu = new QMenu (this);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
588
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
589 add_edit_actions (menu, column_string);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
590
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
591 menu->addSeparator ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
592
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
593 QSignalMapper *plot_mapper = make_plot_mapper (menu);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
594
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
595 connect (plot_mapper, SIGNAL (mapped (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
596 this, SLOT (selected_command_requested (const QString&)));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
597
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
598 QPoint menupos = pt;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
599 menupos.setY (horizontalHeader ()->height ());
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
600
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
601 menu->exec (mapToGlobal (menupos));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
602 }
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
603
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
604 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
605 variable_editor_view::createRowMenu (const QPoint& pt)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
606 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
607 int index = verticalHeader ()->logicalIndexAt (pt);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
608
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
609 if (index < 0 || index > model ()->columnCount ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
610 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
611
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
612 QList<int> coords = range_selected ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
613
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
614 bool nothingSelected = coords.isEmpty ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
615
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
616 bool whole_rows_selected
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
617 = (nothingSelected
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
618 ? false
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
619 : (coords[2] == 1 && coords[3] == model ()->columnCount ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
620
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
621 bool current_row_selected
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
622 = (nothingSelected ? false : (coords[0] <= index+1 && coords[1] > index));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
623
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
624 int rowselection_count = nothingSelected ? 0 : (coords[3] - coords[2] + 1);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
625
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
626 if (! whole_rows_selected || ! current_row_selected)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
627 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
628 selectRow (index);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
629 rowselection_count = 1;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
630 current_row_selected = true;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
631 whole_rows_selected = true;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
632 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
633
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
634 QString row_string = tr (rowselection_count > 1 ? " rows" : " row");
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
635
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
636 QMenu *menu = new QMenu (this);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
637
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
638 add_edit_actions (menu, row_string);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
639
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
640 menu->addSeparator ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
641
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
642 QSignalMapper *plot_mapper = make_plot_mapper (menu);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
643
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
644 connect (plot_mapper, SIGNAL (mapped (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
645 this, SLOT (selected_command_requested (const QString&)));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
646
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
647 QPoint menupos = pt;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
648 menupos.setX (verticalHeader ()->width ());
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
649
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
650 // FIXME: What was the intent here?
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
651 // setY (verticalHeader ()->sectionPosition (index+1) +
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
652 // verticalHeader ()->sectionSize (index));
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
653
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
654 menu->exec (mapToGlobal (menupos));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
655 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
656
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
657 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
658 variable_editor_view::createVariable (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
659 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
660 // FIXME: Create unnamed1..n if exist ('unnamed', 'var') is true.
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
661
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
662 selected_command_requested ("unnamed = %1");
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
663 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
664
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
665 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
666 variable_editor_view::transposeContent (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
667 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
668 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
669 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
670
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
671 emit command_signal (QString ("%1 = %1';").arg (objectName ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
672 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
673
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
674 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
675 variable_editor_view::delete_selected (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
676 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
677 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
678 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
679
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
680 QAbstractItemModel *mod = model ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
681 QList<int> coords = range_selected ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
682
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
683 if (coords.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
684 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
685
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
686 bool whole_columns_selected
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
687 = coords[0] == 1 && coords[1] == mod->rowCount ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
688
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
689 bool whole_rows_selected
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
690 = coords[2] == 1 && coords[3] == mod->columnCount ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
691
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
692 // Must be deleting whole columns or whole rows, and not the whole thing.
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
693
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
694 if (whole_columns_selected == whole_rows_selected)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
695 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
696
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
697 if (whole_rows_selected)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
698 mod->removeRows (coords[0], coords[1] - coords[0]);
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
699
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
700 if (whole_columns_selected)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
701 mod->removeColumns (coords[2], coords[3] - coords[2]);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
702 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
703
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
704 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
705 variable_editor_view::clearContent (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
706 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
707 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
708 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
709
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
710 if (m_var_model == nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
711 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
712
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
713 QItemSelectionModel *sel = selectionModel ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
714 QList<QModelIndex> indices = sel->selectedIndexes ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
715
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
716 // FIXME: Use [] for empty cells?
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
717
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
718 for (const auto& idx : indices)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
719 m_var_model->clear_content (idx);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
720 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
721
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
722 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
723 variable_editor_view::cutClipboard (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
724 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
725 copyClipboard ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
726
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
727 clearContent ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
728 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
729
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
730 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
731 variable_editor_view::copyClipboard (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
732 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
733 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
734 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
735
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
736 QItemSelectionModel *sel = selectionModel ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
737 QList<QModelIndex> indices = sel->selectedIndexes ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
738 qSort (indices);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
739
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
740 if (indices.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
741 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
742
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
743 // Convert selected items into TSV format and copy that.
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
744 // Spreadsheet tools should understand that.
24758
09364b41ddb6 allow dynamic resizing of display rows and columns in variable editor
John W. Eaton <jwe@octave.org>
parents: 24708
diff changeset
745
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
746 QAbstractItemModel *mod = model ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
747 QModelIndex previous = indices.first ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
748 QString copy = mod->data (previous).toString ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
749 indices.removeFirst ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
750 foreach (QModelIndex idx, indices)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
751 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
752 copy.push_back (previous.row () != idx.row () ? '\n' : '\t');
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
753 copy.append (mod->data (idx).toString ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
754 previous = idx;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
755 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
756
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
757 QClipboard *clipboard = QApplication::clipboard ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
758 clipboard->setText (copy);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
759 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
760
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
761 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
762 variable_editor_view::pasteClipboard (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
763 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
764 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
765 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
766
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
767 QAbstractItemModel *mod = model ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
768 QItemSelectionModel *sel = selectionModel ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
769 QList<QModelIndex> indices = sel->selectedIndexes ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
770
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
771 QClipboard *clipboard = QApplication::clipboard ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
772 QString text = clipboard->text ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
773
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
774 if (indices.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
775 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
776 if (size () == QSize (1,1))
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
777 mod->setData (mod->index (0,0), text.toDouble ());
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
778 else if (size () == QSize (0,0))
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
779 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
780 mod->insertColumn (0);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
781 mod->insertRow (0);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
782 mod->setData (mod->index (0,0), text.toDouble ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
783 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
784 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
785 else
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
786 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
787 QStringList cells = text.split(QRegExp("\n|\r\n|\r"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
788 int clen = cells.size ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
789 for (int i = 0; i < indices.size (); i++)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
790 mod->setData (indices[i], cells.at (i % clen).toDouble ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
791 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
792 }
24758
09364b41ddb6 allow dynamic resizing of display rows and columns in variable editor
John W. Eaton <jwe@octave.org>
parents: 24708
diff changeset
793
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
794 void variable_editor_view::pasteTableClipboard (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
795 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
796 if (! hasFocus ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
797 return;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
798
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
799 QAbstractItemModel *mod = model ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
800 QItemSelectionModel *sel = selectionModel ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
801 QList<QModelIndex> indices = sel->selectedIndexes ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
802
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
803 QClipboard *clipboard = QApplication::clipboard ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
804 QString text = clipboard->text ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
805
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
806 QPoint start, end;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
807
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
808 QPoint tabsize = QPoint (mod->rowCount (), mod->columnCount ());
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
809
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
810 if (indices.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
811 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
812 start = QPoint (0,0);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
813 end = tabsize;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
814 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
815 else if (indices.size () == 1)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
816 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
817 start = QPoint (indices[0].row (), indices[0].column ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
818 end = tabsize;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
819 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
820 else
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
821 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
822 end = QPoint (0,0);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
823 start = tabsize;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
824
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
825 for (int i = 0; i < indices.size (); i++)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
826 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
827 if (indices[i].column () < start.y ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
828 start.setY (indices[i].column ());
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
829
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
830 if (indices[i].column () > end.y ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
831 end.setY (indices[i].column ());
24758
09364b41ddb6 allow dynamic resizing of display rows and columns in variable editor
John W. Eaton <jwe@octave.org>
parents: 24708
diff changeset
832
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
833 if (indices[i].row () < start.x ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
834 start.setX (indices[i].column ());
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
835
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
836 if (indices[i].row () > end.x ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
837 end.setX (indices[i].column ());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
838 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
839 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
840
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
841 int rownum = 0;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
842 int colnum = 0;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
843
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
844 QStringList rows = text.split ('\n');
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
845 for (const auto& row : rows)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
846 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
847 if (rownum > end.x () - start.x ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
848 continue;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
849
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
850 QStringList cols = row.split ('\t');
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
851 if (cols.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
852 continue;
24758
09364b41ddb6 allow dynamic resizing of display rows and columns in variable editor
John W. Eaton <jwe@octave.org>
parents: 24708
diff changeset
853
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
854 for (const auto& col : cols)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
855 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
856 if (col.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
857 continue;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
858 if (colnum > end.y () - start.y () )
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
859 continue;
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
860
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
861 mod->setData (mod->index (rownum + start.x (),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
862 colnum + start.y ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
863 QVariant (col));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
864
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
865 colnum++;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
866 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
867
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
868 colnum = 0;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
869 rownum++;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
870 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
871 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
872
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
873 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
874 variable_editor_view::handle_horizontal_scroll_action (int action)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
875 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
876 if (action == QAbstractSlider::SliderSingleStepAdd
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
877 || action == QAbstractSlider::SliderPageStepAdd
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
878 || action == QAbstractSlider::SliderToMaximum
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
879 || action == QAbstractSlider::SliderMove)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
880 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
881 if (m_var_model != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
882 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
883 QScrollBar *sb = horizontalScrollBar ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
884
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
885 if (sb && sb->value () == sb->maximum ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
886 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
887 int new_cols = m_var_model->display_columns () + 16;
24758
09364b41ddb6 allow dynamic resizing of display rows and columns in variable editor
John W. Eaton <jwe@octave.org>
parents: 24708
diff changeset
888
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
889 m_var_model->maybe_resize_columns (new_cols);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
890 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
891 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
892 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
893 }
24758
09364b41ddb6 allow dynamic resizing of display rows and columns in variable editor
John W. Eaton <jwe@octave.org>
parents: 24708
diff changeset
894
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
895 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
896 variable_editor_view::handle_vertical_scroll_action (int action)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
897 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
898 if (action == QAbstractSlider::SliderSingleStepAdd
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
899 || action == QAbstractSlider::SliderPageStepAdd
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
900 || action == QAbstractSlider::SliderToMaximum
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
901 || action == QAbstractSlider::SliderMove)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
902 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
903 if (m_var_model != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
904 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
905 QScrollBar *sb = verticalScrollBar ();
24762
ed2d9ef336a7 resize varible editor model on scrollbar actions
John W. Eaton <jwe@octave.org>
parents: 24758
diff changeset
906
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
907 if (sb && sb->value () == sb->maximum ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
908 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
909 int new_rows = m_var_model->display_rows () + 16;
24762
ed2d9ef336a7 resize varible editor model on scrollbar actions
John W. Eaton <jwe@octave.org>
parents: 24758
diff changeset
910
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
911 m_var_model->maybe_resize_rows (new_rows);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
912 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
913 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
914 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
915 }
24762
ed2d9ef336a7 resize varible editor model on scrollbar actions
John W. Eaton <jwe@octave.org>
parents: 24758
diff changeset
916
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
917
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
918 // Gadgets for focus restoration
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
919
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
920 HoverToolButton::HoverToolButton (QWidget *parent)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
921 : QToolButton (parent)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
922 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
923 installEventFilter (this);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
924 }
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
925
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
926 bool HoverToolButton::eventFilter (QObject *obj, QEvent *ev)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
927 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
928 if (ev->type () == QEvent::HoverEnter)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
929 emit hovered_signal ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
930 else if (ev->type () == QEvent::MouseButtonPress ||
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
931 ev->type () == QEvent::MouseButtonPress)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
932 emit popup_shown_signal ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
933
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
934 return QToolButton::eventFilter (obj, ev);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
935 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
936
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
937 ReturnFocusToolButton::ReturnFocusToolButton (QWidget *parent)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
938 : HoverToolButton (parent)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
939 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
940 installEventFilter (this);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
941 }
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
942
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
943 bool ReturnFocusToolButton::eventFilter (QObject *obj, QEvent *ev)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
944 {
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
945
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
946 if (ev->type () == QEvent::MouseButtonRelease && isDown ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
947 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
948 emit about_to_activate ();
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
949
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
950 setDown (false);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
951 QAction *action = defaultAction ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
952 if (action != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
953 action->activate (QAction::Trigger);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
954
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
955 return true;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
956 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
957
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
958 return HoverToolButton::eventFilter (obj, ev);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
959 }
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
960
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
961 ReturnFocusMenu::ReturnFocusMenu (QWidget *parent)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
962 : QMenu (parent)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
963 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
964 installEventFilter (this);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
965 }
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
966
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
967 bool ReturnFocusMenu::eventFilter (QObject *obj, QEvent *ev)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
968 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
969 if (ev->type () == QEvent::MouseButtonRelease && underMouse ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
970 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
971 emit about_to_activate ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
972 }
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
973
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
974 return QMenu::eventFilter (obj, ev);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
975 }
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
976
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
977 // Variable editor.
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
978
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
979 variable_editor::variable_editor (QWidget *p)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
980 : octave_dock_widget (p),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
981 m_main (new QMainWindow ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
982 m_tool_bar (new QToolBar (m_main)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
983 m_default_width (30),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
984 m_default_height (100),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
985 m_add_font_height (0),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
986 m_use_terminal_font (true),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
987 m_alternate_rows (true),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
988 m_stylesheet (""),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
989 m_font (),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
990 m_sel_font (),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
991 m_table_colors (),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
992 m_current_focus_vname (""),
25220
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
993 m_hovered_focus_vname (""),
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
994 m_variable_focus_widget (nullptr)
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
995 {
24832
a16c810b77c8 * variable-editor.cc (ctor): rename object name matching logo name (bug #53260)
Torsten <mttl@mailbox.org>
parents: 24828
diff changeset
996 setObjectName ("VariableEditor");
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
997 set_title (tr ("Variable Editor"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
998 setStatusTip (tr ("Edit variables."));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
999 setWindowIcon (QIcon (":/actions/icons/logo.png"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1000 setAttribute (Qt::WA_AlwaysShowToolTips);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
1001
25091
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1002 m_main->setParent (this);
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1003 // See Octave bug #53409 and https://bugreports.qt.io/browse/QTBUG-55357
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1004 #if (QT_VERSION < 0x050601) || (QT_VERSION >= 0x050701)
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1005 m_main->setDockOptions (QMainWindow::AnimatedDocks |
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1006 QMainWindow::AllowNestedDocks |
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1007 QMainWindow::VerticalTabs);
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1008 #else
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1009 m_main->setDockNestingEnabled (true);
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1010 #endif
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25062
diff changeset
1011
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1012 // Tool Bar.
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1013
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1014 construct_tool_bar ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1015 m_main->addToolBar (m_tool_bar);
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1016
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1017 // Colors.
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1018
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1019 for (int i = 0; i < resource_manager::varedit_color_chars ().length (); i++)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1020 m_table_colors.append (QColor (Qt::white));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1021
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1022 // Use an MDI area that is shrunk to nothing as the central widget.
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1023 // Future feature might be to switch to MDI mode in which the dock
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1024 // area is shrunk to nothing and the widgets live in the MDI window.
24703
28211444585e style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24701
diff changeset
1025
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1026 QMdiArea *central_mdiarea = new QMdiArea (m_main);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1027 central_mdiarea->setMinimumSize (QSize (0, 0));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1028 central_mdiarea->setMaximumSize (QSize (0, 0));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1029 central_mdiarea->resize (QSize (0, 0));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1030 m_main->setCentralWidget (central_mdiarea);
24703
28211444585e style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24701
diff changeset
1031
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1032 setWidget (m_main);
24703
28211444585e style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24701
diff changeset
1033
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1034 connect (this, SIGNAL (command_signal (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1035 p, SLOT (execute_command_in_terminal (const QString&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1036 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1037
25199
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1038 void variable_editor::focusInEvent (QFocusEvent *ev)
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1039 {
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1040 octave_dock_widget::focusInEvent (ev);
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1041
25220
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1042 // set focus to the current variable or most recent if still valid
25199
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1043 QWidget *fw = m_main->focusWidget ();
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1044 if (fw != nullptr)
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1045 fw->setFocus ();
25220
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1046 else if (m_main->isAncestorOf (m_variable_focus_widget))
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1047 m_variable_focus_widget->setFocus ();
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1048 }
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1049
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1050 void variable_editor::focusOutEvent (QFocusEvent *ev)
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1051 {
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1052 // focusWidget() appears lost in transition to/from main window
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1053 m_variable_focus_widget = m_main->focusWidget ();
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1054
07bddddc5856 Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25199
diff changeset
1055 octave_dock_widget::focusOutEvent (ev);
25199
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1056 }
8cff7eceee87 Do Variable Editor focus retention and titlebar highlight properly (bug #53410).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25192
diff changeset
1057
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1058 // Add an action to a menu or the widget itself.
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
1059
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1060 QAction*
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
1061 variable_editor::add_action (QMenu *menu, const QIcon& icon,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
1062 const QString& text,
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1063 const char *member)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1064 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1065 QAction *a;
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
1066
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1067 if (menu)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1068 a = menu->addAction (icon, text, this, member);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1069 else
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1070 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1071 a = new QAction (this);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1072 connect (a, SIGNAL (triggered ()), this, member);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1073 }
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
1074
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1075 addAction (a); // important for shortcut context
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1076 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
1077
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1078 return a;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1079 }
24694
9b4edcc62936 add contextmenu to the tab bar of the variable editor (part bug #53002)
Torsten <mttl@mailbox.org>
parents: 24693
diff changeset
1080
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1081 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1082 variable_editor::edit_variable (const QString& name, const octave_value& val)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1083 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1084 if (m_stylesheet.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1085 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1086 QSettings *settings = resource_manager::get_settings ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1087 notice_settings (settings);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1088 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1089
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1090 QDockWidget *existing_qdw = m_main->findChild<QDockWidget *> (name);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1091 if (existing_qdw != NULL)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1092 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1093 // Already open.
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
1094
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1095 // Put current focused variable out of focus
24975
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1096 if (m_main->focusWidget () != nullptr)
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1097 {
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1098 QFocusEvent event (QEvent::FocusOut, Qt::OtherFocusReason);
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1099 QApplication::sendEvent (m_main->focusWidget (), &event);
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1100 }
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1101
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1102 // Put existing variable in focus and raise
25178
4e79e324f441 Focus variable panel when Variable Editor comes from hidden state (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25168
diff changeset
1103 m_main->parentWidget ()->show ();
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1104 existing_qdw->show ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1105 existing_qdw->raise ();
24975
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1106 existing_qdw->activateWindow ();
25168
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1107 tab_to_front ();
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1108 existing_qdw->setFocus ();
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
1109
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1110 return;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1111 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1112
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1113 variable_dock_widget *page = new variable_dock_widget (this);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1114 page->setObjectName (name);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1115 m_main->addDockWidget (Qt::LeftDockWidgetArea, page);
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1116
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1117 connect (QApplication::instance(), SIGNAL (focusChanged (QWidget *, QWidget *)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1118 page, SLOT (handle_focus_change (QWidget *, QWidget *)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1119 connect (page, SIGNAL (destroyed (QObject *)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1120 this, SLOT (variable_destroyed (QObject *)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1121 connect (page, SIGNAL (variable_focused_signal (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1122 this, SLOT (variable_focused (const QString&)));
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1123
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1124 variable_editor_stack *stack = new variable_editor_stack (page);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1125 stack->setObjectName (name);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1126 page->setWidget (stack);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1127 page->setFocusProxy (stack);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1128
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1129 connect (stack, SIGNAL (command_signal (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1130 this, SIGNAL (command_signal (const QString&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1131 connect (stack, SIGNAL (edit_variable_signal (const QString&, const octave_value&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1132 this, SLOT (edit_variable (const QString&, const octave_value&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1133 connect (this, SIGNAL (level_up_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1134 stack, SLOT (levelUp ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1135 connect (this, SIGNAL (save_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1136 stack, SLOT (save ()));
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1137
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1138 variable_editor_view *edit_view = stack->edit_view ();
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
1139
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1140 edit_view->setObjectName (name);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1141 edit_view->setFont (m_font);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1142 edit_view->setStyleSheet (m_stylesheet);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1143 edit_view->setAlternatingRowColors (m_alternate_rows);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1144 edit_view->verticalHeader ()->setDefaultSectionSize (m_default_height
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1145 + m_add_font_height);
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
1146
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1147 connect (edit_view, SIGNAL (command_signal (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1148 this, SIGNAL (command_signal (const QString&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1149 connect (this, SIGNAL (delete_selected_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1150 edit_view, SLOT (delete_selected ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1151 connect (this, SIGNAL (clear_content_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1152 edit_view, SLOT (clearContent ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1153 connect (this, SIGNAL (copy_clipboard_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1154 edit_view, SLOT (copyClipboard ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1155 connect (this, SIGNAL (paste_clipboard_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1156 edit_view, SLOT (pasteClipboard ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1157 connect (this, SIGNAL (paste_table_clipboard_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1158 edit_view, SLOT (pasteTableClipboard ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1159 connect (this, SIGNAL (selected_command_signal (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1160 edit_view, SLOT (selected_command_requested (const QString&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1161 connect (edit_view->horizontalHeader (),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1162 SIGNAL (customContextMenuRequested (const QPoint&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1163 edit_view, SLOT (createColumnMenu (const QPoint&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1164 connect (edit_view->verticalHeader (),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1165 SIGNAL (customContextMenuRequested (const QPoint&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1166 edit_view, SLOT (createRowMenu (const QPoint&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1167 connect (edit_view, SIGNAL (customContextMenuRequested (const QPoint&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1168 edit_view, SLOT (createContextMenu (const QPoint&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1169 connect (edit_view->horizontalScrollBar (), SIGNAL (actionTriggered (int)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1170 edit_view, SLOT (handle_horizontal_scroll_action (int)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1171 connect (edit_view->verticalScrollBar (), SIGNAL (actionTriggered (int)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1172 edit_view, SLOT (handle_vertical_scroll_action (int)));
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
1173
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1174 variable_editor_model *model =
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1175 new variable_editor_model (name, val, stack);
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
1176
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1177 connect (model, SIGNAL (edit_variable_signal (const QString&, const octave_value&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1178 this, SLOT (edit_variable (const QString&, const octave_value&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1179 connect (model, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1180 this, SLOT (callUpdate (const QModelIndex&, const QModelIndex&)));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1181 connect (this, SIGNAL (refresh_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1182 model, SLOT (update_data_cache ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1183 connect (model, SIGNAL (set_editable_signal (bool)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1184 stack, SLOT (set_editable (bool)));
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1185
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1186 edit_view->setModel (model);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1187 connect (edit_view, SIGNAL (doubleClicked (const QModelIndex&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1188 model, SLOT (double_click (const QModelIndex&)));
24762
ed2d9ef336a7 resize varible editor model on scrollbar actions
John W. Eaton <jwe@octave.org>
parents: 24758
diff changeset
1189
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1190 // Must supply a title for a QLabel to be created. Calling set_title()
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1191 // more than once will add more QLabels. Could change octave_dock_widget
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1192 // to always supply a QLabl (initially empty) and then simply update its
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1193 // contents.
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1194 page->set_title (name);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1195 QLabel *existing_ql = page->titleBarWidget ()->findChild<QLabel *> ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1196 connect (model, SIGNAL (update_label_signal (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1197 existing_ql, SLOT (setText (const QString&)));
24843
bf1bace6d01d Use OS GUI highlight backgroud color for variable editor name label (bug #53274)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24834
diff changeset
1198 existing_ql->setMargin (2);
24669
15fe766fbaf5 set initial size of variable editor columns based on data
John W. Eaton <jwe@octave.org>
parents: 24651
diff changeset
1199
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1200 model->update_data (val);
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
1201
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1202 QList<QTableView *> viewlist = findChildren<QTableView *> ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1203 if (viewlist.size () == 1)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1204 m_tool_bar->setEnabled (true);
24975
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1205
25178
4e79e324f441 Focus variable panel when Variable Editor comes from hidden state (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25168
diff changeset
1206 m_main->parentWidget ()->show ();
24975
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1207 page->show ();
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1208 page->raise ();
241b80a7d8c7 Prevent openvar() crash when called twice with same variable (bug #53411)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24865
diff changeset
1209 page->activateWindow ();
25168
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1210 tab_to_front ();
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1211 page->setFocus ();
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1212 }
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1213
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1214 void
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1215 variable_editor::tab_to_front (void)
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1216 {
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1217 if (parent () != nullptr)
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1218 {
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1219 QList<QTabBar *> barlist = main_win ()->findChildren<QTabBar *> ();
25192
8cc3213f788f clean up variable editor method for style and compiler warnings (bug #53443)
Mike Miller <mtmiller@octave.org>
parents: 25190
diff changeset
1220 QVariant this_value (reinterpret_cast<quintptr> (this));
25168
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1221
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1222 foreach (QTabBar *tbar, barlist)
25192
8cc3213f788f clean up variable editor method for style and compiler warnings (bug #53443)
Mike Miller <mtmiller@octave.org>
parents: 25190
diff changeset
1223 for (int i = 0; i < tbar->count (); i++)
8cc3213f788f clean up variable editor method for style and compiler warnings (bug #53443)
Mike Miller <mtmiller@octave.org>
parents: 25190
diff changeset
1224 if (tbar->tabData (i) == this_value)
25168
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1225 {
25192
8cc3213f788f clean up variable editor method for style and compiler warnings (bug #53443)
Mike Miller <mtmiller@octave.org>
parents: 25190
diff changeset
1226 tbar->setCurrentIndex (i);
8cc3213f788f clean up variable editor method for style and compiler warnings (bug #53443)
Mike Miller <mtmiller@octave.org>
parents: 25190
diff changeset
1227 return;
25168
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1228 }
8c38361718a9 When Variable Editor is tabbed, activate that tab via openvar (bug #53443).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25103
diff changeset
1229 }
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1230 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1231
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1232 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1233 variable_editor::refresh (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1234 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1235 emit refresh_signal ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1236 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1237
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1238 QList<QColor>
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1239 variable_editor::default_colors (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1240 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1241 QList<QColor> colorlist;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1242
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1243 colorlist << qApp->palette ().color (QPalette::WindowText);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1244 colorlist << qApp->palette ().color (QPalette::Base);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1245 colorlist << qApp->palette ().color (QPalette::HighlightedText);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1246 colorlist << qApp->palette ().color (QPalette::Highlight);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1247 colorlist << qApp->palette ().color (QPalette::AlternateBase);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1248
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1249 return colorlist;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1250 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1251
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1252 QStringList
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1253 variable_editor::color_names (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1254 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1255 QStringList output;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1256
25249
65f201566857 Mark missing Variable Editor GUI strings for translation (bug #53526).
Rik <rik@octave.org>
parents: 25220
diff changeset
1257 output << tr("Foreground");
65f201566857 Mark missing Variable Editor GUI strings for translation (bug #53526).
Rik <rik@octave.org>
parents: 25220
diff changeset
1258 output << tr("Background");
65f201566857 Mark missing Variable Editor GUI strings for translation (bug #53526).
Rik <rik@octave.org>
parents: 25220
diff changeset
1259 output << tr("Selected Foreground");
65f201566857 Mark missing Variable Editor GUI strings for translation (bug #53526).
Rik <rik@octave.org>
parents: 25220
diff changeset
1260 output << tr("Selected Background");
65f201566857 Mark missing Variable Editor GUI strings for translation (bug #53526).
Rik <rik@octave.org>
parents: 25220
diff changeset
1261 output << tr("Alternate Background");
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1262
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1263 return output;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1264 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1265
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1266 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1267 variable_editor::callUpdate (const QModelIndex&, const QModelIndex&)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1268 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1269 emit updated ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1270 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1271
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1272 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1273 variable_editor::notice_settings (const QSettings *settings)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1274 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1275 // FIXME: Why use object->tostring->toint? Why not just 100?
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1276
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1277 m_default_width = settings->value ("variable_editor/column_width",
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1278 100).toInt ();
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1279
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1280 m_default_height = settings->value ("variable_editor/row_height",
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1281 10).toInt ();
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1282
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1283 m_alternate_rows = settings->value ("variable_editor/alternate_rows",
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1284 false).toBool ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1285
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1286 QList<QColor> default_colors = resource_manager::varedit_default_colors ();
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1287
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1288 QString class_chars = resource_manager::varedit_color_chars ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1289
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1290 m_use_terminal_font = settings->value ("variable_editor/use_terminal_font",
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1291 true).toBool ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1292
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1293 QString font_name;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1294 int font_size;
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1295
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1296 if (m_use_terminal_font)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1297 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1298 font_name = settings->value ("terminal/fontName", "Courier New").toString ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1299 font_size = settings->value ("terminal/fontSize", 10).toInt ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1300 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1301 else
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1302 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1303 font_name = settings->value ("variable_editor/font_name",
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1304 settings->value ("terminal/fontName",
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1305 "Courier New")).toString ();
24639
1c90b6d357ec more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24633
diff changeset
1306
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1307 font_size = settings->value ("variable_editor/font_size", 10).toInt ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1308 }
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1309
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1310 m_font = QFont (font_name, font_size);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1311
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1312 QFontMetrics fm (m_font);
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1313
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1314 m_add_font_height = fm.height ();
23943
f5b81e587bb5 only enable toolbar of variable editor if a tab is present
Torsten <mttl@mailbox.org>
parents: 23936
diff changeset
1315
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1316 for (int i = 0; i < class_chars.length (); i++)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1317 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1318 QVariant default_var;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1319 if (i < default_colors.length ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1320 default_var = default_colors.at (i);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1321 else
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1322 default_var = QColor ();
24639
1c90b6d357ec more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24633
diff changeset
1323
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1324 QColor setting_color = settings->value ("variable_editor/color_"
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1325 + class_chars.mid (i, 1),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1326 default_var).value<QColor> ();
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1327
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1328 if (i < m_table_colors.length ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1329 m_table_colors.replace (i, setting_color);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1330 }
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1331
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1332 update_colors ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1333
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1334 // Icon size in the toolbar.
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1335
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1336 int icon_size_settings = settings->value ("toolbar_icon_size", 0).toInt ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1337 QStyle *st = style ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1338 int icon_size = st->pixelMetric (QStyle::PM_ToolBarIconSize);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1339
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1340 // FIXME: Magic numbers. Use enum?
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1341
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1342 if (icon_size_settings == 1)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1343 icon_size = st->pixelMetric (QStyle::PM_LargeIconSize);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1344 else if (icon_size_settings == -1)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1345 icon_size = st->pixelMetric (QStyle::PM_SmallIconSize);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1346
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1347 m_tool_bar->setIconSize (QSize (icon_size, icon_size));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1348 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1349
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1350 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1351 variable_editor::closeEvent (QCloseEvent *e)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1352 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1353 emit finished ();
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1354
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1355 octave_dock_widget::closeEvent (e);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1356 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1357
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1358 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1359 variable_editor::variable_destroyed (QObject *)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1360 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1361 QList<variable_dock_widget *> vdwlist = findChildren<variable_dock_widget *> ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1362 if (vdwlist.isEmpty ())
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1363 m_tool_bar->setEnabled (false);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1364 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1365
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1366 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1367 variable_editor::variable_focused (const QString &name)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1368 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1369 m_current_focus_vname = name;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1370 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1371
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1372 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1373 variable_editor::record_hovered_focus_variable (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1374 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1375 m_hovered_focus_vname = m_current_focus_vname;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1376 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1377
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1378 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1379 variable_editor::restore_hovered_focus_variable (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1380 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1381 variable_dock_widget *tofocus = findChild<variable_dock_widget *> (m_hovered_focus_vname);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1382 if (tofocus != nullptr)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1383 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1384 // Note that this may be platform and window system dependent.
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1385 // On a particular Linux system, activateWindow() alone didn't
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1386 // immediately set the active window and there was a race
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1387 // between the window focus and action signal. Setting the
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1388 // active window via the QApplication route did work.
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1389 QApplication::setActiveWindow(tofocus->window());
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1390 tofocus->activateWindow ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1391 tofocus->setFocus (Qt::OtherFocusReason);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1392 }
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1393 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1394
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1395 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1396 variable_editor::save (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1397 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1398 emit save_signal ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1399 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1400
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1401 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1402 variable_editor::cutClipboard (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1403 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1404 copyClipboard ();
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1405
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1406 emit clear_content_signal ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1407 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1408
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1409 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1410 variable_editor::copyClipboard (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1411 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1412 emit copy_clipboard_signal ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1413 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1414
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1415 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1416 variable_editor::pasteClipboard (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1417 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1418 emit paste_clipboard_signal ();
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1419
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1420 emit updated ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1421 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1422
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1423 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1424 variable_editor::pasteTableClipboard (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1425 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1426 emit paste_table_clipboard_signal ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1427
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1428 emit updated ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1429 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1430
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1431 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1432 variable_editor::levelUp (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1433 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1434 emit level_up_signal ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1435 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1436
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1437 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1438 variable_editor::relay_selected_command (const QString& cmd)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1439 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1440 emit selected_command_signal (cmd);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1441 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1442
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1443 // Also updates the font.
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1444
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1445 void variable_editor::update_colors (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1446 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1447 m_stylesheet = "";
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1448
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1449 if (m_table_colors.length () > 0)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1450 m_stylesheet += "QTableView::item{ foreground-color: "
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
1451 + m_table_colors[0].name () +" }";
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1452
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1453 if (m_table_colors.length () > 1)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1454 m_stylesheet += "QTableView::item{ background-color: "
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
1455 + m_table_colors[1].name () +" }";
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1456
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1457 if (m_table_colors.length () > 2)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1458 m_stylesheet += "QTableView::item{ selection-color: "
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
1459 + m_table_colors[2].name () +" }";
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1460
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1461 if (m_table_colors.length () > 3)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1462 m_stylesheet += "QTableView::item:selected{ background-color: "
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
1463 + m_table_colors[3].name () +" }";
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1464
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1465 if (m_table_colors.length () > 4 && m_alternate_rows)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1466 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1467 m_stylesheet
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1468 += "QTableView::item:alternate{ background-color: "
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1469 + m_table_colors[4].name () +" }";
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1470
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1471 m_stylesheet
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1472 += "QTableView::item:alternate:selected{ background-color: "
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1473 + m_table_colors[3].name () +" }";
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1474 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1475
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1476 QList<QTableView *> viewlist = findChildren<QTableView *> ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1477 for (int i = 0; i < viewlist.size (); i++)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1478 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1479 QTableView *view = viewlist.at (i);
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
1480
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1481 if (! view)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1482 continue;
24697
21d6d80ed427 refactor variable editor model internal representation (bug #53054)
John W. Eaton <jwe@octave.org>
parents: 24694
diff changeset
1483
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1484 view->setAlternatingRowColors (m_alternate_rows);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1485 view->setStyleSheet (m_stylesheet);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1486 view->setFont (m_font);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1487 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1488
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1489 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1490
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1491 QAction *
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1492 variable_editor::add_tool_bar_button (const QIcon &icon,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1493 const QString &text,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1494 const QObject *receiver,
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1495 const char *member)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1496 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1497 QAction *action = new QAction (icon, text, this);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1498 connect(action, SIGNAL (triggered ()), receiver, member);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1499 QToolButton *button = new ReturnFocusToolButton (m_tool_bar);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1500 button->setDefaultAction (action);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1501 button->setText (text);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1502 button->setToolTip (text);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1503 button->setIcon (icon);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1504 m_tool_bar->addWidget (button);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
1505
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1506 return action;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1507 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
1508
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1509 void
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1510 variable_editor::construct_tool_bar (void)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1511 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1512 m_tool_bar->setAllowedAreas (Qt::TopToolBarArea);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1513
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1514 m_tool_bar->setObjectName ("VariableEditorToolBar");
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1515
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1516 m_tool_bar->setWindowTitle (tr ("Variable Editor Toolbar"));
24703
28211444585e style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24701
diff changeset
1517
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1518 QAction *action;
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1519 action = add_tool_bar_button (resource_manager::icon ("document-save"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1520 tr ("Save"), this, SLOT (save ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1521 action->setShortcuts (QKeySequence::Save);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1522 action->setStatusTip(tr("Save variable to a file"));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1523
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1524 m_tool_bar->addSeparator ();
24029
1d184b55416a Use Octave conventions in variable editor code.
Rik <rik@octave.org>
parents: 24028
diff changeset
1525
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1526 action = add_tool_bar_button (resource_manager::icon ("edit-cut"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1527 tr ("Cut"), this, SLOT (cutClipboard ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1528 action->setStatusTip(tr("Cut data to clipboard"));
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1529
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1530 action = add_tool_bar_button (resource_manager::icon ("edit-copy"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1531 tr ("Copy"), this, SLOT (copyClipboard ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1532 action->setStatusTip(tr("Copy data to clipboard"));
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1533
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1534 action = add_tool_bar_button (resource_manager::icon ("edit-paste"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1535 tr ("Paste"), this, SLOT (pasteClipboard ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1536 action->setStatusTip(tr("Paste clipboard into variable data"));
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1537
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1538 // FIXME: Different icon for Paste Table?
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1539
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1540 action = add_tool_bar_button (resource_manager::icon ("edit-paste"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1541 tr ("Paste Table"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1542 this, SLOT (pasteTableClipboard ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1543 action->setStatusTip(tr("Another paste clipboard into variable data"));
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1544
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1545 m_tool_bar->addSeparator ();
24029
1d184b55416a Use Octave conventions in variable editor code.
Rik <rik@octave.org>
parents: 24028
diff changeset
1546
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1547 // FIXME: Add a print item?
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1548 // QAction *print_action; /icons/fileprint.png
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1549 // m_tool_bar->addSeparator ();
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1550
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1551 action = new QAction (resource_manager::icon ("plot-xy-curve"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1552 tr ("Plot"), m_tool_bar);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1553 action->setToolTip (tr ("Plot Selected Data"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1554 QToolButton *plot_tool_button = new HoverToolButton (m_tool_bar);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1555 plot_tool_button->setDefaultAction (action);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1556
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1557 plot_tool_button->setText (tr ("Plot"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1558 plot_tool_button->setToolTip (tr ("Plot selected data"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1559 plot_tool_button->setIcon (resource_manager::icon ("plot-xy-curve"));
24703
28211444585e style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24701
diff changeset
1560
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1561 plot_tool_button->setPopupMode (QToolButton::InstantPopup);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1562
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1563 QMenu *plot_menu = new ReturnFocusMenu (plot_tool_button);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1564 plot_menu->setTitle (tr ("Plot"));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1565 plot_menu->setSeparatorsCollapsible (false);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1566
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1567 QSignalMapper *plot_mapper = make_plot_mapper (plot_menu);
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1568
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1569 connect (plot_mapper, SIGNAL (mapped (const QString&)),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1570 this, SLOT (relay_selected_command (const QString&)));
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1571
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1572 plot_tool_button->setMenu (plot_menu);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1573
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1574 m_tool_bar->addWidget (plot_tool_button);
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1575
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1576 m_tool_bar->addSeparator ();
24585
8a4aedbb3e5a style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1577
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1578 action = add_tool_bar_button (resource_manager::icon ("go-up"),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1579 tr ("Up"), this, SLOT (levelUp ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1580 action->setStatusTip(tr("Go one level up in variable hierarchy"));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
1581
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1582 // The QToolButton mouse-clicks change active window, so connect all
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1583 // HoverToolButton and RuternFocusToolButton objects to the mechanism
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1584 // that restores active window and focus before acting.
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1585 QList<HoverToolButton *> hbuttonlist
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1586 = m_tool_bar->findChildren<HoverToolButton *> (""
24821
88665923596c Make variable editor code compile under Qt4 (bug #53259)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24812
diff changeset
1587 #if defined (QOBJECT_FINDCHILDREN_ACCEPTS_FINDCHILDOPTIONS)
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1588 , Qt::FindDirectChildrenOnly
24821
88665923596c Make variable editor code compile under Qt4 (bug #53259)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24812
diff changeset
1589 #endif
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1590 );
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1591 for (int i = 0; i < hbuttonlist.size (); i++)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1592 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1593 connect (hbuttonlist.at (i), SIGNAL (hovered_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1594 this, SLOT (record_hovered_focus_variable ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1595 connect (hbuttonlist.at (i), SIGNAL (popup_shown_signal ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1596 this, SLOT (restore_hovered_focus_variable ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1597 }
24821
88665923596c Make variable editor code compile under Qt4 (bug #53259)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24812
diff changeset
1598
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1599 QList<ReturnFocusToolButton *> rfbuttonlist
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1600 = m_tool_bar->findChildren<ReturnFocusToolButton *> (""
24821
88665923596c Make variable editor code compile under Qt4 (bug #53259)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24812
diff changeset
1601 #if defined (QOBJECT_FINDCHILDREN_ACCEPTS_FINDCHILDOPTIONS)
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1602 , Qt::FindDirectChildrenOnly
24821
88665923596c Make variable editor code compile under Qt4 (bug #53259)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24812
diff changeset
1603 #endif
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1604 );
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1605 for (int i = 0; i < rfbuttonlist.size (); i++)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1606 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1607 connect (rfbuttonlist.at (i), SIGNAL (about_to_activate ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1608 this, SLOT (restore_hovered_focus_variable ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1609 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
1610
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1611 // Same for QMenu
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1612 QList<ReturnFocusMenu *> menulist
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1613 = m_tool_bar->findChildren<ReturnFocusMenu *> ();
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1614 for (int i = 0; i < menulist.size (); i++)
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1615 {
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1616 connect (menulist.at (i), SIGNAL (about_to_activate ()),
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1617 this, SLOT (restore_hovered_focus_variable ()));
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1618 }
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24765
diff changeset
1619
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1620 m_tool_bar->setAttribute(Qt::WA_ShowWithoutActivating);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1621 m_tool_bar->setFocusPolicy (Qt::NoFocus);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23978
diff changeset
1622
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1623 // Disabled when no tab is present.
24621
2bb3f3de0b4e more style fixes for variable editor
John W. Eaton <jwe@octave.org>
parents: 24585
diff changeset
1624
24828
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1625 m_tool_bar->setEnabled (false);
0f6a261ab144 move some GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24827
diff changeset
1626 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1627 }