File indexing completed on 2025-01-26 05:08:06
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 "Family.h" 0009 #include "File.h" 0010 #include "Misc.h" 0011 #include "Style.h" 0012 #include <QSet> 0013 #include <QString> 0014 #include <sys/time.h> 0015 0016 namespace KFI 0017 { 0018 class Folder 0019 { 0020 struct CfgFile { 0021 bool modified(); 0022 void updateTimeStamp(); 0023 0024 bool dirty; 0025 QString name; 0026 time_t timestamp; 0027 }; 0028 0029 public: 0030 struct FlatFont : Misc::TFont { 0031 FlatFont(const Family &fam, const Style &style, const File &f) 0032 : Misc::TFont(fam.name(), style.value()) 0033 , writingSystems(style.writingSystems()) 0034 , scalable(style.scalable()) 0035 , file(f) 0036 { 0037 } 0038 bool operator==(const FlatFont &o) const 0039 { 0040 return file.path() == o.file.path(); 0041 } 0042 0043 qulonglong writingSystems; 0044 bool scalable; 0045 File file; 0046 }; 0047 0048 struct Flat : public QSet<FlatFont> { 0049 Families build(bool system) const; 0050 }; 0051 0052 Folder() 0053 { 0054 } 0055 ~Folder(); 0056 0057 void init(bool system, bool systemBus); 0058 const QString &location() const 0059 { 0060 return m_location; 0061 } 0062 bool allowToggling() const; 0063 void loadDisabled(); 0064 void saveDisabled(); 0065 void setDisabledDirty() 0066 { 0067 m_disabledCfg.dirty = true; 0068 } 0069 bool disabledDirty() const 0070 { 0071 return m_disabledCfg.dirty; 0072 } 0073 QStringList toXml(int max = 0); 0074 Families list(); 0075 bool contains(const QString &family, quint32 style); 0076 void add(const Family &family); 0077 void addModifiedDir(const QString &dir) 0078 { 0079 m_modifiedDirs.insert(dir); 0080 } 0081 void addModifiedDirs(const QSet<QString> &dirs) 0082 { 0083 m_modifiedDirs += dirs; 0084 } 0085 bool isModified() const 0086 { 0087 return !m_modifiedDirs.isEmpty(); 0088 } 0089 void clearModified() 0090 { 0091 m_modifiedDirs.clear(); 0092 } 0093 void configure(bool force = false); 0094 Flat flatten() const; 0095 const FamilyCont &fonts() const 0096 { 0097 return m_fonts; 0098 } 0099 FamilyCont::ConstIterator addFont(const Family &fam) 0100 { 0101 return m_fonts.insert(fam); 0102 } 0103 void removeFont(const Family &fam) 0104 { 0105 m_fonts.remove(fam); 0106 } 0107 void clearFonts() 0108 { 0109 m_fonts.clear(); 0110 } 0111 0112 private: 0113 bool m_isSystem; 0114 FamilyCont m_fonts; 0115 CfgFile m_disabledCfg; 0116 QString m_location; 0117 QSet<QString> m_modifiedDirs; 0118 }; 0119 0120 inline Q_DECL_EXPORT uint qHash(const Folder::FlatFont &key) 0121 { 0122 return qHash(key.file); // +qHash(key.index()); 0123 } 0124 0125 }