mysocials-core 1.0
|
00001 00007 #ifndef PHOTO_H 00008 #define PHOTO_H 00009 00010 #include <QObject> 00011 #include <QString> 00012 #include <QImage> 00013 #include <QTextCodec> 00014 #include <QMetaType> 00015 #include <QDomDocument> 00016 #include <QFile> 00017 00018 #include "utils/qrefreshlist.h" 00019 class Photo; 00020 00025 typedef QRefreshList<Photo> PhotoList; 00026 00027 #include "photocomments.h" 00028 #include "album.h" 00029 00030 #define FILE_PHOTO_COMMENTS_DATA "comments_%1_%2_%3.xml" 00031 #define NODE_PHOTO_COMMENTS_ROOT "comments" 00032 00033 #define NODE_PHOTO_ROOT "photo" 00034 #define NODE_PHOTO_ID "id" 00035 #define NODE_PHOTO_CREATE "create" 00036 #define NODE_PHOTO_IMAGE "image" 00037 #define NODE_PHOTO_IMAGE_URL "image_url" 00038 #define NODE_PHOTO_ICON "icon" 00039 #define NODE_PHOTO_ICON_URL "icon_url" 00040 #define NODE_PHOTO_DESCRIPTION "description" 00041 00042 00046 class Photo : public QObject 00047 { 00048 Q_OBJECT 00049 00050 public: 00051 Photo(); 00052 Photo(const Photo& source); 00053 00054 QString photoId; //<! photo ID from service 00055 00056 QString albumId; //<! album ID from service 00057 00058 QString ownerId; //<! user ID from service 00059 00060 QString time_create; //<! creation time 00061 00062 QString icon_url; //<! path to thumbnail (icon) 00063 00064 QString icon; //<! path to downloaded icon 00065 00066 QString photo_url; //<! path to large image 00067 00068 QString photo; //<! path to downloaded large image 00069 00070 QString description; //<! photo description 00071 00072 QString accountId; //<! the name of account of this friend (not stored in cache) 00073 00074 // store photolist data to XML format 00075 QDomElement toQDomElement(QDomDocument& doc) const; 00076 00077 // store photolist data to XML format 00078 static QDomElement toQDomElement(QDomDocument& doc, const Photo& src); 00079 00080 // load photolist from XML struct 00081 static Photo fromQDomElement(const QDomElement& fr, const QString& accountId, 00082 const QString& friendId, const QString& albumId); 00083 00084 static void copyData(Photo *dst, const Photo *src); 00085 00086 Photo& operator=(const Photo& source); 00087 00088 // load photo comments from cache file. 00089 PhotoCommentList getPhotoComments() const; 00090 00091 // set photo comments and store it to cache file. 00092 static void setPhotoComments(const PhotoCommentList& list, const QString& accountId, 00093 const QString& friendId, const QString& albumId, const QString& photoId); 00094 00102 static QString getKey(const PhotoList& photos); 00103 00111 static QString getKey(const Photo& photo); 00112 00120 static QString getKey(const Album& album); 00121 00122 static PhotoList loadPhotoList(const QString& accountId, const QString& ownerId, const QString& albumId); 00123 }; 00124 00125 Q_DECLARE_METATYPE(Photo) 00126 //Q_DECLARE_METATYPE(Photo*) 00127 Q_DECLARE_METATYPE(PhotoList) 00128 00129 #endif