#include <recentAlbumMenuItem.h>
Inheritance diagram for RecentAlbumMenuItem:


Definition at line 23 of file recentAlbumMenuItem.h.
Public Member Functions | |
| RecentAlbumMenuItem (Key acceleratorKey) | |
| void | changeItem (QString albumName, QString albumLocation, QString numPhotos) |
| updates entry as per arguments passed (used by constructor during intiailization as well) | |
| 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 | |
| void | setMaxWidth (int val) |
| after all menu items have been refreshed hint at maximum width so we can adequately position the accelerator text | |
| bool | fullSpan () const |
| no icon necessary since album image painted here | |
Private Attributes | |
| Key | acceleratorKey |
| QImage | albumImage |
| album image | |
| QString | albumName |
| album name | |
| QString | numPhotos |
| number of photos | |
| QSize | size |
| computed size | |
| int | maxWidth |
| max element width | |
| int | idealImageWidth |
| used for painting purposes | |
|
|
Definition at line 22 of file recentAlbumMenuItem.cpp. References changeItem(). 00022 : QCustomMenuItem() 00023 { 00024 this->acceleratorKey = acceleratorKey; 00025 changeItem( "unitialized", "unitialized", "unitialized" ); 00026 }
|
|
||||||||||||||||
|
updates entry as per arguments passed (used by constructor during intiailization as well)
Definition at line 28 of file recentAlbumMenuItem.cpp. References albumImage, idealImageWidth, scaleImage(), and size. Referenced by RecentAlbumMenuItem(), and TitleWidget::refreshOpenRecentMenu(). 00031 {
00032 //set name, and number of photos
00033 this->albumName = albumName;
00034 this->numPhotos = numPhotos;
00035
00036 //compute height
00037 QFontMetrics fm( qApp->font() );
00038 size.setHeight( 2 + fm.leading() + 2*fm.height() + 2);
00039
00040 //attempt to set album image
00041 QString albumImageLocation = QDir::convertSeparators( albumLocation + "/img/album.jpg" );
00042 QDir tempDir;
00043 if( tempDir.exists( albumImageLocation ) )
00044 {
00045 //ideal image width assuming 4:3 aspect ratio
00046 idealImageWidth = (4 * (size.height()-4) ) / 3;
00047
00048 //scale image
00049 scaleImage( albumImageLocation, albumImage, idealImageWidth, size.height() );
00050 }
00051 else
00052 {
00053 idealImageWidth = 0;
00054 }
00055
00056 //compute menu entry width
00057 size.setWidth( idealImageWidth + 2 + fm.width(albumName) );
00058 }
|
|
|
no icon necessary since album image painted here
Definition at line 108 of file recentAlbumMenuItem.cpp. 00109 { return true; }
|
|
||||||||||||||||||||||||||||||||||||
|
paints entry
Definition at line 60 of file recentAlbumMenuItem.cpp. References acceleratorKey, albumImage, albumName, idealImageWidth, maxWidth, numPhotos, and size. 00064 {
00065 //move down and right by two for spacing purposes
00066 y+=2;
00067 x+=2;
00068 int xOffset = 0;
00069 int yOffset = 0;
00070
00071 //paint album image first if not null
00072 if(!albumImage.isNull())
00073 {
00074 p->drawImage( x + (idealImageWidth - albumImage.width()) / 2,
00075 y + (size.height() - albumImage.height() - 4)/2,
00076 albumImage );
00077 xOffset+=(idealImageWidth + 2);
00078 }
00079
00080 //paint album name + photo count
00081 QFontMetrics fm( qApp->font() );
00082 yOffset+=fm.ascent();
00083 p->drawText( x+xOffset, y+yOffset, albumName );
00084
00085 //if photo count available print it as well
00086 if(numPhotos.compare("-1") != 0)
00087 {
00088 yOffset+=fm.descent() + 1 + fm.leading() + fm.ascent();
00089 p->drawText( x+xOffset, y+yOffset,
00090 qApp->translate("RecentAlbumMenuItem", "%1 Photos").arg(numPhotos) );
00091 }
00092
00093 //paint accelerator key
00094 if( acceleratorKey != Key_unknown )
00095 {
00096 xOffset = maxWidth + 24;
00097 yOffset = fm.ascent() + fm.height()/2;
00098 QKeySequence seq( CTRL+acceleratorKey );
00099 QString str = (QString)seq;
00100 p->drawText( x+xOffset, y+yOffset,
00101 str);
00102 }
00103 }
|
|
|
after all menu items have been refreshed hint at maximum width so we can adequately position the accelerator text
Definition at line 111 of file recentAlbumMenuItem.cpp. References maxWidth. Referenced by TitleWidget::refreshOpenRecentMenu(). 00112 { maxWidth = val; }
|
|
|
returns menu entry size
Definition at line 105 of file recentAlbumMenuItem.cpp. 00106 { return size; }
|
|
|
Definition at line 48 of file recentAlbumMenuItem.h. Referenced by paint(). |
|
|
album image
Definition at line 51 of file recentAlbumMenuItem.h. Referenced by changeItem(), and paint(). |
|
|
album name
Definition at line 54 of file recentAlbumMenuItem.h. Referenced by paint(). |
|
|
used for painting purposes
Definition at line 66 of file recentAlbumMenuItem.h. Referenced by changeItem(), and paint(). |
|
|
max element width
Definition at line 63 of file recentAlbumMenuItem.h. Referenced by paint(), and setMaxWidth(). |
|
|
number of photos
Definition at line 57 of file recentAlbumMenuItem.h. Referenced by paint(). |
|
|
computed size
Definition at line 60 of file recentAlbumMenuItem.h. Referenced by changeItem(), and paint(). |
1.3.9.1