File indexing completed on 2024-12-22 05:15:55

0001 #pragma once
0002 
0003 /*
0004  * SPDX-FileCopyrightText: 2003-2009 Craig Drummond <craig@kde.org>
0005  * SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #include "File.h"
0009 #include "kfontinst_export.h"
0010 #include <QDBusArgument>
0011 #include <QMetaType>
0012 #include <QSet>
0013 
0014 class QDomElement;
0015 class QTextStream;
0016 
0017 namespace KFI
0018 {
0019 class KFONTINST_EXPORT Style
0020 {
0021 public:
0022     Style(quint32 v = 0, bool sc = false, qulonglong ws = 0)
0023         : m_value(v)
0024         , m_writingSystems(ws)
0025         , m_scalable(sc)
0026     {
0027     }
0028     Style(const QDomElement &elem, bool loadFiles);
0029 
0030     bool operator==(const Style &o) const
0031     {
0032         return m_value == o.m_value;
0033     }
0034 
0035     QString toXml(bool disabled, const QString &family) const;
0036     FileCont::ConstIterator add(const File &f) const
0037     {
0038         return m_files.insert(f);
0039     }
0040     void remove(const File &f) const
0041     {
0042         m_files.remove(f);
0043     }
0044     quint32 value() const
0045     {
0046         return m_value;
0047     }
0048     void setWritingSystems(qulonglong ws) const
0049     {
0050         m_writingSystems = ws;
0051     }
0052     qulonglong writingSystems() const
0053     {
0054         return m_writingSystems;
0055     }
0056     const FileCont &files() const
0057     {
0058         return m_files;
0059     }
0060     void setScalable(bool sc = true) const
0061     {
0062         m_scalable = sc;
0063     }
0064     bool scalable() const
0065     {
0066         return m_scalable;
0067     }
0068     void clearFiles() const
0069     {
0070         m_files.clear();
0071     }
0072     void setFiles(const FileCont &f) const
0073     {
0074         m_files = f;
0075     }
0076     void addFiles(const FileCont &f) const
0077     {
0078         m_files += f;
0079     }
0080     void removeFiles(const FileCont &f) const
0081     {
0082         m_files -= f;
0083     }
0084 
0085 private:
0086     quint32 m_value;
0087     mutable qulonglong m_writingSystems;
0088     mutable bool m_scalable;
0089     mutable FileCont m_files;
0090 };
0091 
0092 typedef QSet<Style> StyleCont;
0093 
0094 inline KFONTINST_EXPORT uint qHash(const Style &key)
0095 {
0096     return key.value();
0097 }
0098 
0099 }
0100 
0101 KFONTINST_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const KFI::Style &obj);
0102 KFONTINST_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, KFI::Style &obj);