#ifndef IMAGERINGLIST_H #define IMAGERINGLIST_H #include #include #include #include #include #include "imageinfo.h" #include "rawimage.h" class ImageRingList; class QThreadPool; class Image : public QObject { Q_OBJECT bool m_loading; bool m_released; bool m_current; int m_number; std::unique_ptr m_rawImage; std::unique_ptr m_thumbnail; QString m_name; ImageInfoData m_info; ImageRingList *m_ringList; public: explicit Image(const QString name, int number, ImageRingList *ringList); void load(); void loadThumbnail(QThreadPool *pool); void release(); QString name() const; RawImage* rawImage(); const RawImage* thumbnail() const; ImageInfoData info() const; bool isCurrent() const; int number() const; signals: void pixmapLoaded(Image *ptr); void thumbnailLoaded(Image *ptr); protected slots: void imageLoaded(void *rawImage, ImageInfoData info); void thumbnailLoadFinish(void *rawImage); }; typedef std::shared_ptr ImagePtr; class ImageRingList : public QAbstractItemModel { Q_OBJECT int m_width; QList m_images; QList::iterator m_firstImage; QList::iterator m_currImage; QList::iterator m_lastImage; QFileSystemWatcher m_fileSystemWatcher; bool m_liveMode; AnalyzeLevel m_analyzeLevel; QThreadPool *m_thumbPool; public: explicit ImageRingList(QObject *parent = 0); ~ImageRingList(); bool setDir(const QString path, const QString ¤tFile = QString()); void setFile(const QString &file); ImagePtr currentImage(); void increment(); void decrement(); void setLiveMode(bool live); void setCalculateStats(bool stats); void setFindPeaks(bool findPeaks); void setFindStars(bool findStars); AnalyzeLevel analyzeLevel() const; void loadFile(int row); void loadThumbnails(); void stopLoading(); int imageCount() const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &child) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; protected: void setFiles(const QStringList files, const QString ¤tFile = QString()); QList::iterator increment(QList::iterator iter); QList::iterator decrement(QList::iterator iter); signals: void pixmapLoaded(Image *image); void thumbnailLoaded(Image *image); void infoLoaded(ImageInfoData info); void currentImageChanged(int index); protected slots: void imageLoaded(Image *image); void dirChanged(QString dir); }; #endif // IMAGERINGLIST_H