File indexing completed on 2025-01-05 03:52:04
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2006-04-04 0007 * Description : a tool to generate HTML image galleries 0008 * 0009 * SPDX-FileCopyrightText: 2006-2010 by Aurelien Gateau <aurelien dot gateau at free dot fr> 0010 * SPDX-FileCopyrightText: 2012-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 // Local includes 0017 0018 #include "galleryelement.h" 0019 #include "galleryxmlutils.h" 0020 #include "metaengine.h" 0021 0022 namespace DigikamGenericHtmlGalleryPlugin 0023 { 0024 0025 GalleryElement::GalleryElement(const DInfoInterface::DInfoMap& info) 0026 : m_valid(false) 0027 { 0028 DItemInfo item(info); 0029 m_title = item.name(); 0030 m_description = item.comment(); 0031 m_orientation = (MetaEngine::ImageOrientation)(item.orientation()); 0032 m_time = item.dateTime(); 0033 } 0034 0035 GalleryElement::GalleryElement() 0036 : m_valid(false), 0037 m_orientation(MetaEngine::ORIENTATION_UNSPECIFIED) 0038 { 0039 } 0040 0041 GalleryElement::~GalleryElement() 0042 { 0043 } 0044 0045 void GalleryElement::appendToXML(XMLWriter& xmlWriter, bool copyOriginalImage) const 0046 { 0047 if (!m_valid) 0048 { 0049 return; 0050 } 0051 0052 XMLElement imageX(xmlWriter, QLatin1String("image")); 0053 xmlWriter.writeElement("title", m_title); 0054 xmlWriter.writeElement("description", m_description); 0055 xmlWriter.writeElement("date", m_time.toString(QLatin1String("yyyy-MM-ddThh:mm:ss"))); 0056 appendImageElementToXML(xmlWriter, QLatin1String("full"), m_fullFileName, m_fullSize); 0057 appendImageElementToXML(xmlWriter, QLatin1String("thumbnail"), m_thumbnailFileName, m_thumbnailSize); 0058 0059 if (copyOriginalImage) 0060 { 0061 appendImageElementToXML(xmlWriter, 0062 QLatin1String("original"), 0063 m_originalFileName, m_originalSize); 0064 } 0065 0066 //Exif 0067 // TODO put all exif tags in a sub level 0068 XMLElement imageExif(xmlWriter, QLatin1String("exif")); 0069 xmlWriter.writeElement("exifimagemake", m_exifImageMake); 0070 xmlWriter.writeElement("exifimagemodel", m_exifItemModel); 0071 xmlWriter.writeElement("exifimageorientation", m_exifImageOrientation); 0072 xmlWriter.writeElement("exifimagexresolution", m_exifImageXResolution); 0073 xmlWriter.writeElement("exifimageyresolution", m_exifImageYResolution); 0074 xmlWriter.writeElement("exifimageresolutionunit", m_exifImageResolutionUnit); 0075 xmlWriter.writeElement("exifimagedatetime", m_exifImageDateTime); 0076 xmlWriter.writeElement("exifimageycbcrpositioning", m_exifImageYCbCrPositioning); 0077 xmlWriter.writeElement("exifphotoexposuretime", m_exifPhotoExposureTime); 0078 xmlWriter.writeElement("exifphotofnumber", m_exifPhotoFNumber); 0079 xmlWriter.writeElement("exifphotoexposureprogram", m_exifPhotoExposureProgram); 0080 xmlWriter.writeElement("exifphotoisospeedratings", m_exifPhotoISOSpeedRatings); 0081 xmlWriter.writeElement("exifphotoshutterspeedvalue", m_exifPhotoShutterSpeedValue); 0082 xmlWriter.writeElement("exifphotoaperturevalue", m_exifPhotoApertureValue); 0083 xmlWriter.writeElement("exifphotofocallength", m_exifPhotoFocalLength); 0084 0085 // GPS 0086 xmlWriter.writeElement("exifgpslatitude", m_exifGPSLatitude); 0087 xmlWriter.writeElement("exifgpslongitude", m_exifGPSLongitude); 0088 xmlWriter.writeElement("exifgpsaltitude", m_exifGPSAltitude); 0089 } 0090 0091 void GalleryElement::appendImageElementToXML(XMLWriter& xmlWriter, 0092 const QString& elementName, 0093 const QString& fileName, 0094 const QSize& size) const 0095 { 0096 XMLAttributeList attrList; 0097 attrList.append(QLatin1String("fileName"), fileName); 0098 attrList.append(QLatin1String("width"), size.width()); 0099 attrList.append(QLatin1String("height"), size.height()); 0100 XMLElement elem(xmlWriter, elementName, &attrList); 0101 } 0102 0103 } // namespace DigikamGenericHtmlGalleryPlugin