Class Avogadro::QtGui::FileFormatDialog#

class FileFormatDialog : private QFileDialog#

<avogadro/qtgui/fileformatdialog.h>

Allow users to select save/open filenames that can be handled by registered FileFormats.

Unnamed Group

enum FilterStringOption#

Used internally by readFileFilter() and writeFileFilter().

Values:

enumerator NoFilterStringOption#
enumerator AllFormats#
enumerator AllFiles#
enumerator WriteFormats#

Public Types

typedef QPair<const Io::FileFormat*, QString> FormatFilePair#

Container for a filename and a compatible file format, used as return values in static functions.

Note

The FileFormat will be set to nullptr to indicate an error.

Note

The FileFormat points to the reference instance held by the FileFormatManager. Use FileFormat::newInstance() to create a usable copy.

Public Static Functions

static FormatFilePair fileToRead(QWidget *parent, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString())#

Show a QFileDialog to prompt the user for a file to open and resolve any file format conflicts. This method returns the selected file and FileFormat reader.

Parameters:
  • parent – The parent of the dialog windows.

  • caption – The dialog window titles.

  • dir – The initial directory shown to the user.

  • filter – A list of filters for limiting the files shown to the user. See the QFileDialog documentation for format. If the string is empty, a default list of all suitable registered formats will be used.

Returns:

A FormatFilePair object containing the absolute file path and a compatible file reader. If an error occurs, the format pointer will be nullptr.

static FormatFilePair fileToWrite(QWidget *parent, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString())#

Show a QFileDialog to prompt the user for a file to save and resolve any file format conflicts. This method returns the selected file and FileFormat writer.

Parameters:
  • parent – The parent of the dialog windows.

  • caption – The dialog window titles.

  • dir – The initial directory shown to the user.

  • filter – A list of filters for limiting the files shown to the user. See the QFileDialog documentation for format. If the string is empty, a default list of all suitable registered formats will be used.

Returns:

A FormatFilePair object containing the absolute file path and a compatible file writer. If an error occurs, the format pointer will be nullptr.

static const Io::FileFormat *findFileFormat(QWidget *parentWidget, const QString &caption, const QString &fileName, const Io::FileFormat::Operations formatFlags, const QString &formatPrefix = QString())#

Given a filename and a set of Io::FileFormat::Operation flags, find a suitable file format from the FileFormatManager. If multiple readers are found, ask the user to select one. If no suitable format is found, return nullptr.

Parameters:
  • parentWidget – Parent for any dialog windows that will appear.

  • caption – Window title for any dialog windows.

  • fileName – Filename to use when searching for a format. Formats are chosen based on the file extension.

  • formatFlags – Operations that the format must support. Most likely (Io::FileFormat::)Read | File or Write | File.

  • formatPrefix – Filter on the supplied prefix (default to none).

Returns:

The selected matching reader, or nullptr if no reader is found.