comparison layer/ImageLayer.h @ 305:013a37723c0a

* Add support for remote files to image layer
author Chris Cannam
date Fri, 05 Oct 2007 15:52:52 +0000
parents 4b7e8da8f069
children 6de6f78b13a1
comparison
equal deleted inserted replaced
304:4b7e8da8f069 305:013a37723c0a
20 #include "data/model/ImageModel.h" 20 #include "data/model/ImageModel.h"
21 21
22 #include <QObject> 22 #include <QObject>
23 #include <QColor> 23 #include <QColor>
24 #include <QImage> 24 #include <QImage>
25 #include <QMutex>
25 26
26 #include <map> 27 #include <map>
27 28
28 class View; 29 class View;
29 class QPainter; 30 class QPainter;
31 class RemoteFile;
30 32
31 class ImageLayer : public Layer 33 class ImageLayer : public Layer
32 { 34 {
33 Q_OBJECT 35 Q_OBJECT
34 36
35 public: 37 public:
36 ImageLayer(); 38 ImageLayer();
39 virtual ~ImageLayer();
37 40
38 virtual void paint(View *v, QPainter &paint, QRect rect) const; 41 virtual void paint(View *v, QPainter &paint, QRect rect) const;
39 42
40 virtual QString getFeatureDescription(View *v, QPoint &) const; 43 virtual QString getFeatureDescription(View *v, QPoint &) const;
41 44
91 94
92 virtual void setLayerDormant(const View *v, bool dormant); 95 virtual void setLayerDormant(const View *v, bool dormant);
93 96
94 void setProperties(const QXmlAttributes &attributes); 97 void setProperties(const QXmlAttributes &attributes);
95 98
99 protected slots:
100 void checkAddRemotes();
101 void remoteFileReady();
102
96 protected: 103 protected:
97 ImageModel::PointList getLocalPoints(View *v, int x, int y) const; 104 ImageModel::PointList getLocalPoints(View *v, int x, int y) const;
98 105
99 bool getImageOriginalSize(QString name, QSize &size) const; 106 bool getImageOriginalSize(QString name, QSize &size) const;
100 QImage getImage(View *v, QString name, QSize maxSize) const; 107 QImage getImage(View *v, QString name, QSize maxSize) const;
104 111
105 //!!! how to reap no-longer-used images? 112 //!!! how to reap no-longer-used images?
106 113
107 typedef std::map<QString, QImage> ImageMap; 114 typedef std::map<QString, QImage> ImageMap;
108 typedef std::map<const View *, ImageMap> ViewImageMap; 115 typedef std::map<const View *, ImageMap> ViewImageMap;
109 116 typedef std::map<QString, RemoteFile *> RemoteFileMap;
110
111 117
112 static ImageMap m_images; 118 static ImageMap m_images;
119 static QMutex m_imageMapMutex;
113 mutable ViewImageMap m_scaled; 120 mutable ViewImageMap m_scaled;
121 mutable RemoteFileMap m_remoteFiles;
122
123 QString getLocalFilename(QString img) const;
124 void checkAddRemote(QString img) const;
114 125
115 ImageModel *m_model; 126 ImageModel *m_model;
116 bool m_editing; 127 bool m_editing;
117 QPoint m_editOrigin; 128 QPoint m_editOrigin;
118 ImageModel::Point m_originalPoint; 129 ImageModel::Point m_originalPoint;