• Main Page
  • Classes
  • Files
  • File List

/home/bifh8/cs2009q3-i386/work/meegotouch-controlpanelapplets-0.20.61/src/wallpaperapplet/wallpaperdescriptor.h

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (directui@nokia.com)
00006 **
00007 ** This file is part of meegotouch-controlpanelapplets.
00008 **
00009 ** If you have questions regarding the use of this file, please contact
00010 ** Nokia at directui@nokia.com.
00011 **
00012 ** This library is free software; you can redistribute it and/or
00013 ** modify it under the terms of the GNU Lesser General Public
00014 ** License version 2.1 as published by the Free Software Foundation
00015 ** and appearing in the file LICENSE.LGPL included in the packaging
00016 ** of this file.
00017 **
00018 ****************************************************************************/
00019 #ifndef WALLPAPERDESCRIPTOR_H
00020 #define WALLPAPERDESCRIPTOR_H
00021 
00022 #include <QObject>
00023 #include <QPointer>
00024 #include <QMetaType>
00025 #include <QPixmap>
00026 #include <QUrl>
00027 #include <QVector>
00028 #include <MApplication>
00029 #include <meegocontrolexport.h>
00030 
00035 #define THUMBNAILER_SINGLETON
00036 
00037 #ifdef HAVE_QUILL_FILTER
00038 #  include <QuillFile>
00039 #  include <QuillImage>
00040 #  include <QuillImageFilterFactory>
00041    typedef QuillImage WallPaperImage;
00042 #else
00043 #  include <QImage>
00044    typedef QImage WallPaperImage;
00045 #endif
00046 
00047 #ifdef HAVE_QUILL_METADATA
00048 #  include <QuillMetadata>
00049 #endif
00050 /*
00051  * In the functional tests we use the real thing, in the unit tests we use the
00052  * stubbed version. 
00053  */
00054 #if defined(UNIT_TEST) && !defined(FUNCTIONAL_TEST)
00055 #  include "thumbnailerstub.h"
00056 #else
00057 #  include <Thumbnailer>
00058 #endif
00059 
00060 using namespace Thumbnails;
00061 
00062 class QString;
00063 
00064 
00065 // If this macro is enabled the thumbnail file will be loaded by the class
00066 // itself. This way we can try to eliminate the aspect ratio distortion, but
00067 // since the current version of the thumbler does not provide such a flavor (or
00068 // it is just me who did not find such a flavor) using our own implementation 
00069 // to paint will not solve the problem.
00070 #undef USE_PAINTER
00071 
00076 class MC_EXPORT Image : public QObject {
00077     Q_OBJECT
00078 
00079 public:
00080     Image ();
00081     ~Image ();
00082     Image(const Image&);
00083     Image &operator= (const Image &rhs);
00084     
00085     void reset ();
00086 
00087     void setFilename (const QString &fileName);
00088     QString filename () const;
00089 
00090     void setMimeType (const QString &mimeType);
00091     QString mimeType () const;
00092 
00093     void setImageID (const QString &imageID);
00094     QString imageID () const;
00095     
00096     void setUrl (const QString &urlString);
00097     QUrl url () const {return m_Url;};
00098 
00099     QString basename () const;
00100     QString extension () const;
00101 
00102     bool hasThumbnail () const { return m_HasThumbnail; };
00103     QPixmap thumbnailPixmap () const {return m_ThumbnailPixmap;};
00104     bool setThumbnailPixmap (const QPixmap &pixmap); 
00105     bool thumbnail (bool force = false);
00106 
00107     bool load (const QString &fileName);
00108     void cache (bool threadSafe = false);
00109     void unCache ();
00110 
00111     QImage &image ();
00112     QImage scaledImage (QSize size);
00113     void preScale (QSize size, bool threadSafe = false);
00114 
00115 private:
00116     QString   m_Filename;
00117     QString   m_MimeType;
00118     QString   m_ImageID;
00119     bool      m_Cached;
00120     QUrl      m_Url;  
00121     QPixmap   m_ThumbnailPixmap;
00122     bool      m_HasThumbnail;
00123     WallPaperImage  m_Image;
00124 
00125     friend class WallpaperDescriptor;
00126     #ifdef UNIT_TEST
00127     friend class Ut_WallpaperDescriptor;
00128     friend class Ft_WallpaperDescriptor;
00129     friend class Ut_WallpaperModel;
00130     #endif
00131 };
00132 
00138 class MC_EXPORT WallpaperDescriptor : public QObject {
00139     Q_OBJECT
00140 
00141 public:
00142 
00143     typedef enum {
00144         Landscape   = 0,
00145         Portrait,
00146         OriginalLandscape,
00147         OriginalPortrait,
00148         NVariants
00149     } ImageVariant;
00150 
00151     WallpaperDescriptor (
00152             QObject *parent = NULL);
00153     
00154     WallpaperDescriptor (const QString &filename);
00155     WallpaperDescriptor (const WallpaperDescriptor &orig);
00156     ~WallpaperDescriptor ();
00157 
00158     void setFilename (
00159             const QString &filename,
00160             ImageVariant   variant = WallpaperDescriptor::Portrait);
00161     QString filename (
00162             ImageVariant   variant = WallpaperDescriptor::Portrait) const;
00163     
00164     void setMimeType (
00165             const QString &mimeType,
00166             ImageVariant   variant = WallpaperDescriptor::Portrait);
00167     QString mimeType (
00168             ImageVariant   variant = WallpaperDescriptor::Portrait) const;
00169 
00170 
00171     void setImageID  (
00172             const QString &imageID,
00173             ImageVariant   variant = WallpaperDescriptor::Portrait);
00174     QString imageID (
00175             ImageVariant   variant = WallpaperDescriptor::Portrait) const;
00176 
00177     void setUrl (
00178             const QString &urlString,
00179             ImageVariant   variant = WallpaperDescriptor::Portrait);
00180 
00181     QString basename (
00182             ImageVariant   variant = WallpaperDescriptor::Portrait) const;
00183     QString extension (
00184             ImageVariant   variant = WallpaperDescriptor::Portrait) const;
00185     
00186     virtual bool isCurrent () const;
00187     virtual int version () const;
00188     
00189     virtual QString suggestedOutputFilename (
00190             M::Orientation orientation,
00191             int            ver = -1) const;
00192     virtual QString suggestedOutputMimeType (
00193             M::Orientation orientation);
00194 
00195     virtual QString originalImageFile (M::Orientation orientation) const;
00196     virtual bool valid () const;
00197 
00198     bool isThumbnailLoaded (
00199             ImageVariant   variant = WallpaperDescriptor::Portrait) const;
00200 
00201     QPixmap thumbnailPixmap () const;
00202 
00203     void cache (
00204             ImageVariant   variant = WallpaperDescriptor::Portrait);
00205     void unCache (ImageVariant variant);
00206     void unCache ();
00207     
00208     bool loading () const;
00209     void setLoading (bool loading = true);
00210     QImage &image (
00211             ImageVariant   variant = WallpaperDescriptor::Portrait);
00212 #if 0
00213     QImage scaledImage (
00214             QSize size,
00215             ImageVariant   variant = WallpaperDescriptor::Portrait);
00216 #endif
00217 
00218     void loadAll ();
00219 
00220 public slots:
00221     void initiateThumbnailer ();
00222 
00223 private slots:
00224     void thumbnailReady (
00225             QUrl         fileUri, 
00226             QUrl         thumbnailUri, 
00227             QPixmap      pixmap, 
00228             QString      flavor);
00229     void thumbnailError (
00230             QString      message,
00231             QUrl         url);
00232     void thumbnailLoadingFinished (
00233             int          left);
00234 
00235 signals:
00236     void thumbnailLoaded (WallpaperDescriptor *desc);
00237     void changed (WallpaperDescriptor *desc);
00238     
00239 protected:
00240     QVector<Image>        m_Images;
00241     QPointer<Thumbnailer> m_Thumbnailer;
00242     bool                  m_Loading;
00243 
00244     #ifdef UNIT_TEST
00245     friend class Ut_WallpaperDescriptor;
00246     friend class Ft_WallpaperDescriptor;
00247     friend class Ut_WallpaperModel;
00248     #endif
00249 };
00250 
00251 Q_DECLARE_METATYPE(WallpaperDescriptor)
00252 Q_DECLARE_METATYPE(WallpaperDescriptor *)
00253 
00254 #endif
00255 

Generated on Mon Jul 11 2011 12:00:31 for libMeegoControl by  doxygen 1.7.1