Mercurial > octave
changeset 29033:c27ce309c079
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 05 Nov 2020 18:43:39 -0500 |
parents | ba5a0edff85e (current diff) 2cbfd91aafb9 (diff) |
children | 8e6ddf23dcea |
files | libinterp/corefcn/variables.cc m4/acinclude.m4 |
diffstat | 3 files changed, 114 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/documentation.cc Thu Nov 05 12:40:38 2020 -0500 +++ b/libgui/src/documentation.cc Thu Nov 05 18:43:39 2020 -0500 @@ -36,6 +36,9 @@ #include <QFileInfo> #include <QHelpContentWidget> #include <QHelpIndexWidget> +#if defined (HAVE_QHELPLINK) +#include <QHelpLink> +#endif #include <QHelpSearchEngine> #include <QHelpSearchQueryWidget> #include <QHelpSearchResultWidget> @@ -182,6 +185,10 @@ if (m_help_engine) { +#if defined (HAVE_QHELPLINK) + // Help engine uses filters instead of old api since Qt 5.15 + m_help_engine->setUsesFilterEngine (true); +#endif // Layout contents, index and search QTabWidget *navi = new QTabWidget (this); navi->setTabsClosable (false); @@ -227,10 +234,17 @@ navi->addTab (index_all, tr ("Function Index")); +#if defined (HAVE_QHELPLINK) + connect (m_help_engine->indexWidget (), + &QHelpIndexWidget::documentActivated, + this, [this](const QHelpLink &link) { + m_doc_browser->handle_index_clicked (link.url);}); +#else connect(m_help_engine->indexWidget (), SIGNAL (linkActivated (const QUrl&, const QString&)), m_doc_browser, SLOT(handle_index_clicked (const QUrl&, const QString&))); +#endif connect (m_filter, SIGNAL (editTextChanged (const QString&)), this, SLOT(filter_update (const QString&)));
--- a/libinterp/corefcn/variables.cc Thu Nov 05 12:40:38 2020 -0500 +++ b/libinterp/corefcn/variables.cc Thu Nov 05 18:43:39 2020 -0500 @@ -233,26 +233,70 @@ // We shouldn't need to look in the global symbol table, since any name // that is visible in the current scope will be in the local symbol table. - // Command line function which Matlab does not support - if (search_any) - { - octave_value val = symtab.find_cmdline_function (name); - - if (val.is_defined ()) - return 103; - } - if (search_any || search_file || search_dir) { - octave::tree_evaluator& tw = interp.get_evaluator (); + bool have_fcn_ext = false; + + std::string xname = name; + std::string ext; + + size_t pos = name.rfind ('.'); + + if (pos != std::string::npos) + { + ext = name.substr (pos+1); - std::string file_name = tw.lookup_autoload (name); + if (ext == "m" || ext == "oct" || ext == "mex") + { + xname = name.substr (0, pos); + have_fcn_ext = true; + } + } - if (file_name.empty ()) + std::string file_name; + + if (search_any || search_file) { octave::load_path& lp = interp.get_load_path (); - file_name = lp.find_fcn (name); + // Class constructor. + file_name = lp.find_method (xname, xname); + + if (have_fcn_ext && ! file_name.empty ()) + { + pos = file_name.rfind ('.'); + + if (pos != std::string::npos) + { + std::string fext = file_name.substr (pos+1); + + if (ext != fext) + file_name = ""; + } + } + + if (search_any && file_name.empty ()) + { + // Command line function which Matlab does not support + octave_value val = symtab.find_cmdline_function (xname); + + if (val.is_defined ()) + return 103; + } + + // Autoloads can only have simple names without extensions. + + if (! have_fcn_ext && file_name.empty ()) + { + octave::tree_evaluator& tw = interp.get_evaluator (); + + file_name = tw.lookup_autoload (name); + } + + // Use original name here. + + if (file_name.empty ()) + file_name = lp.find_fcn (name); } size_t len = file_name.length (); @@ -303,14 +347,9 @@ return 0; } - if (search_any || search_builtin) - { - if (symtab.is_built_in_function_name (name)) - return 5; - - if (search_builtin) - return 0; - } + if ((search_any || search_builtin) + && symtab.is_built_in_function_name (name)) + return 5; return 0; } @@ -497,6 +536,14 @@ %!assert (exist ("fftw", "file"), 3) %!assert (exist ("fftw", "builtin"), 0) +%!assert (exist ("ftp"), 2); +%!assert (exist ("ftp.m"), 2); +%!assert (exist ("@ftp/ftp"), 2); +%!assert (exist ("@ftp/ftp.m"), 2); + +%!assert (exist ("inputParser"), 2); +%!assert (exist ("inputParser.m"), 2); + %!assert (exist ("sin"), 5) %!assert (exist ("sin", "builtin"), 5) %!assert (exist ("sin", "file"), 0)
--- a/m4/acinclude.m4 Thu Nov 05 12:40:38 2020 -0500 +++ b/m4/acinclude.m4 Thu Nov 05 18:43:39 2020 -0500 @@ -431,6 +431,37 @@ fi ]) dnl +dnl Check whether the structure QtHelpLink is defined. Then, +dnl QHelpIndexWidget emits documentActivates instead of linkActivated. +dnl This structure/signal was introduced in Qt 5.15. +dnl +dnl FIXME: Delete this entirely when we drop support for Qt 5.14 or older. +dnl +AC_DEFUN([OCTAVE_CHECK_FUNC_QHELPLINK], [ + AC_CACHE_CHECK([for QHelpLink], + [octave_cv_func_qhelplink], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + ac_octave_save_CXXFLAGS="$CXXFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS" + CXXFLAGS="$CXXPICFLAG $CPPFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include <QHelpLink> + ]], [[ + QHelpLink link; + ]])], + octave_cv_func_qhelplink=yes, + octave_cv_func_qhelplink=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + CXXFLAGS="$ac_octave_save_CXXFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_func_qhelplink = yes; then + AC_DEFINE(HAVE_QHELPLINK, 1, + [Define to 1 if you have the `QHelpLink' structure.]) + fi +]) +dnl dnl Check whether the Qt class QScreen has the devicePixelRatio member function. dnl This member function was introduced in Qt 5.5. dnl @@ -1863,6 +1894,7 @@ OCTAVE_CHECK_FUNC_QFONTMETRICS_HORIZONTAL_ADVANCE OCTAVE_CHECK_FUNC_QGUIAPPLICATION_SETDESKTOPFILENAME OCTAVE_CHECK_FUNC_QHELPSEARCHQUERYWIDGET_SEARCHINPUT + OCTAVE_CHECK_FUNC_QHELPLINK OCTAVE_CHECK_FUNC_QLIST_ITERATOR_CONSTRUCTOR OCTAVE_CHECK_FUNC_QSCREEN_DEVICEPIXELRATIO