Mercurial > octave
annotate libgui/src/dialog.cc @ 24808:abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
* dialog.cc (InputDialog::InputDialog): Check that 'defaults', 'nr' and 'nc'
contain item i before accessing item i.
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Fri, 23 Feb 2018 03:12:20 -0600 |
parents | ea1c88bd4430 |
children | 6652d3823428 |
rev | line source |
---|---|
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2013-2017 John W. Eaton |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
4 Copyright (C) 2013-2016 Daniel J. Sebald |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 This file is part of Octave. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24016
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24016
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
11 (at your option) any later version. |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
16 GNU General Public License for more details. |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 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:
24016
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 */ |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21613
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21213
diff
changeset
|
25 # include "config.h" |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #endif |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #include "dialog.h" |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <QString> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <QStringList> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <QStringListModel> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <QListView> |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
34 #include <QFileInfo> |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 // Could replace most of these with #include <QtGui> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include <QMessageBox> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include <QHBoxLayout> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include <QVBoxLayout> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include <QPushButton> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include <QGroupBox> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include <QGridLayout> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include <QLabel> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
44 namespace octave |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 { |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
46 QUIWidgetCreator uiwidget_creator; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
47 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
48 QUIWidgetCreator::QUIWidgetCreator (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
49 : QObject (), m_dialog_result (-1), m_dialog_button (), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
50 m_string_list (new QStringList ()), m_list_index (new QIntList ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
51 m_path_name (new QString ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
52 { } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
54 QUIWidgetCreator::~QUIWidgetCreator (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
55 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
56 delete m_string_list; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
57 delete m_list_index; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
58 delete m_path_name; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
59 } |
24586
c24b536df5d4
functionality of ui dialogs not affected by inserted accelerators (#bug 52853)
Torsten <mttl@mailbox.org>
parents:
24534
diff
changeset
|
60 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
61 QString QUIWidgetCreator::rm_amp (const QString& text) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
62 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
63 QString text_wo_amp = text; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
64 text_wo_amp.replace (QRegExp ("&(\\w)"), "\\1"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
65 return text_wo_amp; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
66 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
67 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
68 void QUIWidgetCreator::dialog_button_clicked (QAbstractButton *button) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
69 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
70 // Wait for link thread to go to sleep state. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
71 lock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
72 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
73 // Check for a matching button text while ignoring accelerators because |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
74 // the window manager may have added one in the passed button |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
75 QString text_clean = rm_amp (button->text ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
76 for (int i = 0; i < m_button_list.count (); i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
77 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
78 if (rm_amp (m_button_list.at (i)) == text_clean) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
79 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
80 m_dialog_button = m_button_list.at (i); // text w/o extra accelerator |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
81 break; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
82 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
83 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
85 // The value should always be 1 for the Octave functions. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
86 m_dialog_result = 1; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
88 unlock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
89 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
90 // Wake up Octave process so that it continues. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
91 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
92 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
94 void QUIWidgetCreator::list_select_finished (const QIntList& selected, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
95 int button_pressed) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
96 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
97 // Wait for link thread to go to sleep state. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
98 lock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
99 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
100 // Store the value so that builtin functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
101 *m_list_index = selected; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
102 m_dialog_result = button_pressed; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
104 unlock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
105 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
106 // Wake up Octave process so that it continues. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
107 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
108 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
110 void QUIWidgetCreator::input_finished (const QStringList& input, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
111 int button_pressed) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
112 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
113 // Wait for link thread to go to sleep state. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
114 lock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
115 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
116 // Store the value so that builtin functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
117 *m_string_list = input; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
118 m_dialog_result = button_pressed; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
120 unlock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
121 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
122 // Wake up Octave process so that it continues. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
123 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
124 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
126 void QUIWidgetCreator::filedialog_finished (const QStringList& files, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
127 const QString& path, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
128 int filterindex) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
129 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
130 // Wait for link thread to go to sleep state. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
131 lock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
132 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
133 // Store the value so that builtin functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
134 *m_string_list = files; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
135 m_dialog_result = filterindex; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
136 *m_path_name = path; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
137 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
138 unlock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
139 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
140 // Wake up Octave process so that it continues. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
141 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
142 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
143 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
144 MessageDialog::MessageDialog (const QString& message, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
145 const QString& title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
146 const QString& qsicon, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
147 const QStringList& qsbutton, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
148 const QString& defbutton, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
149 const QStringList& role) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
150 : QMessageBox (QMessageBox::NoIcon, title.isEmpty () ? " " : title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
151 message, nullptr, nullptr) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
152 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
153 // Create a NonModal message. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
154 setWindowModality (Qt::NonModal); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
156 // Interpret the icon string, because enumeration QMessageBox::Icon can't |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
157 // easily be made to pass through a signal. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
158 QMessageBox::Icon eicon = QMessageBox::NoIcon; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
159 if (qsicon == "error") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
160 eicon = QMessageBox::Critical; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
161 else if (qsicon == "warn") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
162 eicon = QMessageBox::Warning; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
163 else if (qsicon == "help") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
164 eicon = QMessageBox::Information; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
165 else if (qsicon == "quest") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
166 eicon = QMessageBox::Question; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
167 setIcon (eicon); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
169 int N = (qsbutton.size () < role.size () ? qsbutton.size () : role.size ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
170 if (N == 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
171 addButton (QMessageBox::Ok); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
172 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
173 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
174 for (int i = 0; i < N; i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
175 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
176 // Interpret the button role string, because enumeration |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
177 // QMessageBox::ButtonRole can't be made to pass through a signal. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
178 QString srole = role.at (i); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
179 QMessageBox::ButtonRole erole = QMessageBox::InvalidRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
180 if (srole == "ResetRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
181 erole = QMessageBox::ResetRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
182 else if (srole == "YesRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
183 erole = QMessageBox::YesRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
184 else if (srole == "NoRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
185 erole = QMessageBox::NoRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
186 else if (srole == "RejectRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
187 erole = QMessageBox::RejectRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
188 else if (srole == "AcceptRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
189 erole = QMessageBox::AcceptRole; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
191 QPushButton *pbutton = addButton (qsbutton.at (i), erole); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
192 if (qsbutton.at (i) == defbutton) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
193 setDefaultButton (pbutton); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
194 // Make the last button the button pressed when <esc> key activated. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
195 if (i == N-1) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
196 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
197 // FIXME: Why define and then immediately test value? |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
198 #define ACTIVE_ESCAPE 1 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
199 #if ACTIVE_ESCAPE |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
200 setEscapeButton (pbutton); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
201 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
202 setEscapeButton (0); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
203 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
204 #undef ACTIVE_ESCAPE |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
205 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
206 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
207 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
209 connect (this, SIGNAL (buttonClicked (QAbstractButton *)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
210 &uiwidget_creator, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
211 SLOT (dialog_button_clicked (QAbstractButton *))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
212 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
214 ListDialog::ListDialog (const QStringList& list, const QString& mode, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
215 int wd, int ht, const QList<int>& initial, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
216 const QString& title, const QStringList& prompt, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
217 const QString& ok_string, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
218 const QString& cancel_string) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
219 : QDialog (), m_model (new QStringListModel (list)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
220 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
221 QListView *view = new QListView; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
222 view->setModel (m_model); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
224 if (mode == "single") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
225 view->setSelectionMode (QAbstractItemView::SingleSelection); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
226 else if (mode == "multiple") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
227 view->setSelectionMode (QAbstractItemView::ExtendedSelection); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
228 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
229 view->setSelectionMode (QAbstractItemView::NoSelection); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
231 selector = view->selectionModel (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
232 int i = 0; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
233 for (QList<int>::const_iterator it = initial.begin (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
234 it != initial.end (); it++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
235 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
236 QModelIndex idx = m_model->index (initial.value (i++) - 1, 0, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
237 QModelIndex ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
238 selector->select (idx, QItemSelectionModel::Select); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
239 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
241 bool fixed_layout = false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
242 if (wd > 0 && ht > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
243 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
244 view->setFixedSize (wd, ht); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
245 fixed_layout = true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
246 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
248 view->setEditTriggers (QAbstractItemView::NoEditTriggers); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
249 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
250 QVBoxLayout *listLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
251 if (! prompt.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
252 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
253 // For now, assume html-like Rich Text. May be incompatible |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
254 // with something down the road, but just testing capability. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
255 QString prompt_string; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
256 for (int j = 0; j < prompt.length (); j++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
257 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
258 if (j > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
259 // FIXME: Why define and then immediately test value? |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
260 #define RICH_TEXT 1 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
261 #if RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
262 prompt_string.append ("<br>"); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
263 #else |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
264 prompt_string.append ("\n"); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
265 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
266 prompt_string.append (prompt.at (j)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
267 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
268 QLabel *plabel = new QLabel (prompt_string); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
269 #if RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
270 plabel->setTextFormat (Qt::RichText); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
271 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
272 #undef RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
273 listLayout->addWidget (plabel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
274 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
275 listLayout->addWidget (view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
276 QPushButton *select_all = new QPushButton (tr ("Select All")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
277 select_all->setVisible (mode == "multiple"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
278 listLayout->addWidget (select_all); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
280 QPushButton *buttonOk = new QPushButton (ok_string); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
281 QPushButton *buttonCancel = new QPushButton (cancel_string); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
282 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
283 buttonsLayout->addStretch (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
284 buttonsLayout->addWidget (buttonOk); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
285 buttonsLayout->addWidget (buttonCancel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
286 buttonOk->setDefault (true); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
288 QVBoxLayout *mainLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
289 mainLayout->addLayout (listLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
290 mainLayout->addSpacing (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
291 mainLayout->addLayout (buttonsLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
292 setLayout (mainLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
293 if (fixed_layout) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
294 layout ()->setSizeConstraint (QLayout::SetFixedSize); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
296 // If empty, make blank rather than use default OS behavior. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
297 setWindowTitle (title.isEmpty () ? " " : title); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
299 connect (select_all, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
300 view, SLOT (selectAll ())); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
302 connect (buttonOk, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
303 this, SLOT (buttonOk_clicked ())); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
305 connect (buttonCancel, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
306 this, SLOT (buttonCancel_clicked ())); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
308 connect (this, SIGNAL (finish_selection (const QIntList&, int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
309 &uiwidget_creator, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
310 SLOT (list_select_finished (const QIntList&, int))); |
20505
dd327c0909b0
listdlg: Make appearance and behavior more Matlab compatible (bug #46026)
Mike Miller <mtmiller@octave.org>
parents:
20230
diff
changeset
|
311 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
312 connect (view, SIGNAL (doubleClicked (const QModelIndex&)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
313 this, SLOT (item_double_clicked (const QModelIndex&))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
314 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
316 ListDialog::~ListDialog (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
317 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
318 delete m_model; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
319 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
321 void ListDialog::buttonOk_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
322 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
323 // Store information about what button was pressed so that builtin |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
324 // functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
325 QModelIndexList selected_index = selector->selectedIndexes (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
326 QIntList selected_int; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
328 for (int i = 0; i < selected_index.size (); i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
329 selected_int << selected_index.at (i).row () + 1; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
331 emit finish_selection (selected_int, 1); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
333 done (QDialog::Accepted); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
334 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
335 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
336 void ListDialog::buttonCancel_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
337 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
338 // Store information about what button was pressed so that builtin |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
339 // functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
340 QIntList empty; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
341 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
342 emit finish_selection (empty, 0); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
344 done (QDialog::Rejected); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
345 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
347 void ListDialog::reject (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
348 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
349 buttonCancel_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
350 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
352 void ListDialog::item_double_clicked (const QModelIndex&) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
353 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
354 buttonOk_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
355 } |
20505
dd327c0909b0
listdlg: Make appearance and behavior more Matlab compatible (bug #46026)
Mike Miller <mtmiller@octave.org>
parents:
20230
diff
changeset
|
356 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
357 InputDialog::InputDialog (const QStringList& prompt, const QString& title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
358 const QFloatList& nr, const QFloatList& nc, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
359 const QStringList& defaults) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
360 : QDialog () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
361 { |
24808
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
362 |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
363 #define LINE_EDIT_FOLLOWS_PROMPT 0 |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
365 #if LINE_EDIT_FOLLOWS_PROMPT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
366 // Prompt on left followed by input on right. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
367 QGridLayout *promptInputLayout = new QGridLayout; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
369 // Prompt aligned above input. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
370 QVBoxLayout *promptInputLayout = new QVBoxLayout; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
372 int N_gridrows = prompt.size (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
373 for (int i = 0; i < N_gridrows; i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
374 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
375 QLabel *label = new QLabel (prompt.at (i)); |
24808
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
376 QLineEdit *line_edit = new QLineEdit (); |
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
377 if (i < defaults.size ()) |
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
378 line_edit->setText (defaults.at (i)); |
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
379 if (i < nr.size () && nr.at (i) > 0) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
380 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
381 QSize qsize = line_edit->sizeHint (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
382 int intval = qsize.height () * nr.at (i); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
383 line_edit->setFixedHeight (intval); |
24808
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
384 if (i < nc.size () && nc.at (i) > 0) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
385 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
386 intval = qsize.height () * nc.at (i) / 2; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
387 line_edit->setFixedWidth (intval); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
388 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
389 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
390 input_line << line_edit; |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
391 #if LINE_EDIT_FOLLOWS_PROMPT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
392 promptInputLayout->addWidget (label, i + 1, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
393 promptInputLayout->addWidget (line_edit, i + 1, 1); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
395 promptInputLayout->addWidget (label); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
396 promptInputLayout->addWidget (line_edit); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
397 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
398 } |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
399 #undef LINE_EDIT_FOLLOWS_PROMPT |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
401 QPushButton *buttonOk = new QPushButton ("OK"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
402 QPushButton *buttonCancel = new QPushButton ("Cancel"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
403 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
404 buttonsLayout->addStretch (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
405 buttonsLayout->addWidget (buttonOk); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
406 buttonsLayout->addWidget (buttonCancel); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
408 QVBoxLayout *mainLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
409 mainLayout->addLayout (promptInputLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
410 mainLayout->addSpacing (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
411 mainLayout->addLayout (buttonsLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
412 setLayout (mainLayout); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
414 // If empty, make blank rather than use default OS behavior. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
415 setWindowTitle (title.isEmpty () ? " " : title); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
417 connect (buttonOk, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
418 this, SLOT (buttonOk_clicked ())); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
420 connect (buttonCancel, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
421 this, SLOT (buttonCancel_clicked ())); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
423 connect (this, SIGNAL (finish_input (const QStringList&, int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
424 &uiwidget_creator, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
425 SLOT (input_finished (const QStringList&, int))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
426 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
428 void InputDialog::buttonOk_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
429 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
430 // Store information about what button was pressed so that builtin |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
431 // functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
432 QStringList string_result; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
433 for (int i = 0; i < input_line.size (); i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
434 string_result << input_line.at (i)->text (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
435 emit finish_input (string_result, 1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
436 done (QDialog::Accepted); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
437 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
439 void InputDialog::buttonCancel_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
440 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
441 // Store information about what button was pressed so that builtin |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
442 // functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
443 QStringList empty; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
444 emit finish_input (empty, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
445 done (QDialog::Rejected); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
446 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
448 void InputDialog::reject (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
449 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
450 buttonCancel_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
451 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
452 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
453 FileDialog::FileDialog (const QStringList& name_filters, const QString& title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
454 const QString& filename, const QString& dirname, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
455 const QString& multimode) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
456 : QFileDialog () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
457 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
458 // Create a NonModal message. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
459 setWindowModality (Qt::NonModal); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
460 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
461 setWindowTitle (title.isEmpty () ? " " : title); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
462 setDirectory (dirname); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
463 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
464 if (multimode == "on") // uigetfile multiselect=on |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
465 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
466 setFileMode (QFileDialog::ExistingFiles); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
467 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
468 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
469 else if (multimode == "create") // uiputfile |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
470 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
471 setFileMode (QFileDialog::AnyFile); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
472 setAcceptMode (QFileDialog::AcceptSave); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
473 setOption (QFileDialog::DontConfirmOverwrite, false); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
474 setConfirmOverwrite (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
475 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
476 else if (multimode == "dir") // uigetdir |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
477 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
478 setFileMode (QFileDialog::Directory); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
479 setOption (QFileDialog::ShowDirsOnly, true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
480 setOption (QFileDialog::HideNameFilterDetails, true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
481 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
482 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
483 else // uigetfile multiselect=off |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
484 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
485 setFileMode (QFileDialog::ExistingFile); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
486 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
487 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
488 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
489 setNameFilters (name_filters); |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
490 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
491 selectFile (filename); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
492 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
493 connect (this, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
494 SIGNAL (finish_input (const QStringList&, const QString&, int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
495 &uiwidget_creator, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
496 SLOT (filedialog_finished (const QStringList&, const QString&, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
497 int))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
498 connect (this, SIGNAL (accepted ()), this, SLOT (acceptSelection ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
499 connect (this, SIGNAL (rejected ()), this, SLOT (rejectSelection ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
500 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
501 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
502 void FileDialog::rejectSelection (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
503 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
504 QStringList empty; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
505 emit finish_input (empty, "", 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
506 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
507 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
508 void FileDialog::acceptSelection (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
509 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
510 QStringList string_result; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
511 QString path; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
512 int idx = 1; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
513 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
514 string_result = selectedFiles (); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
515 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
516 if (testOption (QFileDialog::ShowDirsOnly) == true && |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
517 string_result.size () > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
518 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
519 path = string_result[0]; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
520 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
521 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
522 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
523 path = directory ().absolutePath (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
524 } |
18607
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
525 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
526 // Matlab expects just the filename, whereas the file dialog gave us |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
527 // full path names, so fix it. |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
528 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
529 for (int i = 0; i < string_result.size (); i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
530 string_result[i] = QFileInfo (string_result[i]).fileName (); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
531 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
532 // if not showing only dirs, add end slash for the path component |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
533 if (testOption (QFileDialog::ShowDirsOnly) == false) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
534 path += '/'; |
18404
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
535 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
536 // convert to native slashes |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
537 path = QDir::toNativeSeparators (path); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
538 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
539 QStringList name_filters = nameFilters (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
540 idx = name_filters.indexOf (selectedNameFilter ()) + 1; |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
541 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
542 // send the selected info |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
543 emit finish_input (string_result, path, idx); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
544 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
545 } |