KIO

metadata.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000-2005 David Faure <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 #ifndef KIO_METADATA_H
19 #define KIO_METADATA_H
20 
21 #include <QMap>
22 #include <QString>
23 #include <QVariant>
24 #include "kiocore_export.h"
25 
26 namespace KIO
27 {
28 
34 class MetaData : public QMap<QString, QString>
35 {
36 public:
44  MetaData(const QMap<QString, QString> &metaData) :
45  QMap<QString, QString>(metaData) { }
46 
52 
59  {
61  for (it = metaData.constBegin(); it != metaData.constEnd(); ++it) {
62  insert(it.key(), it.value());
63  }
64  return *this;
65  }
66 
78 
86 
93  QVariant toVariant() const;
94 };
95 
97 {
98  *this = map;
99 }
100 
102 {
103  QMapIterator<QString, QVariant> it(metaData);
104 
105  while (it.hasNext()) {
106  it.next();
107  insert(it.key(), it.value().toString());
108  }
109 
110  return *this;
111 }
112 
114 {
115  clear();
116  return (*this += metaData);
117 }
118 
120 {
123 
124  while (it.hasNext()) {
125  it.next();
126  map.insert(it.key(), it.value());
127  }
128 
129  return QVariant(map);
130 }
131 
132 } // namespace KIO
133 
134 #endif /* KIO_METADATA_H */
MetaData()
Creates an empty meta data map.
Definition: metadata.h:40
A namespace for KIO globals.
Definition: authinfo.h:34
MetaData & operator+=(const QMap< QString, QString > &metaData)
Adds the given meta data map to this map.
Definition: metadata.h:58
QMap::const_iterator constBegin() const const
MetaData is a simple map of key/value strings.
Definition: metadata.h:34
QMapIterator::Item next()
QVariant toVariant() const
Returns the contents of the map as a QVariant.
Definition: metadata.h:119
QMap::const_iterator constEnd() const const
const Key & key() const const
const T & value() const const
MetaData(const QMap< QString, QString > &metaData)
Copy constructor.
Definition: metadata.h:44
const Key key(const T &value, const Key &defaultKey) const const
MetaData & operator=(const QMap< QString, QVariant > &metaData)
Sets the given meta data map to this map.
Definition: metadata.h:113
QMap::iterator insert(const Key &key, const T &value)
bool hasNext() const const
const T value(const Key &key, const T &defaultValue) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jul 8 2020 22:59:30 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.