smf/inc/common/smfpictures/smfpicture.h
author cgandhi <chandradeep.gandhi@sasken.com>
Thu, 15 Apr 2010 15:35:36 +0530
changeset 3 0446eb7b28aa
child 5 edb9dc8273d9
permissions -rw-r--r--
Updating the sample plugin and other related changes for clients and plugins

/**
 * Copyright (c) 2010 Sasken Communication Technologies Ltd.
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the "Eclipse Public License v1.0" 
 * which accompanies  this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html"
 *
 * Initial Contributors:
 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
 *
 * Contributors:
 * Manasij Roy, Nalina Hariharan
 * 
 * Description:
 * The picture class represents an instance of a picture
 *
 */

#ifndef SMFPICTURE_H_
#define SMFPICTURE_H_

#include <QImage>
#include <QDateTime>
#include <QStringList>
#include <QUrl>
#include <qdatastream.h>
#include <QSharedData>
#include <smfclientglobal.h>
#include <QMetaType>

class SmfPicturePrivate;

/**
 * SmfPictureVisibility enumeration
 */
enum SmfPictureVisibility
	{
	SMFVisibilityFriend,
	SMFVisibilityPersonal,
	SMFVisibilityFamily,
	SMFVisibilityGroup,
	SMFVisibilityPublic
	};

/**
 * @ingroup smf_common_group
 * The picture class represents an instance of a picture
 */
class SMFCLIENT_EXPORT SmfPicture : public QObject
	{
	Q_OBJECT
public:
	/**
	 * Constructor with default argument
	 * @param aParent The parent object
	 */
	SmfPicture( QObject *aParent = 0 );
	
	/**
	 * Copy Constructor
	 * @param aOther The reference object
	 */
	SmfPicture( const SmfPicture &aOther );
	
	/**
	 * CConstructs SmfPicture from QImage
	 * @param aOther The QImage
	 */
	SmfPicture( const QImage &image );
	
	/**
	 * Destructor
	 */
	~SmfPicture( );
	
	/**
	 * Method to get the id of the picture
	 * @return The ID value 
	 */
	QString id( ) const;
	
	/**
	 * Method to get a picture owner
	 * @return The owner of the picture
	 */
	QString owner( ) const;
	
	/**
	 * Method to get a picture title
	 * @return The title of the picture
	 */
	QString title( ) const;
	
	/**
	 * Method to get a picture description
	 * @return The description of the picture
	 */
	QString description( ) const;
	
	/**
	 * Method to get a visibility of a picture for public
	 * @return The visibility mode of this picture for others
	 */
	SmfPictureVisibility visibility( ) const;
	
	/**
	 * Method to get the date of posting the picture
	 * @return The posted date of the picture
	 */
	QDateTime postedDate( ) const;
	
	/**
	 * Method to get the comments for the picture
	 * @return The comments for the picture
	 */
	QStringList comments( ) const;
	
	/**
	 * Method to get the tags for the picture
	 * @return The tags for the picture
	 */
	QStringList tags( ) const;
	
	/**
	 * Method to get the url of the picture
	 * @return The url of the picture
	 */
	QUrl url( ) const;
	
	/**
	 * Method to get the picture data as QImage
	 * @return The picture as QImage
	 */
	QImage picture( ) const;
		
	/**
	 * Method to set a picture owner
	 * @param aOwner The owner of the picture
	 */
	void setOwner( const QString &aOwner );
	
	/**
	 * Method to set a picture title
	 * @param aTitle The title of the picture
	 */
	void setTitle( const QString &aTitle );
	
	/**
	 * Method to set a picture description
	 * @param aDescription The description of the picture
	 */
	void setDescription( const QString &aDescription );
	
	/**
	 * Method to set a visibility of a picture for public
	 * @param aVisibility aVisibility The visibility mode of 
	 * this picture for others
	 */
	void setVisibility( const SmfPictureVisibility &aVisibility );
	
	/**
	 * Method to add comment on the picture
	 * @param aComment The comment for the picture
	 */
	void addComment( const QString &aComment );
	
	/**
	 * Method to add tags for the picture
	 * @param aTag The tag for the picture
	 */
	void addTags( const QStringList &aTags );
	
	/**
	 * Method to set the picture data as QImage
	 * @param aData The picture as QImage
	 */
	void setPicture( const QImage &aData );
	
private:
	QSharedDataPointer<SmfPicturePrivate> d;
	
	friend QDataStream &operator<<( QDataStream &aDataStream, 
			const SmfPicture &aPic );

	friend QDataStream &operator>>( QDataStream &aDataStream, 
			SmfPicture &aPic );
	
	};


/**
 * Method for Externalization. Writes the SmfPicture object to 
 * the stream and returns a reference to the stream.
 * @param aDataStream Stream to be written
 * @param aPic The SmfPicture object to be externalized
 * @return reference to the written stream
 */
QDataStream &operator<<( QDataStream &aDataStream, 
		const SmfPicture &aPic );

/**
 * Method for Internalization. Reads a SmfPicture object from 
 * the stream and returns a reference to the stream.
 * @param aDataStream Stream to be read
 * @param aPic The SmfPicture object to be internalized
 * @return reference to the stream
 */
QDataStream &operator>>( QDataStream &aDataStream, 
		SmfPicture &aPic);

// Make the class SmfPicture known to QMetaType, so that as to register it.
Q_DECLARE_METATYPE(SmfPicture)

#endif /* SMFPICTURE_H_ */