smf/smfservermodule/smfclient/common/smfpicture.cpp
changeset 10 1d94eb8df9c2
parent 9 b85b0c039c14
equal deleted inserted replaced
9:b85b0c039c14 10:1d94eb8df9c2
     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 #include <smfpicture.h>
       
    21 #include <smfpicture_p.h>
       
    22 
       
    23 /**
       
    24  * Constructor with default argument
       
    25  */
       
    26 SmfPicture::SmfPicture( )
       
    27 	{
       
    28 	d = new SmfPicturePrivate;
       
    29 	}
       
    30 
       
    31 /**
       
    32  * Copy Constructor
       
    33  * @param aOther The reference object
       
    34  */
       
    35 SmfPicture::SmfPicture( const SmfPicture &aOther )
       
    36 	: d( aOther.d )
       
    37 	{
       
    38 	}
       
    39 
       
    40 /**
       
    41  * CConstructs SmfPicture from QImage
       
    42  * @param aOther The QImage
       
    43  */
       
    44 SmfPicture::SmfPicture( const QImage &aImage )
       
    45 	{
       
    46 	d = new SmfPicturePrivate(aImage);
       
    47 	}
       
    48 
       
    49 /**
       
    50  * Overloaded = operator
       
    51  * @param aOther The reference object
       
    52  * @return The target reference value
       
    53  */
       
    54 SmfPicture& SmfPicture::operator=( const SmfPicture &aOther )
       
    55 	{
       
    56 	d->m_photoId = aOther.d->m_photoId;
       
    57 	d->m_owner = aOther.d->m_owner;
       
    58 	d->m_title = aOther.d->m_title;
       
    59 	d->m_description = aOther.d->m_description;
       
    60 	d->m_picVisibility = aOther.d->m_picVisibility;
       
    61 	d->m_postedOn = aOther.d->m_postedOn;
       
    62 	d->m_comments = aOther.d->m_comments;
       
    63 	d->m_tags = aOther.d->m_tags;
       
    64 	d->m_url = aOther.d->m_url;
       
    65 	d->m_picture = aOther.d->m_picture;
       
    66 	return *this;
       
    67 	}
       
    68 
       
    69 /**
       
    70  * Destructor
       
    71  */
       
    72 SmfPicture::~SmfPicture( )
       
    73 	{
       
    74 	}
       
    75 
       
    76 /**
       
    77  * Method to get a picture owner
       
    78  * @return The owner of the picture
       
    79  */
       
    80 QString SmfPicture::owner( ) const
       
    81 	{
       
    82 	return d->m_owner;
       
    83 	}
       
    84 
       
    85 /**
       
    86  * Method to get a picture title
       
    87  * @return The title of the picture
       
    88  */
       
    89 QString SmfPicture::title( ) const
       
    90 	{
       
    91 	return d->m_title;
       
    92 	}
       
    93 
       
    94 /**
       
    95  * Method to get a picture description
       
    96  * @return The description of the picture
       
    97  */
       
    98 QString SmfPicture::description( ) const
       
    99 	{
       
   100 	return d->m_description;
       
   101 	}
       
   102 
       
   103 /**
       
   104  * Method to get a visibility of a picture for public
       
   105  * @return The visibility mode of this picture for others
       
   106  */
       
   107 SmfPictureVisibility SmfPicture::visibility( ) const
       
   108 	{
       
   109 	return d->m_picVisibility;
       
   110 	}
       
   111 
       
   112 /**
       
   113  * Method to get the date of posting the picture
       
   114  * @return The posted date of the picture
       
   115  */
       
   116 QDateTime SmfPicture::postedDate( ) const
       
   117 	{
       
   118 	return d->m_postedOn;
       
   119 	}
       
   120 
       
   121 /**
       
   122  * Method to get the comments for the picture
       
   123  * @return The comments for the picture
       
   124  */
       
   125 QList<SmfComment> SmfPicture::comments( ) const
       
   126 	{
       
   127 	return d->m_comments;
       
   128 	}
       
   129 
       
   130 /**
       
   131  * Method to get the tags for the picture
       
   132  * @return The tags for the picture
       
   133  */
       
   134 QStringList SmfPicture::tags( ) const
       
   135 	{
       
   136 	return d->m_tags;
       
   137 	}
       
   138 
       
   139 /**
       
   140  * Method to get the url of the picture
       
   141  * @return The url of the picture
       
   142  */
       
   143 QUrl SmfPicture::url( ) const
       
   144 	{
       
   145 	return d->m_url;
       
   146 	}
       
   147 
       
   148 /**
       
   149  * Method to get the picture data as QImage
       
   150  * @return The picture as QImage
       
   151  */
       
   152 QImage SmfPicture::picture( ) const
       
   153 	{
       
   154 	return d->m_picture;
       
   155 	}
       
   156 	
       
   157 /**
       
   158  * Method to get the id of the picture
       
   159  * @return The ID value 
       
   160  */
       
   161 QString SmfPicture::id( ) const
       
   162 	{
       
   163 	return d->m_photoId;
       
   164 	}
       
   165 
       
   166 /**
       
   167  * Method to set a picture owner
       
   168  * @param aOwner The owner of the picture
       
   169  */
       
   170 void SmfPicture::setOwner( const QString &aOwner )
       
   171 	{
       
   172 	d->m_owner = aOwner;
       
   173 	}
       
   174 
       
   175 /**
       
   176  * Method to set a picture title
       
   177  * @param aTitle The title of the picture
       
   178  */
       
   179 void SmfPicture::setTitle( const QString &aTitle )
       
   180 	{
       
   181 	d->m_title = aTitle;
       
   182 	}
       
   183 
       
   184 /**
       
   185  * Method to set a picture description
       
   186  * @param aDescription The description of the picture
       
   187  */
       
   188 void SmfPicture::setDescription( const QString &aDescription )
       
   189 	{
       
   190 	d->m_description = aDescription;
       
   191 	}
       
   192 
       
   193 /**
       
   194  * Method to set a visibility of a picture for public
       
   195  * @param aVisibility aVisibility The visibility mode of 
       
   196  * this picture for others
       
   197  */
       
   198 void SmfPicture::setVisibility( const SmfPictureVisibility &aVisibility )
       
   199 	{
       
   200 	d->m_picVisibility = aVisibility;
       
   201 	}
       
   202 
       
   203 /**
       
   204  * Method to set the date of posting the picture
       
   205  * @param aDate The post date of the picture
       
   206  */
       
   207 void SmfPicture::setPostedDate( const QDateTime &aDate )
       
   208 	{
       
   209 	d->m_postedOn = aDate;
       
   210 	}
       
   211 
       
   212 /**
       
   213  * Method to add comment on the picture
       
   214  * @param aComment The comment for the picture
       
   215  */
       
   216 void SmfPicture::addComment( const SmfComment &aComment )
       
   217 	{
       
   218 	d->m_comments.append(aComment);
       
   219 	}
       
   220 
       
   221 /**
       
   222  * Method to add tags for the picture
       
   223  * @param aTag The tag for the picture
       
   224  */
       
   225 void SmfPicture::addTags( const QStringList &aTags )
       
   226 	{
       
   227 	d->m_tags = aTags;
       
   228 	}
       
   229 
       
   230 /**
       
   231  * Method to set the url of the picture
       
   232  * @param aUrl The url of the picture
       
   233  */
       
   234 void SmfPicture::setUrl( const QUrl &aUrl )
       
   235 	{
       
   236 	d->m_url = aUrl;
       
   237 	}
       
   238 
       
   239 /**
       
   240  * Method to set the picture data as QImage
       
   241  * @param aData The picture as QImage
       
   242  */
       
   243 void SmfPicture::setPicture( const QImage &aData )
       
   244 	{
       
   245 	d->m_picture = aData;
       
   246 	}
       
   247 
       
   248 /**
       
   249  * Method to set the id of the picture
       
   250  * @param aId The ID value 
       
   251  */
       
   252 void SmfPicture::setId( const QString &aId )
       
   253 	{
       
   254 	d->m_photoId = aId;
       
   255 	}
       
   256 
       
   257 
       
   258 /**
       
   259  * Method for Externalization. Writes the SmfPicture object to 
       
   260  * the stream and returns a reference to the stream.
       
   261  * @param aDataStream Stream to be written
       
   262  * @param aPic The SmfPicture object to be externalized
       
   263  * @return reference to the written stream
       
   264  */
       
   265 QDataStream& operator<<( QDataStream &aDataStream, 
       
   266 		const SmfPicture &aPic )
       
   267 	{
       
   268 	// Serialize d->m_photoId
       
   269 	aDataStream<<aPic.d->m_photoId;
       
   270 	
       
   271 	// Serialize d->m_owner
       
   272 	aDataStream<<aPic.d->m_owner;
       
   273 	
       
   274 	// Serialize d->m_title
       
   275 	aDataStream<<aPic.d->m_title;
       
   276 	
       
   277 	// Serialize d->m_description
       
   278 	aDataStream<<aPic.d->m_description;
       
   279 	
       
   280 	// Serialize d->m_picVisibility
       
   281 	aDataStream<<aPic.d->m_picVisibility;
       
   282 	
       
   283 	// Serialize d->m_postedOn
       
   284 	aDataStream<<aPic.d->m_postedOn;
       
   285 	
       
   286 	// Serialize d->m_comments
       
   287 	aDataStream<<aPic.d->m_comments;
       
   288 	
       
   289 	// Serialize d->m_tags
       
   290 	aDataStream<<aPic.d->m_tags;
       
   291 	
       
   292 	// Serialize d->m_url
       
   293 	aDataStream<<aPic.d->m_url;
       
   294 	
       
   295 	// Serialize d->m_picture
       
   296 	aDataStream<<aPic.d->m_picture;
       
   297 	
       
   298 	return aDataStream;
       
   299 	}
       
   300 
       
   301 /**
       
   302  * Method for Internalization. Reads a SmfPicture object from 
       
   303  * the stream and returns a reference to the stream.
       
   304  * @param aDataStream Stream to be read
       
   305  * @param aPic The SmfPicture object to be internalized
       
   306  * @return reference to the stream
       
   307  */
       
   308 QDataStream& operator>>( QDataStream &aDataStream, 
       
   309 		SmfPicture &aPic)
       
   310 	{
       
   311 	// Deserialize d->m_photoId
       
   312 	aDataStream>>aPic.d->m_photoId;
       
   313 	
       
   314 	// Deserialize d->m_owner
       
   315 	aDataStream>>aPic.d->m_owner;
       
   316 	
       
   317 	// Deserialize d->m_title
       
   318 	aDataStream>>aPic.d->m_title;
       
   319 	
       
   320 	// Deserialize d->m_description
       
   321 	aDataStream>>aPic.d->m_description;
       
   322 	
       
   323 	// Deserialize d->m_picVisibility
       
   324 	quint32 val = aPic.d->m_picVisibility;
       
   325 	aDataStream>>val;
       
   326 	//aPic.d->m_picVisibility = val;
       
   327 
       
   328 	// Deserialize d->m_postedOn
       
   329 	aDataStream>>aPic.d->m_postedOn;
       
   330 	
       
   331 	// Deserialize d->m_comments
       
   332 	aDataStream>>aPic.d->m_comments;
       
   333 	
       
   334 	// Deserialize d->m_tags
       
   335 	aDataStream>>aPic.d->m_tags;
       
   336 	
       
   337 	// Deserialize d->m_url
       
   338 	aDataStream>>aPic.d->m_url;
       
   339 	
       
   340 	// Deserialize d->m_picture
       
   341 	aDataStream>>aPic.d->m_picture;
       
   342 	
       
   343 	return aDataStream;
       
   344 	}