1 #pragma once
2
3 /*
4 * SPDX-FileCopyrightText: 2003-2009 Craig Drummond <craig@kde.org>
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #include "kfontinst_export.h"
9 #include <QDBusArgument>
10 #include <QMetaType>
11 #include <QSet>
12
13 class QDomElement;
14 class QTextStream;
15
16 namespace KFI
17 {
18 class KFONTINST_EXPORT File
19 {
20 public:
equalIndex(int a,int b)21 static bool equalIndex(int a, int b)
22 {
23 return a <= 1 && b <= 1;
24 }
25
26 File(const QString &pth = QString(), const QString &fndry = QString(), int idx = 0)
itsPath(pth)27 : itsPath(pth)
28 , itsFoundry(fndry)
29 , itsIndex(idx)
30 {
31 }
32 File(const QDomElement &elem, bool disabled);
33
34 bool operator==(const File &o) const
35 {
36 return equalIndex(itsIndex, o.itsIndex) && itsPath == o.itsPath;
37 }
38
39 QString toXml(bool disabledOnly, QTextStream &s) const;
40
path()41 const QString &path() const
42 {
43 return itsPath;
44 }
foundry()45 const QString &foundry() const
46 {
47 return itsFoundry;
48 }
index()49 int index() const
50 {
51 return itsIndex;
52 }
53
54 private:
55 QString itsPath, itsFoundry;
56 int itsIndex;
57 };
58
59 typedef QSet<File> FileCont;
60
qHash(const File & key)61 inline Q_DECL_EXPORT uint qHash(const File &key)
62 {
63 return qHash(key.path()); // +qHash(key.index());
64 }
65
66 }
67
68 Q_DECLARE_METATYPE(KFI::File)
69 Q_DECL_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const KFI::File &obj);
70 Q_DECL_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, KFI::File &obj);
71