changeset 29053:0678fdb81efc stable

avoid deprecated QHelpEngine::linksForIdentifier function * documentation.cc (void documentation::load_ref): If it is available, call QHelpEngine::documentsForIdentifier instead of QHelpEngine::linksForIdentifier. Adapt to different type of returned object. * acinclude.m4 (OCTAVE_CHECK_FUNC_QHELPENGINE_DOCUMENTSFORIDENTIFIER): New macro. (OCTAVE_CHECK_QT_VERSION): Use it.
author John W. Eaton <jwe@octave.org>
date Thu, 12 Nov 2020 01:21:29 -0500
parents 6ecc75589cbc
children 226df400639c 8f07c47242b8
files libgui/src/documentation.cc m4/acinclude.m4
diffstat 2 files changed, 47 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/documentation.cc	Thu Nov 12 01:17:52 2020 -0500
+++ b/libgui/src/documentation.cc	Thu Nov 12 01:21:29 2020 -0500
@@ -632,14 +632,23 @@
       return;
 
     // First search in the function index
+#if defined (HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER)
+    QList<QHelpLink> found_links
+      = m_help_engine->documentsForIdentifier (ref_name);
+
+    QUrl first_url = found_links.constFirst().url;
+#else
     QMap<QString, QUrl> found_links
       = m_help_engine->linksForIdentifier (ref_name);
 
-    QTabWidget *navi = static_cast<QTabWidget*> (widget (0));
+    QUrl first_url = found_links.constBegin().value ();
+#endif
+
+      QTabWidget *navi = static_cast<QTabWidget*> (widget (0));
 
     if (found_links.count() > 0)
       {
-        m_doc_browser->setSource (found_links.constBegin().value());
+        m_doc_browser->setSource (first_url);
 
         // Switch to function index tab
         m_help_engine->indexWidget()->filterIndices (ref_name);
--- a/m4/acinclude.m4	Thu Nov 12 01:17:52 2020 -0500
+++ b/m4/acinclude.m4	Thu Nov 12 01:21:29 2020 -0500
@@ -830,6 +830,41 @@
   fi
 ])
 dnl
+dnl Check whether the Qt class QHelpEngine has the documentsForIdentifier
+dnl function.  dnl This member function was introduced in Qt 5.15.
+dnl
+AC_DEFUN([OCTAVE_CHECK_FUNC_QHELPENGINE_DOCUMENTSFORIDENTIFIER], [
+  AC_CACHE_CHECK([for QHelpEngine::documentsForIdentifier in <QHelpEngine>],
+    [octave_cv_func_qhelpengine_documentsforidentifier],
+    [AC_LANG_PUSH(C++)
+    ac_octave_save_CPPFLAGS="$CPPFLAGS"
+    ac_octave_save_CXXFLAGS="$CXXFLAGS"
+    CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS"
+    CXXFLAGS="$CXXPICFLAG $CXXFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        #include <QHelpEngine>
+        #include <QHelpLink>
+        #include <QList>
+        #include <QString>
+        #include <QUrl>
+        ]], [[
+        QString collection_file;
+        QHelpEngine eng (collection_file);
+        QString id;
+        eng.documentsForIdentifier (id);
+        ]])],
+      octave_cv_func_qhelpengine_documentsforidentifier=yes,
+      octave_cv_func_qhelpengine_documentsforidentifier=no)
+    CPPFLAGS="$ac_octave_save_CPPFLAGS"
+    CXXFLAGS="$ac_octave_save_CXXFLAGS"
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_func_qhelpengine_documentsforidentifier = yes; then
+    AC_DEFINE(HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER, 1,
+      [Define to 1 if you have the `QHelpEngine::documentsForIdentifier' member function.])
+  fi
+])
+dnl
 dnl Check whether the Qt class QWheelEvent has the angleDelta member function.
 dnl This member function was introduced in Qt 5.
 dnl
@@ -2464,6 +2499,7 @@
     OCTAVE_CHECK_FUNC_QSCREEN_DEVICEPIXELRATIO
     OCTAVE_CHECK_FUNC_QTABWIDGET_SETMOVABLE
     OCTAVE_CHECK_FUNC_QTMESSAGEHANDLER_ACCEPTS_QMESSAGELOGCONTEXT
+    OCTAVE_CHECK_FUNC_QHELPENGINE_DOCUMENTSFORIDENTIFIER
     OCTAVE_CHECK_FUNC_QWHEELEVENT_ANGLEDELTA
     OCTAVE_CHECK_FUNC_QWHEELEVENT_POSITION
     OCTAVE_CHECK_MEMBER_QFONT_FORCE_INTEGER_METRICS