24 #if defined (HAVE_CONFIG_H)
31 #include <QStringList>
32 #include <QStringListModel>
36 #include <QMessageBox>
37 #include <QHBoxLayout>
38 #include <QVBoxLayout>
39 #include <QPushButton>
41 #include <QGridLayout>
48 :
QObject (), dialog_result (-1), dialog_button (),
49 string_list (new QStringList ()), list_index (new
QIntList ()),
50 path_name (new QString ())
114 const QString& path,
int filterindex)
131 const QString& title,
132 const QString& qsicon,
133 const QStringList& qsbutton,
134 const QString& defbutton,
135 const QStringList& role)
140 setWindowModality (Qt::NonModal);
144 QMessageBox::Icon eicon = QMessageBox::NoIcon;
145 if (qsicon ==
"error")
146 eicon = QMessageBox::Critical;
147 else if (qsicon ==
"warn")
148 eicon = QMessageBox::Warning;
149 else if (qsicon ==
"help")
150 eicon = QMessageBox::Information;
151 else if (qsicon ==
"quest")
152 eicon = QMessageBox::Question;
155 int N = qsbutton.size () < role.size () ? qsbutton.size () : role.size ();
157 addButton (QMessageBox::Ok);
160 for (
int i = N-1;
i >= 0;
i--)
164 QString srole = role.at (
i);
165 QMessageBox::ButtonRole erole = QMessageBox::InvalidRole;
166 if (srole ==
"YesRole")
167 erole = QMessageBox::YesRole;
168 else if (srole ==
"NoRole")
169 erole = QMessageBox::NoRole;
170 else if (srole ==
"RejectRole")
171 erole = QMessageBox::RejectRole;
172 else if (srole ==
"AcceptRole")
173 erole = QMessageBox::AcceptRole;
175 QPushButton *pbutton = addButton (qsbutton.at (
i), erole);
176 if (qsbutton.at (
i) == defbutton)
177 setDefaultButton (pbutton);
182 #define ACTIVE_ESCAPE 1
184 setEscapeButton (pbutton);
193 connect (
this, SIGNAL (buttonClicked (QAbstractButton *)),
194 &uiwidget_creator, SLOT (dialog_button_clicked (QAbstractButton *)));
199 const QString& title,
const QStringList& prompt,
200 const QString& ok_string,
const QString& cancel_string)
201 :
QDialog (), model (new QStringListModel (list))
203 QListView *view =
new QListView;
204 view->setModel (
model);
206 if (mode ==
"single")
207 view->setSelectionMode (QAbstractItemView::SingleSelection);
208 else if (mode ==
"multiple")
209 view->setSelectionMode (QAbstractItemView::ExtendedSelection);
211 view->setSelectionMode (QAbstractItemView::NoSelection);
216 it != initial.end (); it++)
218 QModelIndex idx =
model->index (initial.value (i++) - 1, 0,
220 selector->select (idx, QItemSelectionModel::Select);
223 bool fixed_layout =
false;
224 if (wd > 0 && ht > 0)
226 view->setFixedSize (wd, ht);
230 view->setEditTriggers (QAbstractItemView::NoEditTriggers);
232 QVBoxLayout *listLayout =
new QVBoxLayout;
233 if (! prompt.isEmpty ())
237 QString prompt_string;
238 for (
int j = 0; j < prompt.length (); j++)
244 prompt_string.append (
"<br>");
246 prompt_string.append (
"\n");
248 prompt_string.append (prompt.at (j));
250 QLabel *plabel =
new QLabel (prompt_string);
252 plabel->setTextFormat (Qt::RichText);
255 listLayout->addWidget (plabel);
257 listLayout->addWidget (view);
259 select_all->setVisible (mode ==
"multiple");
260 listLayout->addWidget (select_all);
264 QHBoxLayout *buttonsLayout =
new QHBoxLayout;
265 buttonsLayout->addStretch (1);
266 buttonsLayout->addWidget (buttonOk);
267 buttonsLayout->addWidget (buttonCancel);
268 buttonOk->setDefault (
true);
270 QVBoxLayout *mainLayout =
new QVBoxLayout;
271 mainLayout->addLayout (listLayout);
272 mainLayout->addSpacing (12);
273 mainLayout->addLayout (buttonsLayout);
274 setLayout (mainLayout);
276 layout ()->setSizeConstraint (QLayout::SetFixedSize);
279 setWindowTitle (title.isEmpty () ?
" " : title);
281 connect (select_all, SIGNAL (clicked ()),
282 view, SLOT (selectAll ()));
284 connect (buttonOk, SIGNAL (clicked ()),
287 connect (buttonCancel, SIGNAL (clicked ()),
292 SLOT (list_select_finished (
const QIntList&,
int)));
294 connect (view, SIGNAL (doubleClicked (
const QModelIndex&)),
308 QModelIndexList selected_index =
selector->selectedIndexes ();
311 for (
int i = 0;
i < selected_index.size ();
i++)
312 selected_int << selected_index.at (
i).row () + 1;
316 done (QDialog::Accepted);
328 done (QDialog::Rejected);
345 const QStringList& defaults)
349 #define LINE_EDIT_FOLLOWS_PROMPT 0
351 #if LINE_EDIT_FOLLOWS_PROMPT
353 QGridLayout *promptInputLayout =
new QGridLayout;
356 QVBoxLayout *promptInputLayout =
new QVBoxLayout;
358 int N_gridrows = prompt.size ();
359 for (
int i = 0;
i < N_gridrows;
i++)
361 QLabel *label =
new QLabel (prompt.at (
i));
365 QSize qsize = line_edit->sizeHint ();
366 int intval = qsize.height () * nr.at (
i);
367 line_edit->setFixedHeight (intval);
370 intval = qsize.height () * nc.at (
i) / 2;
371 line_edit->setFixedWidth (intval);
375 #if LINE_EDIT_FOLLOWS_PROMPT
376 promptInputLayout->addWidget (label,
i + 1, 0);
377 promptInputLayout->addWidget (line_edit,
i + 1, 1);
379 promptInputLayout->addWidget (label);
380 promptInputLayout->addWidget (line_edit);
383 #undef LINE_EDIT_FOLLOWS_PROMPT
387 QHBoxLayout *buttonsLayout =
new QHBoxLayout;
388 buttonsLayout->addStretch (1);
389 buttonsLayout->addWidget (buttonOk);
390 buttonsLayout->addWidget (buttonCancel);
392 QVBoxLayout *mainLayout =
new QVBoxLayout;
393 mainLayout->addLayout (promptInputLayout);
394 mainLayout->addSpacing (12);
395 mainLayout->addLayout (buttonsLayout);
396 setLayout (mainLayout);
399 setWindowTitle (title.isEmpty () ?
" " : title);
401 connect (buttonOk, SIGNAL (clicked ()),
404 connect (buttonCancel, SIGNAL (clicked ()),
407 connect (
this, SIGNAL (
finish_input (
const QStringList&,
int)),
409 SLOT (input_finished (
const QStringList&,
int)));
417 QStringList string_result;
421 done (QDialog::Accepted);
431 done (QDialog::Rejected);
441 const QString&
filename,
const QString& dirname,
442 const QString& multimode)
446 setWindowModality (Qt::NonModal);
448 setWindowTitle (title.isEmpty () ?
" " : title);
449 setDirectory (dirname);
451 if (multimode ==
"on")
453 setFileMode (QFileDialog::ExistingFiles);
454 setAcceptMode (QFileDialog::AcceptOpen);
456 else if (multimode ==
"create")
458 setFileMode (QFileDialog::AnyFile);
459 setAcceptMode (QFileDialog::AcceptSave);
460 setOption (QFileDialog::DontConfirmOverwrite,
false);
461 setConfirmOverwrite (
true);
463 else if (multimode ==
"dir")
465 setFileMode (QFileDialog::Directory);
466 setOption (QFileDialog::ShowDirsOnly,
true);
467 setOption (QFileDialog::HideNameFilterDetails,
true);
468 setAcceptMode (QFileDialog::AcceptOpen);
472 setFileMode (QFileDialog::ExistingFile);
473 setAcceptMode (QFileDialog::AcceptOpen);
476 setNameFilters (name_filters);
478 selectFile (filename);
481 SIGNAL (
finish_input (
const QStringList&,
const QString&,
int)),
483 SLOT (filedialog_finished (
const QStringList&,
const QString&,
498 QStringList string_result;
502 string_result = selectedFiles ();
504 if (testOption (QFileDialog::ShowDirsOnly) ==
true &&
505 string_result.size () > 0)
507 path = string_result[0];
517 for (
int i = 0;
i < string_result.size ();
i++)
518 string_result[
i] = QFileInfo (string_result[
i]).fileName ();
521 if (testOption (QFileDialog::ShowDirsOnly) ==
false)
525 path = QDir::toNativeSeparators (path);
527 QStringList name_filters = nameFilters ();
528 idx = name_filters.indexOf (selectedNameFilter ()) + 1;
void item_double_clicked(const QModelIndex &)
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
void buttonOk_clicked(void)
void finish_selection(const QIntList &, int)
QItemSelectionModel * selector
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup calculate Y_a and Y _d item Given calculate Y nd enumerate In either initial values for the given components are input
FileDialog(const QStringList &filters, const QString &title, const QString &filename, const QString &dirname, const QString &multimode)
ListDialog(const QStringList &list, const QString &mode, int width, int height, const QList< int > &initial, const QString &name, const QStringList &prompt, const QString &ok_string, const QString &cancel_string)
void rejectSelection(void)
QUIWidgetCreator uiwidget_creator
void message(const char *name, const char *fmt,...)
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
F77_RET_T const F77_INT & N
otherwise an error message is printed The permission mask is a UNIX concept used when creating new objects on a file system such as files
=val(i)}if ode{val(i)}occurs in table i
MessageDialog(const QString &message, const QString &title, const QString &icon, const QStringList &button, const QString &defbutton, const QStringList &role)
void finish_input(const QStringList &, const QString &, int)
void acceptSelection(void)
QAbstractItemModel * model
void buttonCancel_clicked(void)
OCTAVE_EXPORT octave_value_list directory