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> 49 :
QObject (), m_dialog_result (-1), m_dialog_button (),
50 m_string_list (new QStringList ()), m_list_index (new
QIntList ()),
51 m_path_name (new QString ())
63 QString text_wo_amp =
text;
64 text_wo_amp.replace (QRegExp (
"&(\\w)"),
"\\1");
75 QString text_clean =
rm_amp (button->text ());
145 const QString& title,
146 const QString& qsicon,
147 const QStringList& qsbutton,
148 const QString& defbutton,
149 const QStringList& role)
154 setWindowModality (Qt::NonModal);
158 QMessageBox::Icon eicon = QMessageBox::NoIcon;
159 if (qsicon ==
"error")
160 eicon = QMessageBox::Critical;
161 else if (qsicon ==
"warn")
162 eicon = QMessageBox::Warning;
163 else if (qsicon ==
"help")
164 eicon = QMessageBox::Information;
165 else if (qsicon ==
"quest")
166 eicon = QMessageBox::Question;
169 int N = (qsbutton.size () < role.size () ? qsbutton.size () : role.size ());
171 addButton (QMessageBox::Ok);
174 for (
int i = 0;
i <
N;
i++)
178 QString srole = role.at (
i);
179 QMessageBox::ButtonRole erole = QMessageBox::InvalidRole;
180 if (srole ==
"ResetRole")
181 erole = QMessageBox::ResetRole;
182 else if (srole ==
"YesRole")
183 erole = QMessageBox::YesRole;
184 else if (srole ==
"NoRole")
185 erole = QMessageBox::NoRole;
186 else if (srole ==
"RejectRole")
187 erole = QMessageBox::RejectRole;
188 else if (srole ==
"AcceptRole")
189 erole = QMessageBox::AcceptRole;
191 QPushButton *pbutton = addButton (qsbutton.at (
i), erole);
192 if (qsbutton.at (
i) == defbutton)
193 setDefaultButton (pbutton);
198 #define ACTIVE_ESCAPE 1 200 setEscapeButton (pbutton);
209 connect (
this, SIGNAL (buttonClicked (QAbstractButton *)),
211 SLOT (dialog_button_clicked (QAbstractButton *)));
216 const QString& title,
const QStringList& prompt,
217 const QString& ok_string,
218 const QString& cancel_string)
219 :
QDialog (), m_model (new QStringListModel (
list))
221 QListView *view =
new QListView;
224 if (
mode ==
"single")
225 view->setSelectionMode (QAbstractItemView::SingleSelection);
226 else if (
mode ==
"multiple")
227 view->setSelectionMode (QAbstractItemView::ExtendedSelection);
229 view->setSelectionMode (QAbstractItemView::NoSelection);
234 it != initial.end (); it++)
236 QModelIndex idx =
m_model->index (initial.value (
i++) - 1, 0,
238 selector->select (idx, QItemSelectionModel::Select);
241 bool fixed_layout =
false;
242 if (wd > 0 && ht > 0)
244 view->setFixedSize (wd, ht);
248 view->setEditTriggers (QAbstractItemView::NoEditTriggers);
250 QVBoxLayout *listLayout =
new QVBoxLayout;
251 if (! prompt.isEmpty ())
255 QString prompt_string;
256 for (
int j = 0; j < prompt.length (); j++)
262 prompt_string.append (
"<br>");
264 prompt_string.append (
"\n");
266 prompt_string.append (prompt.at (j));
268 QLabel *plabel =
new QLabel (prompt_string);
270 plabel->setTextFormat (Qt::RichText);
273 listLayout->addWidget (plabel);
275 listLayout->addWidget (view);
277 select_all->setVisible (
mode ==
"multiple");
278 listLayout->addWidget (select_all);
282 QHBoxLayout *buttonsLayout =
new QHBoxLayout;
283 buttonsLayout->addStretch (1);
284 buttonsLayout->addWidget (buttonOk);
285 buttonsLayout->addWidget (buttonCancel);
286 buttonOk->setDefault (
true);
288 QVBoxLayout *mainLayout =
new QVBoxLayout;
289 mainLayout->addLayout (listLayout);
290 mainLayout->addSpacing (12);
291 mainLayout->addLayout (buttonsLayout);
292 setLayout (mainLayout);
294 layout ()->setSizeConstraint (QLayout::SetFixedSize);
297 setWindowTitle (title.isEmpty () ?
" " : title);
299 connect (select_all, SIGNAL (clicked ()),
300 view, SLOT (selectAll ()));
302 connect (buttonOk, SIGNAL (clicked ()),
305 connect (buttonCancel, SIGNAL (clicked ()),
310 SLOT (list_select_finished (
const QIntList&,
int)));
312 connect (view, SIGNAL (doubleClicked (
const QModelIndex&)),
325 QModelIndexList selected_index =
selector->selectedIndexes ();
328 for (
int i = 0;
i < selected_index.size ();
i++)
329 selected_int << selected_index.at (
i).row () + 1;
333 done (QDialog::Accepted);
344 done (QDialog::Rejected);
359 const QStringList& defaults)
363 #define LINE_EDIT_FOLLOWS_PROMPT 0 365 #if LINE_EDIT_FOLLOWS_PROMPT 367 QGridLayout *promptInputLayout =
new QGridLayout;
370 QVBoxLayout *promptInputLayout =
new QVBoxLayout;
372 int N_gridrows = prompt.size ();
373 for (
int i = 0;
i < N_gridrows;
i++)
375 QLabel *label =
new QLabel (prompt.at (
i));
377 if (
i < defaults.size ())
378 line_edit->setText (defaults.at (
i));
379 if (
i < nr.size () && nr.at (
i) > 0)
381 QSize qsize = line_edit->sizeHint ();
382 int intval = qsize.height () * nr.at (
i);
383 line_edit->setFixedHeight (intval);
384 if (
i < nc.size () && nc.at (
i) > 0)
386 intval = qsize.height () * nc.at (
i) / 2;
387 line_edit->setFixedWidth (intval);
391 #if LINE_EDIT_FOLLOWS_PROMPT 392 promptInputLayout->addWidget (label,
i + 1, 0);
393 promptInputLayout->addWidget (line_edit,
i + 1, 1);
395 promptInputLayout->addWidget (label);
396 promptInputLayout->addWidget (line_edit);
399 #undef LINE_EDIT_FOLLOWS_PROMPT 403 QHBoxLayout *buttonsLayout =
new QHBoxLayout;
404 buttonsLayout->addStretch (1);
405 buttonsLayout->addWidget (buttonOk);
406 buttonsLayout->addWidget (buttonCancel);
408 QVBoxLayout *mainLayout =
new QVBoxLayout;
409 mainLayout->addLayout (promptInputLayout);
410 mainLayout->addSpacing (12);
411 mainLayout->addLayout (buttonsLayout);
412 setLayout (mainLayout);
415 setWindowTitle (title.isEmpty () ?
" " : title);
417 connect (buttonOk, SIGNAL (clicked ()),
420 connect (buttonCancel, SIGNAL (clicked ()),
423 connect (
this, SIGNAL (
finish_input (
const QStringList&,
int)),
425 SLOT (input_finished (
const QStringList&,
int)));
432 QStringList string_result;
436 done (QDialog::Accepted);
445 done (QDialog::Rejected);
455 const QString& multimode)
459 setWindowModality (Qt::NonModal);
461 setWindowTitle (title.isEmpty () ?
" " : title);
464 if (multimode ==
"on")
466 setFileMode (QFileDialog::ExistingFiles);
467 setAcceptMode (QFileDialog::AcceptOpen);
469 else if (multimode ==
"create")
471 setFileMode (QFileDialog::AnyFile);
472 setAcceptMode (QFileDialog::AcceptSave);
473 setOption (QFileDialog::DontConfirmOverwrite,
false);
474 setConfirmOverwrite (
true);
476 else if (multimode ==
"dir")
478 setFileMode (QFileDialog::Directory);
479 setOption (QFileDialog::ShowDirsOnly,
true);
480 setOption (QFileDialog::HideNameFilterDetails,
true);
481 setAcceptMode (QFileDialog::AcceptOpen);
485 setFileMode (QFileDialog::ExistingFile);
486 setAcceptMode (QFileDialog::AcceptOpen);
489 setNameFilters (name_filters);
494 SIGNAL (
finish_input (
const QStringList&,
const QString&,
int)),
496 SLOT (filedialog_finished (
const QStringList&,
const QString&,
510 QStringList string_result;
514 string_result = selectedFiles ();
516 if (testOption (QFileDialog::ShowDirsOnly) ==
true &&
517 string_result.size () > 0)
519 path = string_result[0];
529 for (
int i = 0;
i < string_result.size ();
i++)
530 string_result[
i] = QFileInfo (string_result[
i]).fileName ();
533 if (testOption (QFileDialog::ShowDirsOnly) ==
false)
537 path = QDir::toNativeSeparators (path);
539 QStringList name_filters = nameFilters ();
540 idx = name_filters.indexOf (selectedNameFilter ()) + 1;
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
F77_RET_T const F77_INT & N
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
QItemSelectionModel * selector
std::string dirname(const std::string &path)
QAbstractItemModel * m_model
MessageDialog(const QString &message, const QString &title, const QString &icon, const QStringList &button, const QString &defbutton, const QStringList &role)
void message(const char *name, const char *fmt,...)
void item_double_clicked(const QModelIndex &)
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
void finish_selection(const QIntList &, int)
void finish_input(const QStringList &, const QString &, int)
OCTAVE_EXPORT octave_value_list or cell arrays Arguments are concatenated vertically The returned values are padded with blanks as needed to make each row of the string array have the same length Empty input strings are significant and will concatenated in the output For numerical input
void acceptSelection(void)
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)
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
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
void buttonOk_clicked(void)
void buttonCancel_clicked(void)
QUIWidgetCreator uiwidget_creator
OCTAVE_EXPORT octave_value_list directory
void rejectSelection(void)