smf/smfservermodule/smfcommon/smfalbum.cpp
changeset 25 a180113055cb
parent 18 013a02bf2bb0
equal deleted inserted replaced
24:1cee9f1b95e0 25:a180113055cb
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  * Manasij Roy, Nalina Hariharan
    13  * Manasij Roy, Nalina Hariharan
    14  * 
    14  * 
    15  * Description:
    15  * Description:
    16  * The SmfAlbum class represents a music album
    16  * The SmfAlbum class represents an album
    17  *
    17  *
    18  */
    18  */
    19 
    19 
    20 #include <smfalbum.h>
    20 #include <smfalbum.h>
    21 #include <smfalbum_p.h>
    21 #include <smfalbum_p.h>
    44  * @return The target reference value
    44  * @return The target reference value
    45  */
    45  */
    46 SmfAlbum& SmfAlbum::operator=( const SmfAlbum &aOther )
    46 SmfAlbum& SmfAlbum::operator=( const SmfAlbum &aOther )
    47 	{
    47 	{
    48 	d->m_name = aOther.d->m_name;
    48 	d->m_name = aOther.d->m_name;
    49 	d->m_image = aOther.d->m_image;
    49 	d->m_imageUrl = aOther.d->m_imageUrl;
    50 	d->m_artists = aOther.d->m_artists;
    50 	d->m_artists = aOther.d->m_artists;
       
    51 	d->m_location = aOther.d->m_location;
       
    52 	d->m_itemCount = aOther.d->m_itemCount;
       
    53 	d->m_type = aOther.d->m_type;
    51 	d->m_albumId = aOther.d->m_albumId;
    54 	d->m_albumId = aOther.d->m_albumId;
       
    55 	d->m_secondaryId = aOther.d->m_secondaryId;
    52 	return *this;
    56 	return *this;
    53 	}
    57 	}
    54 
    58 
    55 /**
    59 /**
    56  * Destructor
    60  * Destructor
    67 	{
    71 	{
    68 	return d->m_name;
    72 	return d->m_name;
    69 	}
    73 	}
    70 
    74 
    71 /**
    75 /**
    72  * Method to get the album's image
    76  * Method to get the album's image url if any
    73  * @return The album's image
    77  * @return The album's image url if any
    74  */
    78  */
    75 QImage SmfAlbum::image( ) const
    79 QUrl SmfAlbum::imageUrl( ) const
    76 	{
    80 	{
    77 	return d->m_image;
    81 	return d->m_imageUrl;
    78 	}
    82 	}
    79 
    83 
    80 /**
    84 /**
    81  * Method to get the artist names
    85  * Method to get the artist names
    82  * @return The list of artists in the album
    86  * @return The list of artists in the album
    85 	{
    89 	{
    86 	return d->m_artists;
    90 	return d->m_artists;
    87 	}
    91 	}
    88 
    92 
    89 /**
    93 /**
       
    94  * Method to get the location of this album
       
    95  * @return The location of this album
       
    96  */
       
    97 SmfLocation SmfAlbum::location( ) const
       
    98 	{
       
    99 	return d->m_location;
       
   100 	}
       
   101 
       
   102 /**
       
   103  * Method to get the number of items in this album
       
   104  * @return The number of items in this album
       
   105  */
       
   106 int SmfAlbum::itemsCount( ) const
       
   107 	{
       
   108 	return d->m_itemCount;
       
   109 	}
       
   110 
       
   111 /**
       
   112  * Method to get the type of this album
       
   113  * @return The type of this album
       
   114  */
       
   115 SmfAlbumMediaType SmfAlbum::type( ) const
       
   116 	{
       
   117 	return d->m_type;
       
   118 	}
       
   119 
       
   120 /**
    90  * Method to get the id of the album
   121  * Method to get the id of the album
    91  * @return The ID value 
   122  * @return The ID value 
    92  */
   123  */
    93 QString SmfAlbum::id( ) const
   124 QString SmfAlbum::id( ) const
    94 	{
   125 	{
    95 	return d->m_albumId;
   126 	return d->m_albumId;
    96 	}
   127 	}
    97 
   128 
    98 /**
   129 /**
       
   130  * Method to get the secondary id of the album, e.g. musicbrainz id of the album for a music album
       
   131  * @return The ID value 
       
   132  */
       
   133 QString SmfAlbum::secondaryId( ) const
       
   134 	{
       
   135 	return d->m_secondaryId;
       
   136 	}	
       
   137 
       
   138 
       
   139 /**
    99  * Method to set the album name
   140  * Method to set the album name
   100  * @param aName The album name
   141  * @param aName The album name
   101  */
   142  */
   102 void SmfAlbum::setName( const QString &aName )
   143 void SmfAlbum::setName( const QString &aName )
   103 	{
   144 	{
   104 	d->m_name = aName;
   145 	d->m_name = aName;
   105 	}
   146 	}
   106 
   147 
   107 /**
   148 /**
   108  * Method to set the album's image
   149  * Method to set the album's image url
   109  * @param aImage The album's image
   150  * @param aUrl The album's image url
   110  */
   151  */
   111 void SmfAlbum::setImage( const QImage &aImage )
   152 void SmfAlbum::setImageUrl( const QUrl &aUrl )
   112 	{
   153 	{
   113 	d->m_image = aImage;
   154 	d->m_imageUrl = aUrl;
   114 	}
   155 	}
   115 
   156 
   116 /**
   157 /**
   117  * Method to set the artist names
   158  * Method to set the artist names
   118  * @param aArtists The list of artists in the album
   159  * @param aArtists The list of artists in the album
   121 	{
   162 	{
   122 	d->m_artists = aArtists;
   163 	d->m_artists = aArtists;
   123 	}
   164 	}
   124 
   165 
   125 /**
   166 /**
       
   167  * Method to set the location of this album
       
   168  * @param aLoc The location of the album
       
   169  */
       
   170 void SmfAlbum::setLocation(const SmfLocation &aLoc )
       
   171 	{
       
   172 	d->m_location = aLoc;
       
   173 	}
       
   174 
       
   175 /**
       
   176  * Method to set the number of items in this album
       
   177  * @param aCount the number of items in this album
       
   178  */
       
   179 void SmfAlbum::setItemsCount( const int aCount )
       
   180 	{
       
   181 	d->m_itemCount = aCount;
       
   182 	}
       
   183 
       
   184 /**
       
   185  * Method to set the type of this album
       
   186  * @param aType the type of this album
       
   187  */
       
   188 void SmfAlbum::setType(SmfAlbumMediaType aType)
       
   189 	{
       
   190 	d->m_type = aType;
       
   191 	}
       
   192 
       
   193 /**
   126  * Method to set the id of the album
   194  * Method to set the id of the album
   127  * @param aId The ID value 
   195  * @param aId The ID value 
   128  */
   196  */
   129 void SmfAlbum::setId( const QString &aId )
   197 void SmfAlbum::setId( const QString &aId )
   130 	{
   198 	{
   131 	d->m_albumId = aId;
   199 	d->m_albumId = aId;
   132 	}
   200 	}
       
   201 
       
   202 /**
       
   203  * Method to set the secondary id of the album, e.g. musicbrainz id of the album for a music album
       
   204  * @param aSecondaryID the secondaryID of this album 
       
   205  */
       
   206 void SmfAlbum::setSecondaryId( const QString &aSecondaryID )
       
   207 	{
       
   208 	d->m_secondaryId = aSecondaryID;
       
   209 	}
       
   210 
   133 
   211 
   134 /**
   212 /**
   135  * Method for Externalization. Writes the SmfAlbum object to 
   213  * Method for Externalization. Writes the SmfAlbum object to 
   136  * the stream and returns a reference to the stream.
   214  * the stream and returns a reference to the stream.
   137  * @param aDataStream Stream to be written
   215  * @param aDataStream Stream to be written
   142 		const SmfAlbum &aAlbum )
   220 		const SmfAlbum &aAlbum )
   143 	{
   221 	{
   144 	// Serialize d->m_name
   222 	// Serialize d->m_name
   145 	aDataStream<<aAlbum.d->m_name;
   223 	aDataStream<<aAlbum.d->m_name;
   146 	
   224 	
   147 	// Serialize d->m_image
   225 	// Serialize d->m_imageUrl
   148 	aDataStream<<aAlbum.d->m_image;
   226 	aDataStream<<aAlbum.d->m_imageUrl;
   149 	
   227 	
   150 	// Serialize d->m_artists
   228 	// Serialize d->m_artists
   151 	aDataStream<<aAlbum.d->m_artists;
   229 	aDataStream<<aAlbum.d->m_artists;
   152 	
   230 	
       
   231 	// Serialize d->m_location
       
   232 	aDataStream<<aAlbum.d->m_location;
       
   233 	
       
   234 	// Serialize d->m_itemCount
       
   235 	aDataStream<<aAlbum.d->m_itemCount;
       
   236 	
       
   237 	// Serialize d->m_type
       
   238 	aDataStream<<aAlbum.d->m_type;
       
   239 	
   153 	// Serialize d->m_albumId
   240 	// Serialize d->m_albumId
   154 	aDataStream<<aAlbum.d->m_albumId;
   241 	aDataStream<<aAlbum.d->m_albumId;
       
   242 	
       
   243 	// Serialize d->m_secondaryId
       
   244 	aDataStream<<aAlbum.d->m_secondaryId;
   155 	
   245 	
   156 	return aDataStream;
   246 	return aDataStream;
   157 	}
   247 	}
   158 
   248 
   159 /**
   249 /**
   167 		SmfAlbum &aAlbum)
   257 		SmfAlbum &aAlbum)
   168 	{
   258 	{
   169 	// Deserialize d->m_name
   259 	// Deserialize d->m_name
   170 	aDataStream>>aAlbum.d->m_name;
   260 	aDataStream>>aAlbum.d->m_name;
   171 	
   261 	
   172 	// Deserialize d->m_image
   262 	// Deserialize d->m_imageUrl
   173 	aDataStream>>aAlbum.d->m_image;
   263 	aDataStream>>aAlbum.d->m_imageUrl;
   174 	
   264 	
   175 	// Deserialize d->m_artists
   265 	// Deserialize d->m_artists
   176 	aDataStream>>aAlbum.d->m_artists;
   266 	aDataStream>>aAlbum.d->m_artists;
   177 	
   267 	
       
   268 	// Deserialize d->m_location
       
   269 	aDataStream>>aAlbum.d->m_location;
       
   270 	
       
   271 	// Deserialize d->m_itemCount
       
   272 	aDataStream>>aAlbum.d->m_itemCount;
       
   273 	
       
   274 	// Deserialize d->m_type
       
   275 	int val;
       
   276 	aDataStream>>val;
       
   277 	aAlbum.d->m_type = (SmfAlbumMediaType)val;
       
   278 	
   178 	// Deserialize d->m_albumId
   279 	// Deserialize d->m_albumId
   179 	aDataStream>>aAlbum.d->m_albumId;
   280 	aDataStream>>aAlbum.d->m_albumId;
   180 	
   281 	
       
   282 	// Deserialize d->m_secondaryId
       
   283 	aDataStream>>aAlbum.d->m_secondaryId;
       
   284 	
   181 	return aDataStream;
   285 	return aDataStream;
   182 	}
   286 	}