Warning, file /office/calligra/libs/flake/KoImageCollection.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2007, 2009 Thomas Zander <zander@kde.org> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 #ifndef KOIMAGECOLLECTION_H 0020 #define KOIMAGECOLLECTION_H 0021 0022 #include "flake_export.h" 0023 0024 #include <QObject> 0025 #include <KoDataCenterBase.h> 0026 0027 class QImage; 0028 class QUrl; 0029 class KoStore; 0030 class KoImageData; 0031 0032 /** 0033 * A collection of KoImageData objects to allow loading and saving them all together to the KoStore. 0034 * It also makes sure that if the same image is added to the collection that they share the internal data structure. 0035 */ 0036 class FLAKE_EXPORT KoImageCollection : public QObject, public KoDataCenterBase 0037 { 0038 Q_OBJECT 0039 public: 0040 /// constructor 0041 explicit KoImageCollection(QObject *parent = 0); 0042 ~KoImageCollection() override; 0043 0044 /// reimplemented 0045 bool completeLoading(KoStore *store) override; 0046 0047 /** 0048 * Save all images to the store which are in the context 0049 * @return returns true if save was successful (no images failed). 0050 */ 0051 bool completeSaving(KoStore *store, KoXmlWriter *manifestWriter, KoShapeSavingContext *context) override; 0052 0053 /** 0054 * Create a data object for the image data. 0055 * The collection will create an image data in a way that if there is an 0056 * existing data object with the same image the returned KoImageData will 0057 * share its data. 0058 * @param image a valid image which will be represented by the imageData. 0059 * @see KoImageData::isValid() 0060 */ 0061 KoImageData *createImageData(const QImage &image); 0062 0063 /** 0064 * Create a data object for the image data. 0065 * The collection will create an image data in a way that if there is an 0066 * existing data object with the same image the returned KoImageData will 0067 * share its data. 0068 * @param href the name of the image inside the store. 0069 * @param store the KoStore object. 0070 * @see KoImageData::isValid() 0071 */ 0072 KoImageData *createImageData(const QString &href, KoStore *store); 0073 0074 /** 0075 * Create a data object for the image data. 0076 * The collection will create an image data in a way that if there is an 0077 * existing data object with the same image the returned KoImageData will 0078 * share its data. 0079 * @param imageData the bytes that represent the image in a format like png. 0080 * @see KoImageData::isValid() 0081 */ 0082 KoImageData *createImageData(const QByteArray &imageData); 0083 0084 void removeOnKey(qint64 imageDataKey); 0085 0086 bool fillFromKey(KoImageData &idata, qint64 imageDataKey); 0087 0088 /** 0089 * Get the number of images inside the collection 0090 */ 0091 int size() const; 0092 0093 /** 0094 * Get the number of images inside the collection 0095 */ 0096 int count() const; 0097 0098 /** 0099 * Update the imagecollection: the imagedata object with the old 0100 * key will now be associated with the new key. 0101 * 0102 * @param the key by which the object is known in the collection 0103 * @param they new key by which the object should be known 0104 */ 0105 void update(qint64 oldKey, qint64 newKey); 0106 0107 private: 0108 KoImageData *cacheImage(KoImageData *data); 0109 0110 class Private; 0111 Private * const d; 0112 }; 0113 0114 #endif // KOIMAGECOLLECTION_H