File indexing completed on 2025-01-05 03:55:17
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-06-02 0007 * Description : class holding properties of referenced files used in non-dest. editing 0008 * 0009 * SPDX-FileCopyrightText: 2010 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 #include "historyimageid.h" 0017 0018 // Qt includes 0019 0020 #include <QFileInfo> 0021 #include <QUrl> 0022 0023 namespace Digikam 0024 { 0025 0026 HistoryImageId::HistoryImageId() 0027 : m_type (InvalidType), 0028 m_fileSize(0) 0029 { 0030 } 0031 0032 HistoryImageId::HistoryImageId(const QString& uuid, Type type) 0033 : m_type (type), 0034 m_uuid (uuid), 0035 m_fileSize(0) 0036 { 0037 } 0038 0039 void HistoryImageId::setType(HistoryImageId::Type type) 0040 { 0041 m_type = type; 0042 } 0043 0044 void HistoryImageId::setUuid(const QString& uuid) 0045 { 0046 m_uuid = uuid; 0047 } 0048 0049 void HistoryImageId::setFileName(const QString& fileName) 0050 { 0051 m_fileName = fileName; 0052 } 0053 0054 void HistoryImageId::setCreationDate(const QDateTime& creationDate) 0055 { 0056 m_creationDate = creationDate; 0057 } 0058 0059 void HistoryImageId::setPathOnDisk(const QString& filePath) 0060 { 0061 QUrl url = QUrl::fromLocalFile(filePath); 0062 m_filePath = url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile() + QLatin1Char('/'); 0063 } 0064 0065 void HistoryImageId::setPath(const QString& path) 0066 { 0067 m_filePath = path; 0068 0069 if (!m_filePath.endsWith(QLatin1Char('/'))) 0070 { 0071 m_filePath += QLatin1Char('/'); 0072 } 0073 } 0074 0075 void HistoryImageId::setUniqueHash(const QString& uniqueHash, qlonglong fileSize) 0076 { 0077 m_uniqueHash = uniqueHash; 0078 m_fileSize = fileSize; 0079 } 0080 0081 bool HistoryImageId::isValid() const 0082 { 0083 return ( 0084 (m_type != InvalidType) && 0085 (!m_uuid.isEmpty() || !m_fileName.isEmpty()) 0086 ); 0087 } 0088 0089 HistoryImageId::Type HistoryImageId::type() const 0090 { 0091 return m_type; 0092 } 0093 0094 QString HistoryImageId::path() const 0095 { 0096 return m_filePath; 0097 } 0098 0099 QString HistoryImageId::filePath() const 0100 { 0101 return (m_filePath + m_fileName); 0102 } 0103 0104 bool HistoryImageId::hasFileOnDisk() const 0105 { 0106 return (!m_filePath.isEmpty() && !m_fileName.isEmpty()); 0107 } 0108 0109 bool HistoryImageId::hasFileName() const 0110 { 0111 return !m_fileName.isEmpty(); 0112 } 0113 0114 QString HistoryImageId::fileName() const 0115 { 0116 return m_fileName; 0117 } 0118 0119 bool HistoryImageId::hasUuid() const 0120 { 0121 return !m_uuid.isEmpty(); 0122 } 0123 0124 QString HistoryImageId::uuid() const 0125 { 0126 return m_uuid; 0127 } 0128 0129 bool HistoryImageId::hasCreationDate() const 0130 { 0131 return m_creationDate.isValid(); 0132 } 0133 0134 QDateTime HistoryImageId::creationDate() const 0135 { 0136 return m_creationDate; 0137 } 0138 0139 bool HistoryImageId::hasUniqueHashIdentifier() const 0140 { 0141 return (!m_uniqueHash.isEmpty() && m_fileSize); 0142 } 0143 0144 QString HistoryImageId::uniqueHash() const 0145 { 0146 return m_uniqueHash; 0147 } 0148 0149 qlonglong HistoryImageId::fileSize() const 0150 { 0151 return m_fileSize; 0152 } 0153 0154 QString HistoryImageId::originalUuid() const 0155 { 0156 return m_originalUUID; 0157 } 0158 0159 bool HistoryImageId::operator==(const HistoryImageId& other) const 0160 { 0161 return ( 0162 (m_uuid == other.m_uuid) && 0163 (m_type == other.m_type) && 0164 (m_fileName == other.m_fileName) && 0165 (m_filePath == other.m_filePath) && 0166 (m_creationDate == other.m_creationDate) && 0167 (m_uniqueHash == other.m_uniqueHash) && 0168 (m_fileSize == other.m_fileSize) && 0169 (m_originalUUID == other.m_originalUUID) 0170 ); 0171 } 0172 0173 } // namespace Digikam