File indexing completed on 2024-05-05 04:22:00

0001 // SPDX-FileCopyrightText: 2003-2019 The KPhotoAlbum Development Team
0002 // SPDX-FileCopyrightText: 2022 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0003 //
0004 // SPDX-License-Identifier: GPL-2.0-or-later
0005 
0006 #include "ImageRequest.h"
0007 
0008 ImageManager::ImageRequest::ImageRequest(const DB::FileName &fileName,
0009                                          const QSize &size, int angle,
0010                                          ImageManager::ImageClientInterface *client)
0011     : m_type(RequestType::ImageRequest)
0012     , m_fileName(fileName)
0013     , m_width(size.width())
0014     , m_height(size.height())
0015     , m_client(client)
0016     , m_angle(angle)
0017     , m_priority(ThumbnailVisible)
0018     , m_loadedOK(false)
0019     , m_dontUpScale(false)
0020     , m_isThumbnailRequest(false)
0021     , m_imageIsPreRotated(false)
0022 {
0023 }
0024 
0025 ImageManager::ImageRequest::ImageRequest(RequestType type)
0026     : m_type(type)
0027     , m_width(0)
0028     , m_height(0)
0029     , m_client(nullptr)
0030     , m_angle(0)
0031     , m_priority(Priority::LastPriority)
0032     , m_loadedOK(false)
0033     , m_dontUpScale(false)
0034     , m_isThumbnailRequest(false)
0035     , m_imageIsPreRotated(false)
0036 {
0037     Q_ASSERT(type == RequestType::ExitRequest);
0038 }
0039 
0040 bool ImageManager::ImageRequest::isExitRequest() const
0041 {
0042     return m_type == RequestType::ExitRequest;
0043 }
0044 
0045 bool ImageManager::ImageRequest::imageIsPreRotated() const
0046 {
0047     return m_imageIsPreRotated;
0048 }
0049 
0050 void ImageManager::ImageRequest::setImageIsPreRotated(bool imageIsPreRotated)
0051 {
0052     m_imageIsPreRotated = imageIsPreRotated;
0053 }
0054 
0055 bool ImageManager::ImageRequest::loadedOK() const
0056 {
0057     return m_loadedOK;
0058 }
0059 
0060 int ImageManager::ImageRequest::width() const
0061 {
0062     return m_width;
0063 }
0064 
0065 int ImageManager::ImageRequest::height() const
0066 {
0067     return m_height;
0068 }
0069 
0070 bool ImageManager::ImageRequest::operator<(const ImageRequest &other) const
0071 {
0072     const DB::FileName fileA = databaseFileName();
0073     const DB::FileName fileB = other.databaseFileName();
0074 
0075     if (fileA != fileB)
0076         return fileA < fileB;
0077     else if (m_width != other.m_width)
0078         return m_width < other.m_width;
0079     else if (m_height != other.m_height)
0080         return m_height < other.m_height;
0081     else
0082         return m_angle < other.m_angle;
0083 }
0084 
0085 bool ImageManager::ImageRequest::operator==(const ImageRequest &other) const
0086 {
0087     // Compare all atributes but the pixmap.
0088     return (m_type == other.m_type && databaseFileName() == other.databaseFileName() && m_width == other.m_width && m_height == other.m_height && m_angle == other.m_angle && m_client == other.m_client && m_priority == other.m_priority);
0089 }
0090 
0091 ImageManager::ImageClientInterface *ImageManager::ImageRequest::client() const
0092 {
0093     return m_client;
0094 }
0095 
0096 int ImageManager::ImageRequest::angle() const
0097 {
0098     return m_angle;
0099 }
0100 
0101 QSize ImageManager::ImageRequest::fullSize() const
0102 {
0103     return m_fullSize;
0104 }
0105 
0106 void ImageManager::ImageRequest::setFullSize(const QSize &size)
0107 {
0108     m_fullSize = size;
0109 }
0110 
0111 void ImageManager::ImageRequest::setLoadedOK(bool ok)
0112 {
0113     m_loadedOK = ok;
0114 }
0115 
0116 ImageManager::Priority ImageManager::ImageRequest::priority() const
0117 {
0118     return m_priority;
0119 }
0120 
0121 void ImageManager::ImageRequest::setPriority(const Priority prio)
0122 {
0123     m_priority = prio;
0124 }
0125 
0126 bool ImageManager::ImageRequest::stillNeeded() const
0127 {
0128     return true;
0129 }
0130 
0131 bool ImageManager::ImageRequest::doUpScale() const
0132 {
0133     return !m_dontUpScale;
0134 }
0135 
0136 void ImageManager::ImageRequest::setUpScale(bool b)
0137 {
0138     m_dontUpScale = !b;
0139 }
0140 
0141 void ImageManager::ImageRequest::setIsThumbnailRequest(bool b)
0142 {
0143     m_isThumbnailRequest = b;
0144 }
0145 
0146 bool ImageManager::ImageRequest::isThumbnailRequest() const
0147 {
0148     return m_isThumbnailRequest;
0149 }
0150 
0151 DB::FileName ImageManager::ImageRequest::databaseFileName() const
0152 {
0153     return m_fileName;
0154 }
0155 
0156 DB::FileName ImageManager::ImageRequest::fileSystemFileName() const
0157 {
0158     return m_fileName;
0159 }
0160 
0161 QSize ImageManager::ImageRequest::size() const
0162 {
0163     return QSize(m_width, m_height);
0164 }
0165 
0166 // vi:expandtab:tabstop=4 shiftwidth=4: