3 * \file FileFilterList.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
12 #ifndef FILE_FILTER_LIST_H
13 #define FILE_FILTER_LIST_H
15 #include "support/docstring.h"
23 /** \c FileFilterList parses a Qt-style list of available file filters
24 * to generate the corresponding vector.
25 * For example "TeX documents (*.tex);;LyX Documents (*.lyx)"
26 * will be parsed to fill a vector of size 2, whilst "*.{p[bgp]m} *.pdf"
27 * will result in a vector of size 1 in which the description field is empty.
29 class FileFilterList {
31 // FIXME UNICODE: globs_ should be unicode...
34 std::vector<std::string> globs_;
36 /* \param description text describing the filters.
37 * \param one or more wildcard patterns, separated by
40 Filter(lyx::docstring const & description,
41 std::string const & globs);
43 lyx::docstring const & description() const { return desc_; }
45 typedef std::vector<std::string>::const_iterator glob_iterator;
46 glob_iterator begin() const { return globs_.begin(); }
47 glob_iterator end() const { return globs_.end(); }
50 /** \param qt_style_filter a list of available file filters.
51 * Eg. "TeX documents (*.tex);;LyX Documents (*.lyx)".
52 * The "All files (*)" filter is always added to the list.
54 explicit FileFilterList(lyx::docstring const & qt_style_filter =
57 typedef std::vector<Filter>::size_type size_type;
59 bool empty() const { return filters_.empty(); }
60 size_type size() const { return filters_.size(); }
61 Filter & operator[](size_type i) { return filters_[i]; }
62 Filter const & operator[](size_type i) const { return filters_[i]; }
64 /** \returns the equivalent of the string passed to the c-tor
65 * although any brace expressions are expanded.
66 * (E.g. "*.{png,jpg}" -> "*.png *.jpg")
68 lyx::docstring const as_string() const;
71 void parse_filter(std::string const & filter);
72 std::vector<Filter> filters_;
75 } // namespace support
78 #endif // NOT FILE_FILTER_LIST_H