File indexing completed on 2025-01-05 03:59:46
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2004-09-19 0007 * Description : camera item info container 0008 * 0009 * SPDX-FileCopyrightText: 2004-2005 by Renchi Raju <renchi dot raju at gmail dot com> 0010 * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "camiteminfo.h" 0017 0018 // Qt includes 0019 0020 #include <QDataStream> 0021 0022 namespace Digikam 0023 { 0024 0025 CamItemInfo::CamItemInfo() 0026 : size (-1), 0027 width (-1), 0028 height (-1), 0029 readPermissions (-1), 0030 writePermissions (-1), 0031 downloaded (DownloadUnknown), 0032 id (-1), 0033 rating (0), 0034 pickLabel (0), 0035 colorLabel (0), 0036 previewPossible (false) 0037 { 0038 } 0039 0040 CamItemInfo::~CamItemInfo() 0041 { 0042 } 0043 0044 bool CamItemInfo::isNull() const 0045 { 0046 return (size == -1) && 0047 (width == -1) && 0048 (height == -1) && 0049 (readPermissions == -1) && 0050 (writePermissions == -1) && 0051 (downloaded == DownloadUnknown) && 0052 (id == -1) && 0053 (rating == 0) && 0054 (pickLabel == 0) && 0055 (colorLabel == 0) && 0056 name.isNull() && 0057 folder.isNull() && 0058 mime.isNull() && 0059 ctime.isNull() && 0060 photoInfo.isNull() && 0061 downloadName.isNull() && 0062 tagIds.isEmpty(); 0063 } 0064 0065 QUrl CamItemInfo::url() const 0066 { 0067 QUrl url = QUrl::fromLocalFile(folder); 0068 url = url.adjusted(QUrl::StripTrailingSlash); 0069 url.setPath(url.path() + QLatin1Char('/') + name); 0070 0071 return url; 0072 } 0073 0074 bool CamItemInfo::operator==(const CamItemInfo& info) const 0075 { 0076 return (size == info.size) && 0077 (width == info.width) && 0078 (height == info.height) && 0079 (readPermissions == info.readPermissions) && 0080 (writePermissions == info.writePermissions) && 0081 (name == info.name) && 0082 (folder == info.folder) && 0083 (mime == info.mime) && 0084 (ctime == info.ctime) && 0085 (photoInfo == info.photoInfo) && 0086 (id == info.id) && 0087 (rating == info.rating) && 0088 (pickLabel == info.pickLabel) && 0089 (colorLabel == info.colorLabel) && 0090 (tagIds == info.tagIds); 0091 } 0092 0093 bool CamItemInfo::operator!=(const CamItemInfo& info) const 0094 { 0095 return !operator==(info); 0096 } 0097 0098 QDataStream& operator<<(QDataStream& ds, const CamItemInfo& info) 0099 { 0100 ds << info.name; 0101 ds << info.folder; 0102 ds << info.ctime; 0103 ds << info.mime; 0104 ds << info.size; 0105 ds << info.width; 0106 ds << info.height; 0107 ds << info.downloaded; 0108 ds << info.readPermissions; 0109 ds << info.writePermissions; 0110 ds << info.photoInfo; 0111 ds << info.downloadName; 0112 ds << info.id; 0113 ds << info.rating; 0114 ds << info.pickLabel; 0115 ds << info.colorLabel; 0116 ds << info.tagIds; 0117 0118 return ds; 0119 } 0120 0121 QDataStream& operator>>(QDataStream& ds, CamItemInfo& info) 0122 { 0123 ds >> info.name; 0124 ds >> info.folder; 0125 ds >> info.ctime; 0126 ds >> info.mime; 0127 ds >> info.size; 0128 ds >> info.width; 0129 ds >> info.height; 0130 ds >> info.downloaded; 0131 ds >> info.readPermissions; 0132 ds >> info.writePermissions; 0133 ds >> info.photoInfo; 0134 ds >> info.downloadName; 0135 ds >> info.id; 0136 ds >> info.rating; 0137 ds >> info.pickLabel; 0138 ds >> info.colorLabel; 0139 ds >> info.tagIds; 0140 0141 return ds; 0142 } 0143 0144 QDebug operator<<(QDebug dbg, const CamItemInfo& info) 0145 { 0146 dbg.nospace() << "CamItemInfo::size: " 0147 << info.size << ", "; 0148 dbg.nospace() << "CamItemInfo::width: " 0149 << info.width << ", "; 0150 dbg.nospace() << "CamItemInfo::height: " 0151 << info.height << ", "; 0152 dbg.nospace() << "CamItemInfo::readPermissions: " 0153 << info.readPermissions << ", "; 0154 dbg.nospace() << "CamItemInfo::writePermissions: " 0155 << info.writePermissions << ", "; 0156 dbg.nospace() << "CamItemInfo::name: " 0157 << info.name << ", "; 0158 dbg.nospace() << "CamItemInfo::folder: " 0159 << info.folder << ", "; 0160 dbg.nospace() << "CamItemInfo::mime: " 0161 << info.mime << ", "; 0162 dbg.nospace() << "CamItemInfo::ctime: " 0163 << info.ctime << ", "; 0164 dbg.nospace() << "CamItemInfo::downloaded: " 0165 << info.downloaded; 0166 dbg.nospace() << "CamItemInfo::downloadName: " 0167 << info.downloadName; 0168 dbg.nospace() << "CamItemInfo::id: " 0169 << info.id; 0170 dbg.nospace() << "CamItemInfo::rating: " 0171 << info.rating; 0172 dbg.nospace() << "CamItemInfo::pickLabel: " 0173 << info.pickLabel; 0174 dbg.nospace() << "CamItemInfo::colorLabel: " 0175 << info.colorLabel; 0176 dbg.nospace() << "CamItemInfo::tagIds: " 0177 << info.tagIds; 0178 dbg.nospace() << "CamItemInfo::previewPossible: " 0179 << info.previewPossible; 0180 return dbg.space(); 0181 } 0182 0183 } // namespace Digikam