AvogadroLibs  1.96.0
Public Types | Static Public Member Functions | List of all members
FileFormatDialog Class Reference

#include <fileformatdialog.h>

Inheritance diagram for FileFormatDialog:

Public Types

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

Static Public Member 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. More...
 
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. More...
 
static const Io::FileFormatfindFileFormat (QWidget *parentWidget, const QString &caption, const QString &fileName, const Io::FileFormat::Operations formatFlags, const QString &formatPrefix=QString())
 
enum  FilterStringOption {
  NoFilterStringOption = 0x0 ,
  AllFormats = 0x1 ,
  AllFiles = 0x2 ,
  WriteFormats = 0x4
}
 

Detailed Description

<avogadro/qtgui/fileformatdialog.h>

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

Member Typedef Documentation

◆ FormatFilePair

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.
The FileFormat points to the reference instance held by the FileFormatManager. Use FileFormat::newInstance() to create a usable copy.

Member Enumeration Documentation

◆ FilterStringOption

Used internally by readFileFilter() and writeFileFilter().

Member Function Documentation

◆ fileToRead()

static FormatFilePair fileToRead ( QWidget *  parent,
const QString &  caption = QString(),
const QString &  dir = QString(),
const QString &  filter = QString() 
)
static
Parameters
parentThe parent of the dialog windows.
captionThe dialog window titles.
dirThe initial directory shown to the user.
filterA 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.

◆ fileToWrite()

static FormatFilePair fileToWrite ( QWidget *  parent,
const QString &  caption = QString(),
const QString &  dir = QString(),
const QString &  filter = QString() 
)
static
Parameters
parentThe parent of the dialog windows.
captionThe dialog window titles.
dirThe initial directory shown to the user.
filterA 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.

◆ findFileFormat()

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

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
parentWidgetParent for any dialog windows that will appear.
captionWindow title for any dialog windows.
fileNameFilename to use when searching for a format. Formats are chosen based on the file extension.
formatFlagsOperations that the format must support. Most likely (Io::FileFormat::)Read | File or Write | File.
formatPrefixFilter on the supplied prefix (default to none).
Returns
The selected matching reader, or nullptr if no reader is found.

The documentation for this class was generated from the following file: