1 /****************************************************************************
3 ** Copyright (C) 2012 Takumi Asaki
4 ** All rights reserved.
5 ** Contact: Takumi Asaki (takumi.asaki@gmail.com)
7 ** This file is part of the fontmanager application.
9 ** You may use this file under the terms of the BSD license as follows:
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
20 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 ** the names of its contributors may be used to endorse or promote
22 ** products derived from this software without specific prior written
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37 ****************************************************************************/
43 #include <QStringList>
45 #include "fontsconfelement.h"
47 class FontsConf : public QObject
51 explicit FontsConf(QObject *parent = 0);
54 bool modified() const;
55 void setModified(bool value);
56 bool hasUnknownConfig() const;
62 bool parse(const QByteArray &buf);
64 QStringList preferFamily() const;
66 QStringList aliasFamilyFor(const QString &family, const QString &mode) const;
67 int indxOfAliasFamilyFor(const QString &family, const QString &mode, const QString &value) const;
68 void appendAliasFamilyFor(const QString &family, const QString &mode, const QString &value);
69 void insertAliasFamilyFor(const QString &family, const QString &mode, const QString &value, int index);
70 void removeAliasFamilyFor(const QString &family, const QString &mode, const QString &value);
72 QStringList preferFamilyFor(const QString &family) const;
73 int indxOfPreferFamilyFor(const QString &family, const QString &value) const;
74 void appendPreferFamilyFor(const QString &family, const QString &value);
75 void insertPreferFamilyFor(const QString &family, const QString &value, int index);
76 void removePreferFamilyFor(const QString &family, const QString &value);
78 QStringList acceptFamilyFor(const QString &family) const;
79 int indxOfAcceptFamilyFor(const QString &family, const QString &value) const;
80 void appendAcceptFamilyFor(const QString &family, const QString &value);
81 void insertAcceptFamilyFor(const QString &family, const QString &value, int index);
82 void removeAcceptFamilyFor(const QString &family, const QString &value);
84 QStringList matchFamilyFor(const QString &config, bool val) const;
85 QString matchEditValueFor(const QString &config, const QString &family) const;
86 void setMatchEditValueFor(const QString &config, const QString &family, bool val);
87 void unsetMatchEditValueFor(const QString &config, const QString &family);
89 QStringList patternFamilyFor(const QString &family, const QString &mode) const;
90 int indxOfPatternFamilyFor(const QString &family, const QString &mode, const QString &value) const;
91 void appendPatternFamilyFor(const QString &family, const QString &mode, const QString &value);
92 void insertPatternFamilyFor(const QString &family, const QString &mode, const QString &value, int index);
93 void removePatternFamilyFor(const QString &family, const QString &mode, const QString &value);
95 QStringList prependFamilyFor(const QString &family) const;
96 int indxOfPrependFamilyFor(const QString &family, const QString &value) const;
97 void appendPrependFamilyFor(const QString &family, const QString &value);
98 void insertPrependFamilyFor(const QString &family, const QString &value, int index);
99 void removePrependFamilyFor(const QString &family, const QString &value);
101 QStringList appendFamilyFor(const QString &family) const;
102 int indxOfAppendFamilyFor(const QString &family, const QString &value) const;
103 void appendAppendFamilyFor(const QString &family, const QString &value);
104 void insertAppendFamilyFor(const QString &family, const QString &value, int index);
105 void removeAppendFamilyFor(const QString &family, const QString &value);
107 void copy(FontsConf *src);
109 static QStringList genericFamilies();
110 static QStringList configKeys();
113 FontsConfElementPointer aliasElementFor(const QString &family) const;
114 FontsConfElementPointer matchElementFor(const QString &config, bool val) const;
115 FontsConfElementPointer patternElementFor(const QString &family) const;
117 bool appendFamilyToAlias(FontsConfElementPointer aliasElem, const QString &family, const QString &mode, const QString &value);
118 bool insertFamilyToAlias(FontsConfElementPointer aliasElem, const QString &family, const QString &mode, const QString &value, int index);
119 bool isMatchElementFor(FontsConfElementPointer matchElem, const QString &config, const QString &family, const QString &val = QString()) const;
120 bool isPatternElementFor(FontsConfElementPointer matchElem, const QString &family, const QString &mode = QString()) const;
121 FontsConfElementPointer getEditPatternElementFor(FontsConfElementPointer matchElem, const QString &family, const QString &mode = QString()) const;
123 bool containsTextElement(FontsConfElementPointer elem, const QString &tag, const QString &text) const;
124 QStringList textElementList(FontsConfElementPointer elem, const QString &tag) const;
129 void load(const QString &path);
130 void save(const QString &path);
135 bool mHasUnknownConfig;
136 FontsConfElementPointer mElements;
139 #endif // FONTSCONF_H