1 /*****************************************************************************
2 ** QNapi
3 ** Copyright (C) 2008-2017 Piotr Krzemiński <pio.krzeminski@gmail.com>
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12 **
13 *****************************************************************************/
14 
15 #ifndef POSTPROCESSINGCONFIG_H
16 #define POSTPROCESSINGCONFIG_H
17 
18 #include <QString>
19 #include <QStringList>
20 
21 enum EncodingChangeMethod {
22   ECM_ORIGINAL = 0,
23   ECM_CHANGE = 1,
24   ECM_REPLACE_DIACRITICS = 2
25 };
26 
27 class PostProcessingConfig {
28  private:
29   bool enabled_;
30   EncodingChangeMethod encodingChangeMethod_;
31   QString encodingFrom_;
32   bool encodingAutoDetectFrom_;
33   QString encodingTo_;
34   bool showAllEncodings_;
35   QString subFormat_;
36   QString subExtension_;
37   bool skipConvertAds_;
38   bool removeWordsEnabled_;
39   QStringList removeWords_;
40 
41  public:
PostProcessingConfig(const bool & enabled,const EncodingChangeMethod & encodingChangeMethod,const QString & encodingFrom,const bool & encodingAutoDetectFrom,const QString & encodingTo,const bool & showAllEncodings,const QString & subFormat,const QString & subExtension,const bool & skipConvertAds,const bool & removeWordsEnabled,const QStringList & removeWords)42   PostProcessingConfig(const bool& enabled,
43                        const EncodingChangeMethod& encodingChangeMethod,
44                        const QString& encodingFrom,
45                        const bool& encodingAutoDetectFrom,
46                        const QString& encodingTo, const bool& showAllEncodings,
47                        const QString& subFormat, const QString& subExtension,
48                        const bool& skipConvertAds,
49                        const bool& removeWordsEnabled,
50                        const QStringList& removeWords)
51       : enabled_(enabled),
52         encodingChangeMethod_(encodingChangeMethod),
53         encodingFrom_(encodingFrom),
54         encodingAutoDetectFrom_(encodingAutoDetectFrom),
55         encodingTo_(encodingTo),
56         showAllEncodings_(showAllEncodings),
57         subFormat_(subFormat),
58         subExtension_(subExtension),
59         skipConvertAds_(skipConvertAds),
60         removeWordsEnabled_(removeWordsEnabled),
61         removeWords_(removeWords) {}
62 
enabled()63   bool enabled() const { return enabled_; }
encodingChangeMethod()64   EncodingChangeMethod encodingChangeMethod() const {
65     return encodingChangeMethod_;
66   }
encodingFrom()67   QString encodingFrom() const { return encodingFrom_; }
encodingAutoDetectFrom()68   bool encodingAutoDetectFrom() const { return encodingAutoDetectFrom_; }
encodingTo()69   QString encodingTo() const { return encodingTo_; }
showAllEncodings()70   bool showAllEncodings() const { return showAllEncodings_; }
subFormat()71   QString subFormat() const { return subFormat_; }
subExtension()72   QString subExtension() const { return subExtension_; }
skipConvertAds()73   bool skipConvertAds() const { return skipConvertAds_; }
removeWordsEnabled()74   bool removeWordsEnabled() const { return removeWordsEnabled_; }
removeWords()75   QStringList removeWords() const { return removeWords_; }
76 
setEnabled(const bool & enabled)77   const PostProcessingConfig setEnabled(const bool& enabled) const {
78     return PostProcessingConfig(
79         enabled, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom_,
80         encodingTo_, showAllEncodings_, subFormat_, subExtension_,
81         skipConvertAds_, removeWordsEnabled_, removeWords_);
82   }
setEncodingChangeMethod(const EncodingChangeMethod & encodingChangeMethod)83   const PostProcessingConfig setEncodingChangeMethod(
84       const EncodingChangeMethod& encodingChangeMethod) const {
85     return PostProcessingConfig(
86         enabled_, encodingChangeMethod, encodingFrom_, encodingAutoDetectFrom_,
87         encodingTo_, showAllEncodings_, subFormat_, subExtension_,
88         skipConvertAds_, removeWordsEnabled_, removeWords_);
89   }
setEncodingFrom(const QString & encodingFrom)90   const PostProcessingConfig setEncodingFrom(
91       const QString& encodingFrom) const {
92     return PostProcessingConfig(
93         enabled_, encodingChangeMethod_, encodingFrom, encodingAutoDetectFrom_,
94         encodingTo_, showAllEncodings_, subFormat_, subExtension_,
95         skipConvertAds_, removeWordsEnabled_, removeWords_);
96   }
setEncodingAutoDetectFrom(const bool & encodingAutoDetectFrom)97   const PostProcessingConfig setEncodingAutoDetectFrom(
98       const bool& encodingAutoDetectFrom) const {
99     return PostProcessingConfig(
100         enabled_, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom,
101         encodingTo_, showAllEncodings_, subFormat_, subExtension_,
102         skipConvertAds_, removeWordsEnabled_, removeWords_);
103   }
setEncodingTo(const QString & encodingTo)104   const PostProcessingConfig setEncodingTo(const QString& encodingTo) const {
105     return PostProcessingConfig(
106         enabled_, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom_,
107         encodingTo, showAllEncodings_, subFormat_, subExtension_,
108         skipConvertAds_, removeWordsEnabled_, removeWords_);
109   }
setShowAllEncodings(const bool & showAllEncodings)110   const PostProcessingConfig setShowAllEncodings(
111       const bool& showAllEncodings) const {
112     return PostProcessingConfig(
113         enabled_, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom_,
114         encodingTo_, showAllEncodings, subFormat_, subExtension_,
115         skipConvertAds_, removeWordsEnabled_, removeWords_);
116   }
setSubFormat(const QString & subFormat)117   const PostProcessingConfig setSubFormat(const QString& subFormat) const {
118     return PostProcessingConfig(
119         enabled_, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom_,
120         encodingTo_, showAllEncodings_, subFormat, subExtension_,
121         skipConvertAds_, removeWordsEnabled_, removeWords_);
122   }
setSubExtension(const QString & subExtension)123   const PostProcessingConfig setSubExtension(
124       const QString& subExtension) const {
125     return PostProcessingConfig(
126         enabled_, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom_,
127         encodingTo_, showAllEncodings_, subFormat_, subExtension,
128         skipConvertAds_, removeWordsEnabled_, removeWords_);
129   }
setSkipConvertAds(const bool & skipConvertAds)130   const PostProcessingConfig setSkipConvertAds(
131       const bool& skipConvertAds) const {
132     return PostProcessingConfig(
133         enabled_, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom_,
134         encodingTo_, showAllEncodings_, subFormat_, subExtension_,
135         skipConvertAds, removeWordsEnabled_, removeWords_);
136   }
setRemoveWordsEnabled(const bool & removeWordsEnabled)137   const PostProcessingConfig setRemoveWordsEnabled(
138       const bool& removeWordsEnabled) const {
139     return PostProcessingConfig(
140         enabled_, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom_,
141         encodingTo_, showAllEncodings_, subFormat_, subExtension_,
142         skipConvertAds_, removeWordsEnabled, removeWords_);
143   }
setRemoveWords(const QStringList & removeWords)144   const PostProcessingConfig setRemoveWords(
145       const QStringList& removeWords) const {
146     return PostProcessingConfig(
147         enabled_, encodingChangeMethod_, encodingFrom_, encodingAutoDetectFrom_,
148         encodingTo_, showAllEncodings_, subFormat_, subExtension_,
149         skipConvertAds_, removeWordsEnabled_, removeWords);
150   }
151 
152   QString toString() const;
153 };
154 
155 #endif
156