1
/* This file is part of the KDE project
2
Copyright (c) 2001 Simon Hausmann <hausmann@kde.org>
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 as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
19
#ifndef __koImageCollection_h__
20
#define __koImageCollection_h__
29
* This is a little extension to a QMap holding a bunch of @ref KoImage
30
* objects. It actually inherits from QMap, but it provides additional
33
class KoImageCollection : public QMap<KoImageKey, KoImage>
37
* Convenience method to QMap::find . Returns the data directly.
39
KoImage findImage( const KoImageKey &key ) const;
42
* Similar to QMap::insert, however it doesn't overwrite the
43
* existing entry if it exists already.
45
KoImage insertImage( const KoImageKey &key, const QImage &image );
48
* Load an image from a file (and insert into the collection).
49
* The modification date of the file is checked, to create the key
50
* for this KoImage. If this key maps to an existing image in the
51
* collection, then this image is returned, otherwise the file is loaded.
53
KoImage loadImage( const QString &fileName );
56
* Save the used images from the collection into the store
57
* Usually called from completeSaving().
59
* @param store the store in which to save the images
60
* @param keys the list of keys corresponding to the images to save
61
* @param prefix the prefix to use when saving the images in the store
62
* (usually: isStoredExtern() ? QString::null : url().url() + "/",
63
* where 'this' is the document)
65
void saveToStore( KoStore * store, QValueList<KoImageKey> keys, const QString & prefix ) const;
68
* Generate the <PIXMAPS> tag, that saves the key and the related
69
* relative path in the store (e.g. pictures/picture1.ext) for each pixmap.
71
QDomElement saveXML( QDomDocument &doc, QValueList<KoImageKey> keys, const QString & prefix ) const;
73
typedef QMap<KoImageKey, QString> StoreMap;
75
* Read the <PIXMAPS> tag, and save the result (key<->store-filename associations)
76
* into the QMap. You may want to 'new' a QMap in loadXML, and to use and then delete
77
* it in completeLoading (to save memory).
79
StoreMap readXML( QDomElement &pixmapsElem, const QDateTime & defaultDateTime );
82
* Read all images from the store, into this collection
83
* The map comes from readXML above, and is used to find which images
84
* to load, and which key to associate them.
85
* @param prefix same as above (only used for old format support)
87
void readFromStore( KoStore * store, const StoreMap &storeMap,const QString &prefix );