smf/smfservermodule/smfcommon/smfpicture.h
changeset 18 013a02bf2bb0
equal deleted inserted replaced
17:106a4bfcb866 18:013a02bf2bb0
       
     1 /**
       
     2  * Copyright (c) 2010 Sasken Communication Technologies Ltd.
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the "Eclipse Public License v1.0" 
       
     6  * which accompanies  this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html"
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
       
    11  *
       
    12  * Contributors:
       
    13  * Manasij Roy, Nalina Hariharan
       
    14  * 
       
    15  * Description:
       
    16  * The picture class represents an instance of a picture
       
    17  *
       
    18  */
       
    19 
       
    20 #ifndef SMFPICTURE_H_
       
    21 #define SMFPICTURE_H_
       
    22 
       
    23 #include <QImage>
       
    24 #include <QDateTime>
       
    25 #include <QStringList>
       
    26 #include <QUrl>
       
    27 #include <qdatastream.h>
       
    28 #include <QSharedData>
       
    29 #include <smfclientglobal.h>
       
    30 #include <QMetaType>
       
    31 #include <smfcomment.h>
       
    32 
       
    33 class SmfPicturePrivate;
       
    34 /**
       
    35  * Max size for one SmfPicture
       
    36  */
       
    37 const int MaxSmfPictureSize = 1000;
       
    38 /**
       
    39  * SmfPictureVisibility enumeration
       
    40  */
       
    41 enum SmfPictureVisibility
       
    42 	{
       
    43 	SMFVisibilityFriend,
       
    44 	SMFVisibilityPersonal,
       
    45 	SMFVisibilityFamily,
       
    46 	SMFVisibilityGroup,
       
    47 	SMFVisibilityPublic
       
    48 	};
       
    49 
       
    50 /**
       
    51  * @ingroup smf_common_group
       
    52  * The picture class represents an instance of a picture
       
    53  */
       
    54 class SMFCOMMON_EXPORT SmfPicture
       
    55 	{
       
    56 public:
       
    57 	/**
       
    58 	 * Constructor with default argument.
       
    59 	 * @param aDownloaded This flag is to know whether the content is downloaded
       
    60 	 * in the device(if true). If false it signifies that SmfPicture contains
       
    61 	 * a link/url to the location of the content
       
    62 	 */
       
    63 	SmfPicture(/*bool aDownloaded = false*/ );
       
    64 	
       
    65 	/**
       
    66 	 * Copy Constructor
       
    67 	 * @param aOther The reference object
       
    68 	 */
       
    69 	SmfPicture( const SmfPicture &aOther );
       
    70 	
       
    71 	/**
       
    72 	 * CConstructs SmfPicture from QImage
       
    73 	 * @param aImage The QImage
       
    74 	 */
       
    75 	SmfPicture( const QImage &aImage );
       
    76 	
       
    77 	/**
       
    78 	 * Overloaded = operator
       
    79 	 * @param aOther The reference object
       
    80 	 * @return The current object reference
       
    81 	 */
       
    82 	SmfPicture& operator=(const SmfPicture &aOther);
       
    83 	
       
    84 	/**
       
    85 	 * Destructor
       
    86 	 */
       
    87 	~SmfPicture( );
       
    88 	
       
    89 	/**
       
    90 	 * Method to get a picture owner
       
    91 	 * @return The owner of the picture
       
    92 	 */
       
    93 	QString owner( ) const;
       
    94 	
       
    95 	/**
       
    96 	 * Method to get a picture title
       
    97 	 * @return The title of the picture
       
    98 	 */
       
    99 	QString title( ) const;
       
   100 	
       
   101 	/**
       
   102 	 * Method to get a picture description
       
   103 	 * @return The description of the picture
       
   104 	 */
       
   105 	QString description( ) const;
       
   106 	
       
   107 	/**
       
   108 	 * Method to get a visibility of a picture for public
       
   109 	 * @return The visibility mode of this picture for others
       
   110 	 */
       
   111 	SmfPictureVisibility visibility( ) const;
       
   112 	
       
   113 	/**
       
   114 	 * Method to get the date of posting the picture
       
   115 	 * @return The posted date of the picture
       
   116 	 */
       
   117 	QDateTime postedDate( ) const;
       
   118 	
       
   119 	/**
       
   120 	 * Method to get the comments for the picture
       
   121 	 * @return The comments for the picture
       
   122 	 */
       
   123 	QList<SmfComment> comments( ) const;
       
   124 	
       
   125 	/**
       
   126 	 * Method to get the tags for the picture
       
   127 	 * @return The tags for the picture
       
   128 	 */
       
   129 	QStringList tags( ) const;
       
   130 	
       
   131 	/**
       
   132 	 * Method to get the url of the picture
       
   133 	 * @return The url of the picture
       
   134 	 */
       
   135 	QUrl url( ) const;
       
   136 	
       
   137 	/**
       
   138 	 * Method to get the picture data as QImage
       
   139 	 * @return The picture as QImage
       
   140 	 */
       
   141 	QImage picture( ) const;
       
   142 	
       
   143 	/**
       
   144 	 * Method to get the id of the picture
       
   145 	 * @return The ID value 
       
   146 	 */
       
   147 	QString id( ) const;
       
   148 	
       
   149 	/**
       
   150 	 * Gets download flag. This flag is to know whether the content is downloaded
       
   151 	 * in the device(if true). If false it signifies that SmfPicture contains
       
   152 	 * a link/url to the location of the content
       
   153 	 */
       
   154 	bool downloadFlag();
       
   155 			
       
   156 	/**
       
   157 	 * Method to set a picture owner
       
   158 	 * @param aOwner The owner of the picture
       
   159 	 */
       
   160 	void setOwner( const QString &aOwner );
       
   161 	
       
   162 	/**
       
   163 	 * Method to set a picture title
       
   164 	 * @param aTitle The title of the picture
       
   165 	 */
       
   166 	void setTitle( const QString &aTitle );
       
   167 	
       
   168 	/**
       
   169 	 * Method to set a picture description
       
   170 	 * @param aDescription The description of the picture
       
   171 	 */
       
   172 	void setDescription( const QString &aDescription );
       
   173 	
       
   174 	/**
       
   175 	 * Method to set a visibility of a picture for public
       
   176 	 * @param aVisibility aVisibility The visibility mode of 
       
   177 	 * this picture for others
       
   178 	 */
       
   179 	void setVisibility( const SmfPictureVisibility &aVisibility );
       
   180 	
       
   181 	/**
       
   182 	 * Method to set the date of posting the picture
       
   183 	 * @param aDate The post date of the picture
       
   184 	 */
       
   185 	void setPostedDate( const QDateTime &aDate );
       
   186 	
       
   187 	/**
       
   188 	 * Method to add comment on the picture
       
   189 	 * @param aComment The comment for the picture
       
   190 	 */
       
   191 	void addComment( const SmfComment &aComment );
       
   192 	
       
   193 	/**
       
   194 	 * Method to add tags for the picture
       
   195 	 * @param aTag The tag for the picture
       
   196 	 */
       
   197 	void addTags( const QStringList &aTags );
       
   198 	
       
   199 	/**
       
   200 	 * Method to set the url of the picture
       
   201 	 * @param aUrl The url of the picture
       
   202 	 */
       
   203 	void setUrl( const QUrl &aUrl );
       
   204 	
       
   205 	/**
       
   206 	 * Method to set the picture data as QImage
       
   207 	 * @param aData The picture as QImage
       
   208 	 */
       
   209 	void setPicture( const QImage &aData );
       
   210 	
       
   211 	/**
       
   212 	 * Method to set the id of the picture
       
   213 	 * @param aId The ID value 
       
   214 	 */
       
   215 	void setId( const QString &aId );
       
   216 	
       
   217 private:
       
   218 	QSharedDataPointer<SmfPicturePrivate> d;
       
   219 	
       
   220 	friend QDataStream& operator<<( QDataStream &aDataStream, 
       
   221 			const SmfPicture &aPic );
       
   222 
       
   223 	friend QDataStream& operator>>( QDataStream &aDataStream, 
       
   224 			SmfPicture &aPic );
       
   225 	
       
   226 	};
       
   227 
       
   228 
       
   229 /**
       
   230  * Method for Externalization. Writes the SmfPicture object to 
       
   231  * the stream and returns a reference to the stream.
       
   232  * @param aDataStream Stream to be written
       
   233  * @param aPic The SmfPicture object to be externalized
       
   234  * @return reference to the written stream
       
   235  */
       
   236 SMFCOMMON_EXPORT QDataStream& operator<<( QDataStream &aDataStream, 
       
   237 		const SmfPicture &aPic );
       
   238 
       
   239 /**
       
   240  * Method for Internalization. Reads a SmfPicture object from 
       
   241  * the stream and returns a reference to the stream.
       
   242  * @param aDataStream Stream to be read
       
   243  * @param aPic The SmfPicture object to be internalized
       
   244  * @return reference to the stream
       
   245  */
       
   246 SMFCOMMON_EXPORT QDataStream& operator>>( QDataStream &aDataStream, 
       
   247 		SmfPicture &aPic);
       
   248 
       
   249 typedef QList<SmfPicture> SmfPictureList;
       
   250 
       
   251 // Make the class SmfPicture known to QMetaType, so that as to register it.
       
   252 Q_DECLARE_METATYPE(SmfPicture)
       
   253 Q_DECLARE_METATYPE(QList<SmfPicture>)
       
   254 
       
   255 #endif /* SMFPICTURE_H_ */