Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

RecentAlbumMenuItem Class Reference

#include <recentAlbumMenuItem.h>

Inheritance diagram for RecentAlbumMenuItem:

Inheritance graph
[legend]
Collaboration diagram for RecentAlbumMenuItem:

Collaboration graph
[legend]
List of all members.

Detailed Description

A custom menu entry, displays album image, name, and number of photos.

Definition at line 23 of file recentAlbumMenuItem.h.

Public Member Functions

 RecentAlbumMenuItem (QString albumName, QString albumLocation, QString numPhotos)
void paint (QPainter *p, const QColorGroup &cg, bool act, bool enabled, int x, int y, int w, int h)
 paints entry
QSize sizeHint ()
 returns menu entry size
bool fullSpan () const
 no icon necessary since album image painted here

Private Attributes

QImage albumImage
 album image
QString albumName
 album name
QString numPhotos
 number of photos
QSize size
 computed size
int idealImageWidth
 used for painting purposes


Constructor & Destructor Documentation

RecentAlbumMenuItem::RecentAlbumMenuItem QString  albumName,
QString  albumLocation,
QString  numPhotos
 

Definition at line 21 of file recentAlbumMenuItem.cpp.

References albumImage, idealImageWidth, scaleImage(), and size.

00023                                                               : QCustomMenuItem()
00024 {
00025   //set name, and number of photos
00026   this->albumName = albumName;
00027   this->numPhotos = numPhotos;
00028   
00029   //compute height
00030   QFontMetrics fm( qApp->font() );
00031   size.setHeight( 2 + fm.leading() + 2*fm.height() + 2);
00032   
00033   //attempt to set album image   
00034   QString albumImageLocation = QDir::convertSeparators( albumLocation + "/img/album.jpg" );
00035   QDir tempDir;
00036   if( tempDir.exists( albumImageLocation ) )
00037   {       
00038     //ideal image width assuming 4:3 aspect ratio
00039     idealImageWidth = (4 * (size.height()-4) ) / 3;
00040     
00041     //scale image
00042     scaleImage( albumImageLocation, albumImage, idealImageWidth, size.height() );
00043   }
00044   else
00045   {
00046     idealImageWidth = 0;
00047   }
00048   
00049   //compute menu entry width
00050   size.setWidth( idealImageWidth + 2 + fm.width(albumName) );
00051 }


Member Function Documentation

bool RecentAlbumMenuItem::fullSpan  )  const
 

no icon necessary since album image painted here

Definition at line 88 of file recentAlbumMenuItem.cpp.

00089 { return true; }

void RecentAlbumMenuItem::paint QPainter *  p,
const QColorGroup &  cg,
bool  act,
bool  enabled,
int  x,
int  y,
int  w,
int  h
 

paints entry

Definition at line 53 of file recentAlbumMenuItem.cpp.

References albumImage, albumName, idealImageWidth, numPhotos, and size.

00057 {
00058   //move down and right by two for spacing purposes
00059   y+=2;
00060   x+=2;
00061 
00062   //paint album image first if not null
00063   if(!albumImage.isNull())
00064   {
00065     p->drawImage( x + (idealImageWidth - albumImage.width()) / 2, 
00066                   y + (size.height() - albumImage.height() - 4)/2, 
00067                   albumImage );
00068     x+=(idealImageWidth + 2);
00069   }
00070   
00071   //paint album name + photo count
00072   QFontMetrics fm( qApp->font() );
00073   y+=fm.ascent();
00074   p->drawText( x, y, albumName ); 
00075 
00076   //if photo count available print it as well
00077   if(numPhotos.compare("-1") != 0)
00078   {
00079     y+=fm.descent() + 1 + fm.leading() + fm.ascent();
00080     p->drawText( x, y, 
00081                qApp->translate("RecentAlbumMenuItem", "%1 Photos").arg(numPhotos) );
00082   }
00083 }

QSize RecentAlbumMenuItem::sizeHint  ) 
 

returns menu entry size

Definition at line 85 of file recentAlbumMenuItem.cpp.

00086 { return size; }


Member Data Documentation

QImage RecentAlbumMenuItem::albumImage [private]
 

album image

Definition at line 41 of file recentAlbumMenuItem.h.

Referenced by paint(), and RecentAlbumMenuItem().

QString RecentAlbumMenuItem::albumName [private]
 

album name

Definition at line 44 of file recentAlbumMenuItem.h.

Referenced by paint().

int RecentAlbumMenuItem::idealImageWidth [private]
 

used for painting purposes

Definition at line 53 of file recentAlbumMenuItem.h.

Referenced by paint(), and RecentAlbumMenuItem().

QString RecentAlbumMenuItem::numPhotos [private]
 

number of photos

Definition at line 47 of file recentAlbumMenuItem.h.

Referenced by paint().

QSize RecentAlbumMenuItem::size [private]
 

computed size

Definition at line 50 of file recentAlbumMenuItem.h.

Referenced by paint(), and RecentAlbumMenuItem().


The documentation for this class was generated from the following files:
Generated on Sat Apr 2 05:45:10 2005 for AlbumShaper by  doxygen 1.3.9.1