File indexing completed on 2024-05-12 16:35:05
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 VIDEOCOLLECTION_H 0020 #define VIDEOCOLLECTION_H 0021 0022 #include <KoDataCenterBase.h> 0023 #include <QObject> 0024 0025 class QUrl; 0026 class KoStore; 0027 class VideoData; 0028 0029 /** 0030 * An collection of VideoData objects to allow loading and saving them all together to the KoStore. 0031 * It also makes sure that if the same image is added to the collection that they share the internal data structure. 0032 */ 0033 class VideoCollection : public QObject, public KoDataCenterBase 0034 { 0035 Q_OBJECT 0036 public: 0037 enum ResouceManager { 0038 ResourceId = 75208282 0039 }; 0040 /// constructor 0041 explicit VideoCollection(QObject *parent = 0); 0042 virtual ~VideoCollection(); 0043 0044 /// reimplemented 0045 bool completeLoading(KoStore *store) override; 0046 0047 /** 0048 * Save all videos to the store which are in the context 0049 * @return returns true if save was successful (no videos failed). 0050 */ 0051 bool completeSaving(KoStore *store, KoXmlWriter *manifestWriter, KoShapeSavingContext *context) override; 0052 0053 /** 0054 * Create a data object for the video data. 0055 * The collection will create an video data in a way that if there is an 0056 * existing data object with the same video the returned VideoData will 0057 * share its data. 0058 * @param url a valid, local url to point to an video on the filesystem. 0059 * @param saveInternal, if true then the video is saved inside the resulting document 0060 * @see VideoData::isValid() 0061 */ 0062 VideoData *createExternalVideoData(const QUrl &url, bool saveInternal); 0063 0064 /** 0065 * Create a data object for the video data. 0066 * The collection will create an image data in a way that if there is an 0067 * existing data object with the same video the returned VideoData will 0068 * share its data. 0069 * @param href the name of the video inside the store. 0070 * @param store the KoStore object. 0071 * @see VideoData::isValid() 0072 */ 0073 VideoData *createVideoData(const QString &href, KoStore *store); 0074 0075 void add(const VideoData &data); 0076 void remove(const VideoData &data); 0077 void removeOnKey(qint64 videoDataKey); 0078 0079 /** 0080 * Get the number of videos inside the collection 0081 */ 0082 int size() const; 0083 /** 0084 * Get the number of videos inside the collection 0085 */ 0086 int count() const; 0087 0088 int saveCounter; 0089 0090 private: 0091 VideoData *cacheVideo(VideoData *data); 0092 0093 class Private; 0094 Private * const d; 0095 }; 0096 0097 #endif // VIDEOCOLLECTION_H