#include <recentAlbumMenuItem.h>
Inheritance diagram for RecentAlbumMenuItem:
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 |
|
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 }
|
|
no icon necessary since album image painted here
Definition at line 88 of file recentAlbumMenuItem.cpp. 00089 { return true; }
|
|
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 }
|
|
returns menu entry size
Definition at line 85 of file recentAlbumMenuItem.cpp. 00086 { return size; }
|
|
album image
Definition at line 41 of file recentAlbumMenuItem.h. Referenced by paint(), and RecentAlbumMenuItem(). |
|
album name
Definition at line 44 of file recentAlbumMenuItem.h. Referenced by paint(). |
|
used for painting purposes
Definition at line 53 of file recentAlbumMenuItem.h. Referenced by paint(), and RecentAlbumMenuItem(). |
|
number of photos
Definition at line 47 of file recentAlbumMenuItem.h. Referenced by paint(). |
|
computed size
Definition at line 50 of file recentAlbumMenuItem.h. Referenced by paint(), and RecentAlbumMenuItem(). |