Mercurial > hg > octave-shane
changeset 16581:fa4a035e0cf4
Add octave_link uiputfile implementation
* libgui/src/dialog.cc, libgui/src/dialog.h
(FileDialog::FileDialog): Change bool multiselect to QString multimode, add mode option of 'create' and set options accordingly.
(QUIWidgetCreator::signal_filedialog): Change bool multiselect to QString multimode.
(QUIWidgetCreator::create_filedialog): Change bool multiselect to QString multimode.
* libgui/src/main-window.cc, libgui/src/main-window.h
(main_window::connect_uiwidget_links): update bool multiselect to QString multimode.
(main_window::handle_create_filedialog): update bool multiselect to QString multimode.
* libgui/src/octave-qt-link.h
(octave_qt_link::do_file_dialog): update bool multiselect to std::string multimode.
* libinterp/interpfcn/octave-link.h
(octave_link::do_file_dialog): update bool multiselect to std::string multimode.
(octave_link::file_dialog): update bool multiselect to std::string multimode.
* scripts/plot/uiputfile.m
(uiputfile): update to call __octave_link_file_dialog__ if octave_link is present.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sun, 28 Apr 2013 17:00:00 -0400 |
parents | adc150db1809 |
children | 868d0bcfabae |
files | libgui/src/dialog.cc libgui/src/dialog.h libgui/src/main-window.cc libgui/src/main-window.h libgui/src/octave-qt-link.cc libgui/src/octave-qt-link.h libinterp/interpfcn/octave-link.cc libinterp/interpfcn/octave-link.h scripts/plot/uiputfile.m |
diffstat | 9 files changed, 51 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/dialog.cc +++ b/libgui/src/dialog.cc @@ -424,7 +424,7 @@ const QString& title, const QString& filename, const QString& dirname, - bool multiselect) + const QString& multimode) : QFileDialog() { // Create a NonModal message. @@ -433,13 +433,26 @@ setWindowTitle (title.isEmpty () ? " " : title); setDirectory (dirname); - if (multiselect) - setFileMode (QFileDialog::ExistingFiles); - else - setFileMode (QFileDialog::ExistingFile); + if (multimode == "on") // uigetfile multiselect=on + { + setFileMode (QFileDialog::ExistingFiles); + setAcceptMode (QFileDialog::AcceptOpen); + } + else if(multimode == "create") // uiputfile + { + setFileMode (QFileDialog::AnyFile); + setAcceptMode (QFileDialog::AcceptSave); + setOption (QFileDialog::DontConfirmOverwrite, false); + setConfirmOverwrite(true); + } + else // uigetfile multiselect=off + { + setFileMode (QFileDialog::ExistingFile); + setAcceptMode (QFileDialog::AcceptOpen); + } setNameFilters (filters); - setAcceptMode (QFileDialog::AcceptOpen); + selectFile (filename); connect (this,
--- a/libgui/src/dialog.h +++ b/libgui/src/dialog.h @@ -106,9 +106,9 @@ bool signal_filedialog (const QStringList& filters, const QString& title, const QString& filename, const QString& dirname, - bool multiselect) + const QString &multimode) { - emit create_filedialog (filters, title, filename, dirname, multiselect); + emit create_filedialog (filters, title, filename, dirname, multimode); return true; } @@ -135,7 +135,7 @@ void create_filedialog (const QStringList& filters, const QString& title, const QString& filename, const QString& dirname, - bool multiselect); + const QString& multimode); public slots: void dialog_button_clicked (QAbstractButton *button); @@ -253,7 +253,7 @@ explicit FileDialog (const QStringList& filters, const QString& title, const QString& filename, - const QString& dirname, bool multiselect); + const QString& dirname, const QString& multimode); signals:
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -654,11 +654,11 @@ connect (&uiwidget_creator, SIGNAL (create_filedialog (const QStringList &,const QString&, - const QString&, const QString&, bool)), + const QString&, const QString&, const QString&)), this, SLOT (handle_create_filedialog (const QStringList &, const QString&, const QString&, const QString&, - bool))); + const QString&))); } // Create a message dialog with specified string, buttons and decorative @@ -720,10 +720,10 @@ const QString& title, const QString& filename, const QString& dirname, - bool multiselect) + const QString& multimode) { FileDialog *file_dialog = new FileDialog (filters, title, filename, - dirname, multiselect); + dirname, multimode); file_dialog->setAttribute (Qt::WA_DeleteOnClose); file_dialog->show ();
--- a/libgui/src/main-window.h +++ b/libgui/src/main-window.h @@ -160,7 +160,7 @@ void handle_create_filedialog (const QStringList &filters, const QString& title, const QString& filename, const QString &dirname, - bool multiselect); + const QString& multimode); // find files dialog void find_files(const QString &startdir=QDir::currentPath());
--- a/libgui/src/octave-qt-link.cc +++ b/libgui/src/octave-qt-link.cc @@ -226,7 +226,7 @@ const std::string& title, const std::string& filename, const std::string& dirname, - bool multiselect) + const std::string& multimode) { std::list<std::string> retval; @@ -234,7 +234,7 @@ QString::fromStdString (title), QString::fromStdString (filename), QString::fromStdString (dirname), - multiselect); + QString::fromStdString (multimode)); // Wait while the user is responding to dialog. uiwidget_creator.wait ();
--- a/libgui/src/octave-qt-link.h +++ b/libgui/src/octave-qt-link.h @@ -87,7 +87,7 @@ std::list<std::string> do_file_dialog (const filter_list& filter, const std::string& title, const std::string &filename, const std::string &pathname, - bool multiselect); + const std::string& multimode); int do_debug_cd_or_addpath_error (const std::string& file,
--- a/libinterp/interpfcn/octave-link.cc +++ b/libinterp/interpfcn/octave-link.cc @@ -208,7 +208,7 @@ std::string title = args (1).string_value (); std::string filename = args (2).string_value (); Matrix pos = args (3).matrix_value (); - std::string multi_on = args (4).string_value (); // on, off + std::string multi_on = args (4).string_value (); // on, off, create std::string pathname = args (5).string_value (); octave_idx_type nel = flist.numel (); @@ -225,7 +225,7 @@ std::list<std::string> items_lst = octave_link::file_dialog (filter_lst, title, filename, pathname, - multi_on == "on" ? true : false); + multi_on); nel = items_lst.size ();
--- a/libinterp/interpfcn/octave-link.h +++ b/libinterp/interpfcn/octave-link.h @@ -184,10 +184,10 @@ static std::list<std::string> file_dialog (const filter_list& filter, const std::string& title, const std::string& filename, const std::string& dirname, - bool multiselect) + const std::string& multimode) { return enabled () - ? instance->do_file_dialog (filter, title, filename, dirname, multiselect) + ? instance->do_file_dialog (filter, title, filename, dirname, multimode) : std::list<std::string> (); } @@ -386,7 +386,7 @@ virtual std::list<std::string> do_file_dialog (const filter_list& filter, const std::string& title, const std::string& filename, const std::string& dirname, - bool multiselect) = 0; + const std::string& multimode) = 0; virtual int do_debug_cd_or_addpath_error (const std::string& file,
--- a/scripts/plot/uiputfile.m +++ b/scripts/plot/uiputfile.m @@ -56,16 +56,18 @@ function [retfile, retpath, retindex] = uiputfile (varargin) - defaulttoolkit = get (0, "defaultfigure__graphics_toolkit__"); - funcname = ["__uiputfile_", defaulttoolkit, "__"]; - functype = exist (funcname); - if (! __is_function__ (funcname)) - funcname = "__uiputfile_fltk__"; + if (! __octave_link_enabled__ ()) + defaulttoolkit = get (0, "defaultfigure__graphics_toolkit__"); + funcname = ["__uiputfile_", defaulttoolkit, "__"]; + functype = exist (funcname); if (! __is_function__ (funcname)) - error ("uiputfile: fltk graphics toolkit required"); - elseif (! strcmp (defaulttoolkit, "gnuplot")) - warning ("uiputfile: no implementation for toolkit '%s', using 'fltk' instead", + funcname = "__uiputfile_fltk__"; + if (! __is_function__ (funcname)) + error ("uiputfile: fltk graphics toolkit required"); + elseif (! strcmp (defaulttoolkit, "gnuplot")) + warning ("uiputfile: no implementation for toolkit '%s', using 'fltk' instead", defaulttoolkit); + endif endif endif @@ -117,7 +119,11 @@ endif endif - [retfile, retpath, retindex] = feval (funcname, outargs{:}); + if (__octave_link_enabled__ ()) + [retfile, retpath, retindex] = __octave_link_file_dialog__ (outargs{:}); + else + [retfile, retpath, retindex] = feval (funcname, outargs{:}); + endif endfunction