Mercurial > octave
changeset 33098:110595642c14 bytecode-interpreter
maint: merge default to bytecode-interpreter.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Tue, 27 Feb 2024 16:45:04 -0500 |
parents | f93c00562f70 (current diff) db71211ac17b (diff) |
children | 445396d7edbb |
files | |
diffstat | 3 files changed, 76 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dock-widget.cc Mon Feb 26 23:31:22 2024 -0500 +++ b/libgui/src/files-dock-widget.cc Tue Feb 27 16:45:04 2024 -0500 @@ -27,6 +27,8 @@ # include "config.h" #endif +#include <map> + #include <QApplication> #include <QClipboard> #include <QCompleter> @@ -39,6 +41,8 @@ #include <QLineEdit> #include <QMenu> #include <QMessageBox> +#include <QMimeDatabase> +#include <QMimeType> #include <QProcess> #include <QSizePolicy> #include <QStyledItemDelegate> @@ -175,6 +179,56 @@ } }; +class cache_file_icon_provider : public QFileIconProvider +{ +public: + cache_file_icon_provider () + { + m_null_icon = QIcon (); + m_file_icon = m_file_icon_provider.icon (QFileIconProvider::File); + m_folder_icon = m_file_icon_provider.icon (QFileIconProvider::Folder); + } + + QIcon icon (IconType ict) const + { + if (ict == QFileIconProvider::File) + return m_file_icon; + else if (ict == QFileIconProvider::Folder) + return m_folder_icon; + else + return m_null_icon; + } + + QIcon icon (const QFileInfo &fi) const + { + static bool no_platform_theme = QIcon::themeName ().isEmpty (); + + if (no_platform_theme) + return m_file_icon_provider.icon (fi); + + QMimeType mime_type = m_db.mimeTypeForFile (fi.absoluteFilePath ()); + QString icon_name = mime_type.iconName (); + auto mime_type_iter = m_icon_cache.find (icon_name); + if (mime_type_iter != m_icon_cache.end ()) + return mime_type_iter->second; + + QIcon icon = QIcon::fromTheme (icon_name); + m_icon_cache.insert ({icon_name, icon}); + return icon; + } + +private: + QIcon m_null_icon; + QIcon m_file_icon; + QIcon m_folder_icon; + + QFileIconProvider m_file_icon_provider; + QMimeDatabase m_db; + static std::map<QString, QIcon> m_icon_cache; +}; + +std::map<QString, QIcon> cache_file_icon_provider::m_icon_cache; + files_dock_widget::files_dock_widget (QWidget *p) : octave_dock_widget ("FilesDockWidget", p) { @@ -313,6 +367,9 @@ QModelIndex rootPathIndex = m_file_system_model->setRootPath (startup_dir.absolutePath ()); + m_file_icon_provider = new cache_file_icon_provider (); + m_file_system_model->setIconProvider (m_file_icon_provider); + // Attach the model to the QTreeView and set the root index m_file_tree_view = new FileTreeViewer (container); m_file_tree_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
--- a/libgui/src/files-dock-widget.h Mon Feb 26 23:31:22 2024 -0500 +++ b/libgui/src/files-dock-widget.h Tue Feb 27 16:45:04 2024 -0500 @@ -29,6 +29,7 @@ #include <QAction> #include <QComboBox> #include <QDate> +#include <QFileIconProvider> #include <QFileSystemModel> #include <QList> #include <QListView> @@ -210,6 +211,7 @@ //! The file system model. QFileSystemModel *m_file_system_model; + QFileIconProvider *m_file_icon_provider; //! The file system view. //!@{
--- a/libinterp/corefcn/load-save.cc Mon Feb 26 23:31:22 2024 -0500 +++ b/libinterp/corefcn/load-save.cc Tue Feb 27 16:45:04 2024 -0500 @@ -1642,12 +1642,13 @@ Force Octave to assume the file is in Octave's binary format. @item -hdf5 -Force Octave to assume the file is in @sc{hdf5} format. -(@sc{hdf5} is a free, portable binary format developed by the National -Center for Supercomputing Applications at the University of Illinois.) -Note that Octave can only read @sc{hdf5} files that were created by itself with -@code{save}. This format is only available if Octave was built with a link to -the @sc{hdf5} libraries. +Force Octave to assume the file is in @sc{hdf5} format. (@sc{hdf5} is a free, +portable binary format developed by the National Center for Supercomputing +Applications at the University of Illinois.) Note that Octave can only +read @sc{hdf5} files that were created by itself with @code{save} or with +@sc{matlab}'s @code{-v7.3} option (which saves in @sc{hdf5} format). This +format is only available if Octave was built with a link to the @sc{hdf5} +libraries. @item -import This option is accepted for backward compatibility but is ignored. @@ -1660,7 +1661,10 @@ @item -v7.3 @itemx -V7.3 @itemx -7.3 -Octave does @strong{not} yet implement @sc{matlab}'s v7.3 binary data format. +Force Octave to assume the file is in @sc{matlab}'s v7.3 binary data format. +As the v7.3 format is an HDF5 based format, those files often can also be +opened with the @qcode{"-hdf5"} option. Note that Octave @strong{can not} +currently save in this format. @item -v7 @itemx -V7 @@ -1754,10 +1758,10 @@ be represented in single precision. @item -hdf5 -Save the data in @sc{hdf5} format. -(HDF5 is a free, portable, binary format developed by the National Center for -Supercomputing Applications at the University of Illinois.) This format is only -available if Octave was built with a link to the @sc{hdf5} libraries. +Save the data in @sc{hdf5} format. (HDF5 is a free, portable, binary format +developed by the National Center for Supercomputing Applications at the +University of Illinois.) This format is only available if Octave was built +with a link to the @sc{hdf5} libraries. @item -float-hdf5 Save the data in @sc{hdf5} format but using only single precision. Use this @@ -1770,7 +1774,8 @@ @item -v7.3 @itemx -V7.3 @itemx -7.3 -Octave does @strong{not} yet implement @sc{matlab}'s v7.3 binary data format. +Octave does @strong{not} yet implement saving in @sc{matlab}'s v7.3 binary +data format. @item -v7 @itemx -V7