Mercurial > octave-dspies
annotate libgui/src/dialog.cc @ 18607:40dce9423baa gui-release
uigetdir: return correct path name (Bug #42004)
* libgui/src/dialog.cc
(FileDialog::accept): When in dir mode, get the full path name from the selected file.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sun, 30 Mar 2014 20:18:18 -0400 |
parents | 187f3a3429e1 |
children |
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 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 Copyright (C) 2013 John W. Eaton |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 Copyright (C) 2013 Daniel J. Sebald |
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 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 Octave is free software; you can redistribute it and/or modify it |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 under the terms of the GNU General Public License as published by the |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 Free Software Foundation; either version 3 of the License, or (at your |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 option) any later version. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See 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
|
16 for more details. |
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 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 <http://www.gnu.org/licenses/>. |
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 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 #ifdef HAVE_CONFIG_H |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #include <config.h> |
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 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 QUIWidgetCreator uiwidget_creator; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
46 |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 QUIWidgetCreator::QUIWidgetCreator (void) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 : QObject (), dialog_result (-1), dialog_button (), |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
49 string_list (new QStringList ()), list_index (new QIntList ()), |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
50 path_name (new QString ()) |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 { } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 QUIWidgetCreator::~QUIWidgetCreator (void) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 delete string_list; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 delete list_index; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
58 delete path_name; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 void |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
63 QUIWidgetCreator::dialog_button_clicked (QAbstractButton *button) |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 // Store the value so that builtin functions can retrieve. |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
66 if (button) |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
67 dialog_button = button->text (); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
69 // The value should always be 1 for the Octave functions. |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 dialog_result = 1; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 // Wake up Octave process so that it continues. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 waitcondition.wakeAll (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 void |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
78 QUIWidgetCreator::list_select_finished (const QIntList& selected, |
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
79 int 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
|
80 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 // Store the value so that builtin functions can retrieve. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 *list_index = selected; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 dialog_result = button_pressed; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 // Wake up Octave process so that it continues. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 waitcondition.wakeAll (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 void |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
91 QUIWidgetCreator::input_finished (const QStringList& input, int 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
|
92 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 // Store the value so that builtin functions can retrieve. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 *string_list = input; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 dialog_result = button_pressed; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 // Wake up Octave process so that it continues. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 waitcondition.wakeAll (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
101 void |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
102 QUIWidgetCreator::filedialog_finished (const QStringList& files, |
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
103 const QString& path, int filterindex) |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
104 { |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
105 // Store the value so that builtin functions can retrieve. |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
106 *string_list = files; |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
107 dialog_result = filterindex; |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
108 *path_name = path; |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
109 |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
110 // Wake up Octave process so that it continues. |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
111 waitcondition.wakeAll (); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
112 } |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
113 |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
114 |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
116 MessageDialog::MessageDialog (const QString& message, |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
117 const QString& title, |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 const QString& qsicon, |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 const QStringList& qsbutton, |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 const QString& defbutton, |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 const QStringList& role) |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
122 : QMessageBox (QMessageBox::NoIcon, title.isEmpty () ? " " : title, |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
123 message, 0, 0) |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 // Create a NonModal message. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 setWindowModality (Qt::NonModal); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 // Interpret the icon string, because enumeration QMessageBox::Icon can't |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 // easily be made to pass through a signal. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 QMessageBox::Icon eicon = QMessageBox::NoIcon; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 if (qsicon == "error") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 eicon = QMessageBox::Critical; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 else if (qsicon == "warn") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 eicon = QMessageBox::Warning; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 else if (qsicon == "help") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 eicon = QMessageBox::Information; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 else if (qsicon == "quest") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 eicon = QMessageBox::Question; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 setIcon (eicon); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 int N = qsbutton.size () < role.size () ? qsbutton.size () : role.size (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 if (N == 0) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 addButton (QMessageBox::Ok); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 else |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 { |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
146 for (int i = N-1; i >= 0; i--) |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 // Interpret the button role string, because enumeration |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 // QMessageBox::ButtonRole can't be made to pass through a signal. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 QString srole = role.at (i); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 QMessageBox::ButtonRole erole = QMessageBox::InvalidRole; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 if (srole == "YesRole") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 erole = QMessageBox::YesRole; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 else if (srole == "NoRole") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 erole = QMessageBox::NoRole; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 else if (srole == "RejectRole") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 erole = QMessageBox::RejectRole; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 else if (srole == "AcceptRole") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 erole = QMessageBox::AcceptRole; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 QPushButton *pbutton = addButton (qsbutton.at (i), erole); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 if (qsbutton.at (i) == defbutton) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 setDefaultButton (pbutton); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 // Make the last button the button pressed when <esc> key activated. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 if (i == N-1) |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
166 { |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
167 #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
|
168 #if ACTIVE_ESCAPE |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
169 setEscapeButton (pbutton); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
170 #else |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
171 setEscapeButton (0); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
172 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
173 #undef ACTIVE_ESCAPE |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
174 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 connect (this, SIGNAL (buttonClicked (QAbstractButton *)), |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 &uiwidget_creator, SLOT (dialog_button_clicked (QAbstractButton *))); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 ListDialog::ListDialog (const QStringList& list, const QString& mode, |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 int wd, int ht, const QList<int>& initial, |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
185 const QString& title, const QStringList& prompt, |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 const QString& ok_string, const QString& cancel_string) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 : QDialog () |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 // Put the list of items into a model. Keep this off of the stack |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 // because this conceivably could be a very large list. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 QAbstractItemModel *model = new QStringListModel (list); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 QListView *view = new QListView; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 view->setModel (model); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 if (mode == "Single") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 view->setSelectionMode (QAbstractItemView::SingleSelection); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 else if (mode == "Multiple") |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 view->setSelectionMode (QAbstractItemView::ExtendedSelection); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 // else if () |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 // view->setSelectionMode (QAbstractItemView::ContiguousSelection); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 // else if () |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 // view->setSelectionMode (QAbstractItemView::MultiSelection); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 else |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 view->setSelectionMode (QAbstractItemView::NoSelection); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 selector = view->selectionModel (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 int i = 0; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 for (QList<int>::const_iterator it = initial.begin (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 it != initial.end (); it++) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 QModelIndex idx = model->index (initial.value (i++) - 1, 0, |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 QModelIndex ()); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 selector->select (idx, QItemSelectionModel::Select); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 bool fixed_layout = false; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 if (wd > 0 && ht > 0) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 view->setFixedSize (wd, ht); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 fixed_layout = true; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
224 view->setEditTriggers (QAbstractItemView::NoEditTriggers); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
225 |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 QVBoxLayout *listLayout = new QVBoxLayout; |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
227 if (! prompt.isEmpty ()) |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
228 { |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
229 // For now, assume html-like Rich Text. May be incompatible |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
230 // with something down the road, but just testing capability. |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
231 QString prompt_string; |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
232 for (int j = 0; j < prompt.length (); j++) |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
233 { |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
234 if (j > 0) |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
235 #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
|
236 #if RICH_TEXT |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
237 prompt_string.append ("<br>"); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
238 #else |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
239 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
|
240 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
241 prompt_string.append (prompt.at (j)); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
242 } |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
243 QLabel *plabel = new QLabel (prompt_string); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
244 #if RICH_TEXT |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
245 plabel->setTextFormat (Qt::RichText); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
246 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
247 #undef RICH_TEXT |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
248 listLayout->addWidget (plabel); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
249 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 listLayout->addWidget (view); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
251 QPushButton *select_all = new QPushButton (tr ("Select All")); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
252 select_all->setEnabled (mode == "Multiple"); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 listLayout->addWidget (select_all); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 QPushButton *buttonOk = new QPushButton (ok_string); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 QPushButton *buttonCancel = new QPushButton (cancel_string); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 buttonsLayout->addStretch (1); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 buttonsLayout->addWidget (buttonOk); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 buttonsLayout->addWidget (buttonCancel); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 QVBoxLayout *mainLayout = new QVBoxLayout; |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
263 mainLayout->addLayout (listLayout); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 mainLayout->addSpacing (12); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 mainLayout->addLayout (buttonsLayout); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 setLayout (mainLayout); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 if (fixed_layout) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
268 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
|
269 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
270 // If empty, make blank rather than use default OS behavior. |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
271 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
|
272 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 connect (select_all, SIGNAL (clicked ()), |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 view, SLOT (selectAll ())); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 connect (buttonOk, SIGNAL (clicked ()), |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 this, SLOT (buttonOk_clicked ())); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 connect (buttonCancel, SIGNAL (clicked ()), |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 this, SLOT (buttonCancel_clicked ())); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
282 connect (this, SIGNAL (finish_selection (const QIntList&, int)), |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 &uiwidget_creator, |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
284 SLOT (list_select_finished (const QIntList&, int))); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 void |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
289 ListDialog::buttonOk_clicked (void) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
291 // Store information about what button was pressed so that builtin |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
292 // functions can retrieve. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 QModelIndexList selected_index = selector->selectedIndexes (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 QIntList selected_int; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 for (int i = 0; i < selected_index.size (); i++) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 selected_int << selected_index.at (i).row () + 1; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 emit finish_selection (selected_int, 1); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 done (QDialog::Accepted); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 void |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 ListDialog::buttonCancel_clicked (void) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 // Store information about what button was pressed so that builtin |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 // functions can retrieve. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 QIntList empty; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
311 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 emit finish_selection (empty, 0); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 done (QDialog::Rejected); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 void |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 ListDialog::reject (void) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
321 buttonCancel_clicked (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 InputDialog::InputDialog (const QStringList& prompt, const QString& title, |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
326 const QFloatList& nr, const QFloatList& nc, |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 const QStringList& defaults) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 : QDialog () |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
331 #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
|
332 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
333 #if LINE_EDIT_FOLLOWS_PROMPT |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
334 // Prompt on left followed by input on right. |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
335 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
|
336 #else |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
337 // Prompt aligned above input. |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
338 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
|
339 #endif |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
340 int N_gridrows = prompt.size (); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
341 for (int i = 0; i < N_gridrows; i++) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
342 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
343 QLabel *label = new QLabel (prompt.at (i)); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
344 QLineEdit *line_edit = new QLineEdit (defaults.at (i)); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
345 if (nr.at (i) > 0) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
346 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
347 QSize qsize = line_edit->sizeHint (); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
348 int intval = qsize.height () * nr.at (i); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
349 line_edit->setFixedHeight (intval); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
350 if (nc.at (i) > 0) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
351 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
352 intval = qsize.height () * nc.at (i) / 2; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
353 line_edit->setFixedWidth (intval); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
354 } |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
355 } |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
356 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
|
357 #if LINE_EDIT_FOLLOWS_PROMPT |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
358 promptInputLayout->addWidget (label, i + 1, 0); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
359 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
|
360 #else |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
361 promptInputLayout->addWidget (label); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
362 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
|
363 #endif |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
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 #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
|
366 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
367 QPushButton *buttonOk = new QPushButton ("OK"); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
368 QPushButton *buttonCancel = new QPushButton ("Cancel"); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
369 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
370 buttonsLayout->addStretch (1); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
371 buttonsLayout->addWidget (buttonOk); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
372 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
|
373 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
374 QVBoxLayout *mainLayout = new QVBoxLayout; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
375 mainLayout->addLayout (promptInputLayout); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
376 mainLayout->addSpacing (12); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
377 mainLayout->addLayout (buttonsLayout); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
378 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
|
379 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
380 // If empty, make blank rather than use default OS behavior. |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
381 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
|
382 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
383 connect (buttonOk, SIGNAL (clicked ()), |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
384 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
|
385 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
386 connect (buttonCancel, SIGNAL (clicked ()), |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
387 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
|
388 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
389 connect (this, SIGNAL (finish_input (const QStringList&, int)), |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
390 &uiwidget_creator, |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
391 SLOT (input_finished (const QStringList&, int))); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
395 void |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 InputDialog::buttonOk_clicked (void) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
397 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 // Store information about what button was pressed so that builtin |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 // functions can retrieve. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 QStringList string_result; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 for (int i = 0; i < input_line.size (); i++) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 string_result << input_line.at (i)->text (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 emit finish_input (string_result, 1); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
404 done (QDialog::Accepted); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
406 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 void |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 InputDialog::buttonCancel_clicked (void) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
410 // Store information about what button was pressed so that builtin |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 // functions can retrieve. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 QStringList empty; |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 emit finish_input (empty, 0); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 done (QDialog::Rejected); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 } |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
417 |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 void |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 InputDialog::reject (void) |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 { |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
421 buttonCancel_clicked (); |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
423 |
17400
3feff4d08953
dialog.cc: Rename local variables to avoid shadowed variable warning
Rik <rik@octave.org>
parents:
16654
diff
changeset
|
424 FileDialog::FileDialog (const QStringList& name_filters, const QString& title, |
16582 | 425 const QString& filename, const QString& dirname, |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
426 const QString& multimode) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
427 : QFileDialog () |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
428 { |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
429 // Create a NonModal message. |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
430 setWindowModality (Qt::NonModal); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
431 |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
432 setWindowTitle (title.isEmpty () ? " " : title); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
433 setDirectory (dirname); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
434 |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
435 if (multimode == "on") // uigetfile multiselect=on |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
436 { |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
437 setFileMode (QFileDialog::ExistingFiles); |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
438 setAcceptMode (QFileDialog::AcceptOpen); |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
439 } |
16582 | 440 else if (multimode == "create") // uiputfile |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
441 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
442 setFileMode (QFileDialog::AnyFile); |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
443 setAcceptMode (QFileDialog::AcceptSave); |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
444 setOption (QFileDialog::DontConfirmOverwrite, false); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
445 setConfirmOverwrite (true); |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
446 } |
16654
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
16626
diff
changeset
|
447 else if (multimode == "dir") // uigetdir |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
16626
diff
changeset
|
448 { |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
16626
diff
changeset
|
449 setFileMode (QFileDialog::Directory); |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
16626
diff
changeset
|
450 setOption (QFileDialog::ShowDirsOnly, true); |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
16626
diff
changeset
|
451 setOption (QFileDialog::HideNameFilterDetails, true); |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
16626
diff
changeset
|
452 setAcceptMode (QFileDialog::AcceptOpen); |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
16626
diff
changeset
|
453 } |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
454 else // uigetfile multiselect=off |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
455 { |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
456 setFileMode (QFileDialog::ExistingFile); |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
457 setAcceptMode (QFileDialog::AcceptOpen); |
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
458 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
459 |
17400
3feff4d08953
dialog.cc: Rename local variables to avoid shadowed variable warning
Rik <rik@octave.org>
parents:
16654
diff
changeset
|
460 setNameFilters (name_filters); |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
461 |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
462 selectFile (filename); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
463 |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
464 connect (this, |
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
465 SIGNAL (finish_input (const QStringList&, const QString&, int)), |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
466 &uiwidget_creator, |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
467 SLOT (filedialog_finished (const QStringList&, const QString&, |
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
468 int))); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
469 } |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
470 |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
471 void |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
472 FileDialog::reject (void) |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
473 { |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
474 QStringList empty; |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
475 emit finish_input (empty, "", 0); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
476 done (QDialog::Rejected); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
477 |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
478 } |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
479 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
480 void FileDialog::accept (void) |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
481 { |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
482 QStringList string_result; |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
483 QString path; |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
484 int idx = 1; |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
485 |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
486 string_result = selectedFiles (); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
487 |
18607
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
488 if (testOption (QFileDialog::ShowDirsOnly) == true && |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
489 string_result.size () > 0) |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
490 { |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
491 path = string_result[0]; |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
492 } |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
493 else |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
494 { |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
495 path = directory ().absolutePath (); |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
496 } |
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
497 |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
498 // Matlab expects just the file name, whereas the file dialog gave us |
18607
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
499 // full path names, so fix it. |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
500 |
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
501 for (int i = 0; i < string_result.size (); i++) |
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
502 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
|
503 |
18404
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
504 // if not showing only dirs, add end slash for the path component |
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
505 if (testOption (QFileDialog::ShowDirsOnly) == false) |
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
506 path = path + "/"; |
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
507 |
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
508 // convert to native slashes |
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
509 path = QDir::toNativeSeparators (path); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
510 |
17400
3feff4d08953
dialog.cc: Rename local variables to avoid shadowed variable warning
Rik <rik@octave.org>
parents:
16654
diff
changeset
|
511 QStringList name_filters = nameFilters (); |
3feff4d08953
dialog.cc: Rename local variables to avoid shadowed variable warning
Rik <rik@octave.org>
parents:
16654
diff
changeset
|
512 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
|
513 |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
514 // send the selected info |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
515 emit finish_input (string_result, path, idx); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
516 done (QDialog::Accepted); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
517 } |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
518 |