File indexing completed on 2024-05-12 15:50:11
0001 /* -*- C++ -*- 0002 This file is part of ThreadWeaver. 0003 0004 SPDX-FileCopyrightText: 2005-2014 Mirko Boehm <mirko@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef IMAGE_H 0010 #define IMAGE_H 0011 0012 #include <QAtomicInt> 0013 #include <QCoreApplication> 0014 #include <QImage> 0015 #include <QReadWriteLock> 0016 0017 #include "Progress.h" 0018 0019 class Model; 0020 0021 /** @brief Image loads an image from a path, and then calculates and saves a thumbnail for it. */ 0022 class Image 0023 { 0024 Q_DECLARE_TR_FUNCTIONS(Image) 0025 0026 public: 0027 enum Steps { 0028 Step_NotStarted, 0029 Step_LoadFile, 0030 Step_LoadImage, 0031 Step_ComputeThumbNail, 0032 Step_SaveThumbNail, 0033 Step_NumberOfSteps = Step_SaveThumbNail, 0034 Step_Complete = Step_SaveThumbNail, 0035 }; 0036 0037 Image(const QString inputFileName = QString(), const QString outputFileName = QString(), Model *model = nullptr, int id = 0); 0038 Progress progress() const; 0039 QString description() const; 0040 QString details() const; 0041 QString details2() const; 0042 int processingOrder() const; 0043 0044 const QString inputFileName() const; 0045 const QString outputFileName() const; 0046 QImage thumbNail() const; 0047 0048 void loadFile(); 0049 void loadImage(); 0050 void computeThumbNail(); 0051 void saveThumbNail(); 0052 0053 static const int ThumbHeight; 0054 static const int ThumbWidth; 0055 0056 private: 0057 void announceProgress(Steps step); 0058 void error(Steps step, const QString &message); 0059 0060 QString m_inputFileName; 0061 QString m_outputFileName; 0062 QString m_description; 0063 QString m_details; 0064 QString m_details2; 0065 QAtomicInt m_progress; 0066 QAtomicInt m_failedStep; 0067 QAtomicInt m_processingOrder; 0068 0069 QByteArray m_imageData; 0070 QImage m_image; 0071 QImage m_thumbnail; 0072 Model *m_model; 0073 int m_id; 0074 0075 static QReadWriteLock Lock; 0076 static int ProcessingOrder; 0077 }; 0078 0079 Q_DECLARE_METATYPE(Image) 0080 Q_DECLARE_METATYPE(const Image *) 0081 0082 #endif // IMAGE_H