2
* KFontInst - KDE Font Installer
4
* Copyright 2003-2009 Craig Drummond <craig@kde.org>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; see the file COPYING. If not, write to
20
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
* Boston, MA 02110-1301, USA.
24
#include <QtCore/QTextStream>
25
#include <QtXml/QDomElement>
29
#include "XmlStrings.h"
31
#define KFI_DBUG kDebug() << time(0L)
36
Family::Family(const QDomElement &elem, bool loadStyles)
38
if(elem.hasAttribute(FAMILY_ATTR))
39
itsName=elem.attribute(FAMILY_ATTR);
40
if(elem.hasAttribute(NAME_ATTR))
41
itsName=elem.attribute(NAME_ATTR);
44
for(QDomNode n=elem.firstChild(); !n.isNull(); n=n.nextSibling())
46
QDomElement ent=n.toElement();
48
if(FONT_TAG==ent.tagName())
50
Style style(ent, loadStyles);
52
if(!style.files().isEmpty())
53
itsStyles.insert(style);
59
void Family::toXml(bool disabled, QTextStream &s) const
61
QString family(KFI::Misc::encodeText(itsName, s));
63
StyleCont::ConstIterator it(itsStyles.begin()),
68
QString entry((*it).toXml(disabled, disabled ? family : QString(), s));
71
entries.append(entry);
77
s << " <"FAMILY_TAG" "NAME_ATTR"=\"" << KFI::Misc::encodeText(itsName, s) << "\">\n";
79
QStringList::ConstIterator it(entries.begin()),
86
s << " </"FAMILY_TAG">" << endl;
92
QDBusArgument & operator<<(QDBusArgument &argument, const KFI::Family &obj)
94
argument.beginStructure();
95
argument << obj.name();
97
argument.beginArray(qMetaTypeId<KFI::Style>());
98
KFI::StyleCont::ConstIterator it(obj.styles().begin()),
99
end(obj.styles().end());
103
argument.endStructure();
107
const QDBusArgument & operator>>(const QDBusArgument &argument, KFI::Family &obj)
110
argument.beginStructure();
112
obj=KFI::Family(name);
113
argument.beginArray();
114
while(!argument.atEnd())
121
argument.endStructure();
125
QDBusArgument & operator<<(QDBusArgument &argument, const KFI::Families &obj)
127
argument.beginStructure();
128
argument << obj.isSystem;
130
argument.beginArray(qMetaTypeId<KFI::Family>());
131
KFI::FamilyCont::ConstIterator it(obj.items.begin()),
132
end(obj.items.end());
137
argument.endStructure();
141
const QDBusArgument & operator>>(const QDBusArgument &argument, KFI::Families &obj)
143
argument.beginStructure();
144
argument >> obj.isSystem;
145
argument.beginArray();
146
while(!argument.atEnd())
150
obj.items.insert(fam);
153
argument.endStructure();