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 <QtXml/QDomElement>
25
#include <QtCore/QTextStream>
26
#include <QtCore/QDir>
29
#include "XmlStrings.h"
34
static QString expandHome(const QString &path)
38
return !p.isEmpty() && '~'==p[0]
39
? 1==p.length() ? QDir::homePath() : p.replace(0, 1, QDir::homePath())
43
File::File(const QDomElement &elem, bool disabled)
45
QString path=expandHome(elem.attribute(PATH_ATTR));
47
if(!disabled || Misc::fExists(path)) // Only need to check instance if we are loading the disabled file...
49
itsFoundry=elem.attribute(FOUNDRY_ATTR);
50
itsIndex=elem.hasAttribute(FACE_ATTR) ? elem.attribute(FACE_ATTR).toInt() : 0;
55
QString File::toXml(bool disabled, QTextStream &s) const
57
if(!disabled || Misc::isHidden(Misc::getFile(itsPath)))
59
QString str(PATH_ATTR"=\""+KFI::Misc::encodeText(KFI::Misc::contractHome(itsPath), s)+"\"");
61
if(!itsFoundry.isEmpty() && QString::fromLatin1("unknown")!=itsFoundry)
62
str+=" "FOUNDRY_ATTR"=\""+KFI::Misc::encodeText(itsFoundry, s)+"\"";
65
str+=" "FACE_ATTR"=\""+QString::number(itsIndex)+"\"";
75
QDBusArgument & operator<<(QDBusArgument &argument, const KFI::File &obj)
77
argument.beginStructure();
78
argument << obj.path() << obj.foundry() << obj.index();
79
argument.endStructure();
83
const QDBusArgument & operator>>(const QDBusArgument &argument, KFI::File &obj)
88
argument.beginStructure();
89
argument >> path >> foundry >> index;
90
obj=KFI::File(path, foundry, index);
91
argument.endStructure();