File indexing completed on 2024-04-14 14:36:00

0001 /************************************************************************
0002  *                                  *
0003  *  This file is part of Kooka, a scanning/OCR application using    *
0004  *  Qt <http://www.qt.io> and KDE Frameworks <http://www.kde.org>.  *
0005  *                                  *
0006  *  Copyright (C) 2016 Jonathan Marten <jjm@keelhaul.me.uk>     *
0007  *                                  *
0008  *  Kooka is free software; you can redistribute it and/or modify it    *
0009  *  under the terms of the GNU Library General Public License as    *
0010  *  published by the Free Software Foundation and appearing in the  *
0011  *  file COPYING included in the packaging of this file;  either    *
0012  *  version 2 of the License, or (at your option) any later version.    *
0013  *                                  *
0014  *  As a special exception, permission is given to link this program    *
0015  *  with any version of the KADMOS OCR/ICR engine (a product of     *
0016  *  reRecognition GmbH, Kreuzlingen), and distribute the resulting  *
0017  *  executable without including the source code for KADMOS in the  *
0018  *  source distribution.                        *
0019  *                                  *
0020  *  This program is distributed in the hope that it will be useful, *
0021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of  *
0022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *
0023  *  GNU General Public License for more details.            *
0024  *                                  *
0025  *  You should have received a copy of the GNU General Public       *
0026  *  License along with this program;  see the file COPYING.  If     *
0027  *  not, see <http://www.gnu.org/licenses/>.                *
0028  *                                  *
0029  ************************************************************************/
0030 
0031 #ifndef IMAGEFILTER_H
0032 #define IMAGEFILTER_H
0033 
0034 #include <qstringlist.h>
0035 
0036 #include "libdialogutil_export.h"
0037 
0038 
0039 /**
0040  * @short Generation of a filter string for image selection or saving.
0041  *
0042  * This class generates a filter suitable to use with either Qt or
0043  * KDE Frameworks file dialogues.  Although @c KFileDialog is deprecated
0044  * in Frameworks, a KDE filter is still required for a @c KUrlRequester
0045  * or if KFileWidget is used directly.
0046  *
0047  * @author Jonathan Marten
0048  **/
0049 
0050 namespace ImageFilter
0051 {
0052     /**
0053      * Enumeration specifying the intended use of the filter.
0054      **/
0055     enum FilterMode
0056     {
0057         Reading = 0x01,                 ///< Image reading
0058         Writing = 0x02                  ///< Image writing
0059     };
0060 
0061     /**
0062      * Enumeration specifying options for the filter.
0063      **/
0064     enum FilterOption
0065     {
0066         NoOptions = 0x00,               ///< No options specified
0067         AllImages = 0x10,               ///< Include an "All images" entry
0068         AllFiles  = 0x20,               ///< Include an "All files" entry
0069         Unsorted  = 0x40                ///< Do not sort the returned list
0070     };
0071     Q_DECLARE_FLAGS(FilterOptions, FilterOption)
0072 
0073     /**
0074      * Generate a Qt-style filter list.
0075      *
0076      * This is a filter list suitable for passing
0077      * to @c QFileDialog::setNameFilters().
0078      * 
0079      * @param mode The intended file operation mode
0080      * @param options Options for the filter generation.
0081      * @return The filter list
0082      **/
0083     LIBDIALOGUTIL_EXPORT QStringList qtFilterList(ImageFilter::FilterMode mode,
0084                                                   ImageFilter::FilterOptions options = ImageFilter::NoOptions);
0085 
0086     /**
0087      * Generate a Qt-style filter string.
0088      *
0089      * This is a filter string suitable for passing
0090      * to @c QFileDialog::getOpenFileName() or the similar static functions.
0091      * 
0092      * @param mode The intended file operation mode
0093      * @param options Options for the filter generation.
0094      * @return The filter string
0095      **/
0096     LIBDIALOGUTIL_EXPORT QString qtFilterString(ImageFilter::FilterMode mode,
0097                                                 ImageFilter::FilterOptions options = ImageFilter::NoOptions);
0098 
0099     /**
0100      * Generate a KDE-style filter list.
0101      *
0102      * This is a filter string suitable for passing
0103      * to @c KUrlRequester::setFilter().
0104      * @param mode The intended file operation mode
0105      * @param options Options for the filter generation.
0106      * @return The filter string
0107      **/
0108     LIBDIALOGUTIL_EXPORT QString kdeFilter(ImageFilter::FilterMode mode,
0109                                            ImageFilter::FilterOptions options = ImageFilter::NoOptions);
0110 }
0111 
0112 Q_DECLARE_OPERATORS_FOR_FLAGS(ImageFilter::FilterOptions)
0113 
0114 
0115 #endif                          // IMAGEFILTER_H