File indexing completed on 2025-01-19 03:56:59
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-12-20 0007 * Description : description of actions when saving a file with versioning 0008 * 0009 * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * SPDX-FileCopyrightText: 2010 by Martin Klapetek <martin dot klapetek at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_VERSION_FILE_OPERATION_H 0017 #define DIGIKAM_VERSION_FILE_OPERATION_H 0018 0019 // Qt includes 0020 0021 #include <QFlags> 0022 #include <QMap> 0023 #include <QString> 0024 0025 // Local includes 0026 0027 #include "digikam_export.h" 0028 #include "dimagehistory.h" 0029 0030 class QUrl; 0031 0032 namespace Digikam 0033 { 0034 0035 class DIGIKAM_EXPORT VersionFileInfo 0036 { 0037 public: 0038 0039 explicit VersionFileInfo() 0040 { 0041 } 0042 0043 VersionFileInfo(const QString& path, const QString& fileName, const QString& format) 0044 : path(path), 0045 fileName(fileName), 0046 format(format) 0047 { 0048 } 0049 0050 bool isNull() const; 0051 0052 QString filePath() const; 0053 QUrl fileUrl() const; 0054 0055 QString path; 0056 QString fileName; 0057 QString format; 0058 }; 0059 0060 // ------------------------------------------------------------------------------------------- 0061 0062 class DIGIKAM_EXPORT VersionFileOperation 0063 { 0064 public: 0065 0066 /** This class describes an operation necessary for storing an 0067 * image under version control. 0068 * The loadedFile and current history is given to the VersionManager. 0069 * The saveFile is the destination of the save operation. 0070 * If the loadedFile shall be moved to an intermediate, 0071 * the name is given in intermediateForLoadedFile. 0072 * The intermediates map may contain name of intermediates 0073 * to save the state after action i of the history 0074 * (initialResolvedHistory.size() <= i < currentHistory.size() - 1). 0075 */ 0076 0077 explicit VersionFileOperation() 0078 { 0079 } 0080 0081 public: 0082 0083 enum Task 0084 { 0085 /// saveFile is a new file. Excludes Replace. 0086 NewFile = 1 << 0, 0087 /// loadedFile and saveFile are the same - replace. Excludes NewFile. 0088 Replace = 1 << 1, 0089 /// Similar to Replace, but the new file name differs from the old one, which should be removed 0090 SaveAndDelete = 1 << 2, 0091 /// Move loadedFile to loadedFileToIntermediate 0092 MoveToIntermediate = 1 << 3, 0093 /// Store additional snapshots from within history 0094 StoreIntermediates = 1 << 4 0095 }; 0096 Q_DECLARE_FLAGS(Tasks, Task) 0097 0098 public: 0099 0100 Tasks tasks; 0101 0102 VersionFileInfo loadedFile; 0103 0104 VersionFileInfo saveFile; 0105 0106 VersionFileInfo intermediateForLoadedFile; 0107 0108 QMap<int, VersionFileInfo> intermediates; 0109 0110 /** 0111 * Returns a list with all saving locations, for main result or intermediates 0112 */ 0113 QStringList allFilePaths() const; 0114 }; 0115 0116 } // namespace Digikam 0117 0118 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::VersionFileOperation::Tasks) 0119 0120 #endif // DIGIKAM_VERSION_FILE_OPERATION_H