OpenMS
FileTypeList Class Reference

holds a vector of known file types, e.g. as a way to specify supported input formats More...

#include <OpenMS/FORMAT/FileTypes.h>

Collaboration diagram for FileTypeList:
[legend]

Classes

struct  FilterElements_
 hold filter items (for Qt dialogs) along with their OpenMS type More...
 

Public Member Functions

 FileTypeList (const std::vector< FileTypes::Type > &types)
 
bool contains (const FileTypes::Type &type) const
 check if type is contained in this array More...
 
const std::vector< FileTypes::Type > & getTypes () const
 
String toFileDialogFilter (const FilterLayout style, bool add_all_filter) const
 
FileTypes::Type fromFileDialogFilter (const String &filter, const FileTypes::Type fallback=FileTypes::Type::UNKNOWN) const
 Convert a Qt filter back to a Type if possible. More...
 

Static Public Member Functions

static std::vector< FileTypes::TypetypesWithProperties (const std::vector< FileTypes::FileProperties > features)
 Get a std::vector<FileTypes::Type> with all fileTypes that support a set of features. More...
 

Private Member Functions

FilterElements_ asFilterElements_ (const FilterLayout style, bool add_all_filter) const
 

Private Attributes

std::vector< FileTypes::Typetype_list_
 

Detailed Description

holds a vector of known file types, e.g. as a way to specify supported input formats

The vector can be exported in Qt's file dialog format.


Class Documentation

◆ OpenMS::FileTypeList::FilterElements_

struct OpenMS::FileTypeList::FilterElements_

hold filter items (for Qt dialogs) along with their OpenMS type

Collaboration diagram for FileTypeList::FilterElements_:
[legend]
Class Members
vector< String > items
vector< Type > types

Constructor & Destructor Documentation

◆ FileTypeList()

FileTypeList ( const std::vector< FileTypes::Type > &  types)

Member Function Documentation

◆ asFilterElements_()

FilterElements_ asFilterElements_ ( const FilterLayout  style,
bool  add_all_filter 
) const
private

creates Qt filters and the corresponding elements from type_list_

Parameters
styleCreate a combined filter, or single filters, or both
add_all_filterAdd 'all files (*)' as a single filter at the end?

◆ contains()

bool contains ( const FileTypes::Type type) const

check if type is contained in this array

Referenced by TOPPViewBase::addDataFile().

◆ fromFileDialogFilter()

FileTypes::Type fromFileDialogFilter ( const String filter,
const FileTypes::Type  fallback = FileTypes::Type::UNKNOWN 
) const

Convert a Qt filter back to a Type if possible.

E.g. from a full filter such as '"mzML files (*.mzML);;mzData files (*.mzData);;mzXML files (*.mzXML);;all files (*)"', as created by toFileDialogFilter(), the selected filter could be "mzML files (*.mzML)", in which case the type is Type::MZML . However, for the filter "all files (*)", Type::UNKNOWN will be returned.

If the type is UNKNOWN, then the fallback is returned (by default also UNKNOWN). This is useful if you want a default type to fall back to.

Parameters
filterThe filter returned by 'QFileDialog::getSaveFileName' and others, i.e. an item from the result of 'toFileDialogFilter'.
fallbackIf the filter is ambiguous, return this type instead
Returns
The type associated to the filter or the fallback
Exceptions
Exception::ElementNotFoundif the given filter is not a filter produced by toFileDialogFilter()

◆ getTypes()

const std::vector<FileTypes::Type>& getTypes ( ) const
inline

◆ toFileDialogFilter()

String toFileDialogFilter ( const FilterLayout  style,
bool  add_all_filter 
) const

converts the array into a Qt-compatible filter for selecting files in a user dialog. e.g. "all readable files (*.mzML *.mzXML);;". See Filter enum.

Parameters
styleCreate a combined filter, or single filters, or both
add_all_filterAdd 'all files (*)' as a single filter at the end?

Referenced by TOPPViewBase::chooseFilesDialog_().

◆ typesWithProperties()

static std::vector<FileTypes::Type> typesWithProperties ( const std::vector< FileTypes::FileProperties features)
static

Get a std::vector<FileTypes::Type> with all fileTypes that support a set of features.

Parameters
featuresA set of features that must be supported
Returns
A std::vector<FileTypes::Type> with the files that support features

Member Data Documentation

◆ type_list_

std::vector<FileTypes::Type> type_list_
private