1
/***************************************************************************
2
* Copyright (C) 2004-2009 by Thomas Fischer *
3
* fischer@unix-ag.uni-kl.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
22
#include <QTextStream>
24
#include <QStringList>
35
const QString File::Url = QLatin1String("Url");
36
const QString File::Encoding = QLatin1String("Encoding");
38
class File::FilePrivate
44
QMap<QString, QVariant> properties;
46
FilePrivate(File *parent)
53
: QList<Element*>(), d(new FilePrivate(this))
63
const Element *File::containsKey(const QString &key) const
65
for (ConstIterator it = begin(); it != end(); ++it) {
66
const Entry* entry = dynamic_cast<const Entry*>(*it);
68
if (entry->id() == key)
71
const Macro* macro = dynamic_cast<const Macro*>(*it);
73
if (macro->key() == key)
82
QStringList File::allKeys() const
86
for (ConstIterator it = begin(); it != end(); ++it) {
87
const Entry* entry = dynamic_cast<const Entry*>(*it);
89
result.append(entry->id());
91
const Macro* macro = dynamic_cast<const Macro*>(*it);
93
result.append(macro->key());
100
void File::setProperty(const QString &key, const QVariant &value)
102
d->properties.insert(key, value);
105
QVariant File::property(const QString &key) const
107
return d->properties.value(key);
110
QVariant File::property(const QString &key, const QVariant &defaultValue) const
112
return d->properties.value(key, defaultValue);
115
bool File::hasProperty(const QString &key) const
117
return d->properties.contains(key);