64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#ifndef IMAGERINGLIST_H
|
|
#define IMAGERINGLIST_H
|
|
|
|
#include <QObject>
|
|
#include <QFileSystemWatcher>
|
|
#include <QList>
|
|
#include <QPixmap>
|
|
#include <memory>
|
|
|
|
class Image : public QObject
|
|
{
|
|
Q_OBJECT
|
|
bool m_loading;
|
|
bool m_released;
|
|
bool m_current;
|
|
QPixmap m_pixmap;
|
|
QString m_name;
|
|
public:
|
|
explicit Image(const QString name);
|
|
void load();
|
|
void release();
|
|
QString name() const;
|
|
QPixmap pixmap() const;
|
|
bool isCurrent() const;
|
|
signals:
|
|
void pixmapLoaded(Image *ptr);
|
|
protected slots:
|
|
void imageLoaded(QImage img);
|
|
};
|
|
|
|
typedef std::shared_ptr<Image> ImagePtr;
|
|
|
|
class ImageRingList : public QObject
|
|
{
|
|
Q_OBJECT
|
|
int m_width;
|
|
QList<ImagePtr> m_images;
|
|
QList<ImagePtr>::iterator m_firstImage;
|
|
QList<ImagePtr>::iterator m_currImage;
|
|
QList<ImagePtr>::iterator m_lastImage;
|
|
QFileSystemWatcher m_fileSystemWatcher;
|
|
bool m_liveMode;
|
|
public:
|
|
explicit ImageRingList(QObject *parent = 0);
|
|
bool setDir(const QString path, const QString ¤tFile = QString());
|
|
void setFile(const QString &file);
|
|
ImagePtr currentImage();
|
|
void increment();
|
|
void decrement();
|
|
void setLiveMode(bool live);
|
|
protected:
|
|
void setFiles(const QStringList files, const QString ¤tFile = QString());
|
|
QList<ImagePtr>::iterator increment(QList<ImagePtr>::iterator iter);
|
|
QList<ImagePtr>::iterator decrement(QList<ImagePtr>::iterator iter);
|
|
signals:
|
|
void pixmapLoaded(QPixmap pix);
|
|
void currentImageChanged();
|
|
protected slots:
|
|
void imageLoaded(Image *image);
|
|
void dirChanged(QString dir);
|
|
};
|
|
|
|
#endif // IMAGERINGLIST_H
|