WebImage.h 997 Bytes
Newer Older
1 2 3 4 5
#ifndef WEBIMAGE_H
#define WEBIMAGE_H

#include <inttypes.h>
#include <QImage>
6
#include <QScopedPointer>
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <QSharedPointer>

class WebImage
{
public:
    WebImage();

    void clear(void);

    enum State
    {
        UNINITIALIZED = 0,
        REQUESTED = 1,
        READY = 2
    };

    State getState(void) const;
    void setState(State state);

26
    const QString& getSourceURL(void) const;
27 28 29
    void setSourceURL(const QString& url);

    const uint8_t* getData(void) const;
30 31
    void setData(const QByteArray& data);

32 33
    int32_t getWidth(void) const;
    int32_t getHeight(void) const;
34
    int32_t getByteCount(void) const;
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

    uint64_t getLastReference(void) const;
    void setLastReference(uint64_t value);

    bool getSyncFlag(void) const;
    void setSyncFlag(bool onoff);

private:
    State state;
    QString sourceURL;
    QSharedPointer<QImage> image;
    uint64_t lastReference;
    bool syncFlag;
};

typedef QSharedPointer<WebImage> WebImagePtr;

#endif // WEBIMAGE_H