# HG changeset patch # User John W. Eaton # Date 1594666642 14400 # Node ID 20ee8aa92897aa52a988bea259b4fdb92eb9c4d4 # Parent 0ecec070c08697f53a8e4552a7dc25a30a34f540 avoid QList deprecated function warnings * libgui/src/qt-utils.h: New file. * libgui/src/module.mk: Update. * qt-interpreter-events.cc: Avoid deprecated QList::fromStdList and QList::toStdList functions. * acinclude.m4 (OCTAVE_CHECK_FUNC_QLIST_ITERATOR_CONSTRUCTOR): New macro. (OCTAVE_CHECK_QT_VERSION): Use it. diff -r 0ecec070c086 -r 20ee8aa92897 libgui/src/module.mk --- a/libgui/src/module.mk Mon Jul 13 12:30:46 2020 -0400 +++ b/libgui/src/module.mk Mon Jul 13 14:57:22 2020 -0400 @@ -222,6 +222,7 @@ %reldir%/octave-qobject.h \ %reldir%/qt-application.h \ %reldir%/qt-interpreter-events.h \ + %reldir%/qt-utils.h \ %reldir%/resource-manager.h \ %reldir%/settings-dialog.h \ %reldir%/shortcut-manager.h \ diff -r 0ecec070c086 -r 20ee8aa92897 libgui/src/qt-interpreter-events.cc --- a/libgui/src/qt-interpreter-events.cc Mon Jul 13 12:30:46 2020 -0400 +++ b/libgui/src/qt-interpreter-events.cc Mon Jul 13 14:57:22 2020 -0400 @@ -38,6 +38,7 @@ #include "gui-preferences-ed.h" #include "octave-qobject.h" #include "qt-interpreter-events.h" +#include "qt-utils.h" #include "localcharset-wrapper.h" #include "oct-env.h" @@ -161,8 +162,8 @@ QStringList lst = m_uiwidget_creator.input_dialog (make_qstring_list (prompt), QString::fromStdString (title), - QFloatList::fromStdList (nr), - QFloatList::fromStdList (nc), + std_list_to_qt_list (nr), + std_list_to_qt_list (nc), make_qstring_list (defaults)); std::list retval; @@ -186,13 +187,15 @@ = m_uiwidget_creator.list_dialog (make_qstring_list (list), QString::fromStdString (mode), width, height, - QList::fromStdList (initial), + std_list_to_qt_list (initial), QString::fromStdString (name), make_qstring_list (prompt), QString::fromStdString (ok_string), QString::fromStdString (cancel_string)); - return std::pair, int> (result.first.toStdList (), + QIntList& lst = result.first; + return std::pair, int> (std::list (lst.begin (), + lst.end ()), result.second); } diff -r 0ecec070c086 -r 20ee8aa92897 libgui/src/qt-utils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/src/qt-utils.h Mon Jul 13 14:57:22 2020 -0400 @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 The Octave Project Developers +// +// See the file COPYRIGHT.md in the top-level directory of this +// distribution or . +// +// This file is part of Octave. +// +// Octave is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Octave is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Octave; see the file COPYING. If not, see +// . +// +//////////////////////////////////////////////////////////////////////// + +#if ! defined (octave_qt_utils_h) +#define octave_qt_utils_h 1 + +#include + +#include + +namespace octave +{ + template + QList + std_list_to_qt_list (const std::list& lst) + { +#if defined (HAVE_QLIST_ITERATOR_CONSTRUCTOR) + return QList (lst.begin (), lst.end ()); +#else + return QList::fromStdList (lst); +#endif + } +} + +#endif diff -r 0ecec070c086 -r 20ee8aa92897 m4/acinclude.m4 --- a/m4/acinclude.m4 Mon Jul 13 12:30:46 2020 -0400 +++ b/m4/acinclude.m4 Mon Jul 13 14:57:22 2020 -0400 @@ -461,6 +461,35 @@ fi ]) dnl +dnl Check whether the Qt class QList has a constructor that accepts +dnl a pair of iterators. This constructor was introduced in Qt 5.14. +dnl +AC_DEFUN([OCTAVE_CHECK_FUNC_QLIST_ITERATOR_CONSTRUCTOR], [ + AC_CACHE_CHECK([for QList::QList (iterator, iterator) constructor], + [octave_cv_func_qlist_iterator_constructor], + [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 + ]], [[ + QList lst_one; + QList lst_two (lst_one.begin (), lst_one.end ()); + ]])], + octave_cv_func_qlist_iterator_constructor=yes, + octave_cv_func_qlist_iterator_constructor=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + CXXFLAGS="$ac_octave_save_CXXFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_func_qlist_iterator_constructor = yes; then + AC_DEFINE(HAVE_QLIST_ITERATOR_CONSTRUCTOR, 1, + [Define to 1 if you have the `QList::QList (iterator, iterator)' constructor.]) + fi +]) +dnl dnl Check whether HDF5 library has version 1.6 API functions. dnl AC_DEFUN([OCTAVE_CHECK_HDF5_HAS_VER_16_API], [ @@ -1763,6 +1792,7 @@ OCTAVE_CHECK_FUNC_QGUIAPPLICATION_SETDESKTOPFILENAME OCTAVE_CHECK_FUNC_QHELPSEARCHQUERYWIDGET_SEARCHINPUT OCTAVE_CHECK_FUNC_QSCREEN_DEVICEPIXELRATIO + OCTAVE_CHECK_FUNC_QLIST_ITERATOR_CONSTRUCTOR if test -n "$OPENGL_LIBS"; then OCTAVE_CHECK_QT_OPENGL_OK([build_qt_graphics=yes],