Walls And Holes  1
imageandsource.h
Go to the documentation of this file.
1 #ifndef IMAGEANDSOURCE_H
2 #define IMAGEANDSOURCE_H
3 
4 #include <QSharedPointer>
5 #include <QImage>
6 #include <QMap>
7 
9 
10 typedef QSharedPointer<ImageAndSource> SharedImageAndSource;
11 
13 {
14 public:
15  static SharedImageAndSource getSharedImageAndSource(QString filePath);
16 
17  // TODO: This should probably return a const ref instead
18  QSharedPointer<QImage> image() { return mImage; }
19  const QString &source() const { return mSource; }
20 
21 private:
22  ImageAndSource(QString filePath)
23  : mSource(filePath)
24  , mImage(QSharedPointer<QImage>::create(filePath))
25  {
26  if (mImage->isNull())
27  mSource = "";
28  }
29 
30  QString mSource;
31  QSharedPointer<QImage> mImage;
32 
33  static QMap<QString, SharedImageAndSource> mLoadedImages;
34 };
35 
36 #endif // IMAGEANDSOURCE_H
QSharedPointer< ImageAndSource > SharedImageAndSource
Definition: imageandsource.h:8
Definition: imageandsource.h:12
const QString & source() const
Definition: imageandsource.h:19
static SharedImageAndSource getSharedImageAndSource(QString filePath)
Definition: imageandsource.cpp:5
QSharedPointer< QImage > image()
Definition: imageandsource.h:18