Album Statistics Window. More...
#include <albumStatistics.h>
Signals | |
void | closed () |
Public Member Functions | |
AlbumStatistics (Album *album, QWidget *parent=0, const char *name=0) | |
Private Slots | |
void | setCreationDate () |
void | reject () |
Private Member Functions | |
void | closeEvent (QCloseEvent *e) |
Private Attributes | |
Album * | album |
QGridLayout * | grid |
QGridLayout * | grid2 |
QLabel * | titleMessage |
QLabel * | numSubalbums |
QLabel * | numSubalbumsVal |
QLabel * | numPhotos |
QLabel * | numPhotosVal |
QLabel * | sizeOnDisk |
QLabel * | sizeOnDiskVal |
QLabel * | created |
QLabel * | createdVal |
QPushButton * | setCreatedVal |
QLabel * | modified |
QLabel * | modifiedVal |
QFrame * | albumPreview |
QPixmap * | albumImage |
QLabel * | albumIcon |
QLabel * | albumTitle |
QPushButton * | closeButton |
Close button. |
Definition at line 30 of file albumStatistics.h.
Definition at line 31 of file albumStatistics.cpp.
References albumIcon, albumImage, albumPreview, albumTitle, calcScaledImageDimensions(), closeButton, created, createdVal, Album::getCreationDay(), Album::getCreationMonth(), Album::getCreationYear(), Subalbum::getFirst(), Album::getFirstSubalbum(), Photo::getImageFilename(), Album::getModificationDay(), Album::getModificationMonth(), Album::getModificationYear(), Album::getName(), Subalbum::getNext(), Photo::getNext(), Album::getNumPhotos(), Album::getNumSubalbums(), Album::getRepresentativeImage(), Photo::getSlideshowFilename(), grid, grid2, LARGE, modified, modifiedVal, numPhotos, numPhotosVal, numSubalbums, numSubalbumsVal, sizeOnDisk, sizeOnDiskVal, titleMessage, and WIDGET_SPACING.
00034 : 00035 QDialog(parent,name) 00036 { 00037 //-------------------------------------------------------------- 00038 QColor white(255, 255, 255); 00039 QColor darkBlue(35, 75, 139); 00040 //-------------------------------------------------------------- 00041 //this album pointer 00042 this->album = album; 00043 //-- 00044 //compute size on disk 00045 int albumSize = 0; 00046 Subalbum* curSubalbum = album->getFirstSubalbum(); 00047 QFileInfo info; 00048 while(curSubalbum != NULL) 00049 { 00050 Photo* curPhoto = curSubalbum->getFirst(); 00051 while(curPhoto != NULL) 00052 { 00053 info.setFile( curPhoto->getImageFilename() ); 00054 albumSize+=info.size(); 00055 00056 info.setFile( curPhoto->getSlideshowFilename() ); 00057 albumSize+=info.size(); 00058 00059 curPhoto = curPhoto->getNext(); 00060 } 00061 curSubalbum = curSubalbum->getNext(); 00062 } 00063 //-- 00064 //set window title 00065 setCaption( tr("Album Statistics")); 00066 //-- 00067 //create title 00068 titleMessage = new QLabel( tr("Album Statistics:"), this); 00069 00070 QFont titleFont = titleMessage->font(); 00071 titleFont.setWeight(QFont::Bold); 00072 titleFont.setPointSize( titleFont.pointSize() + 2 ); 00073 00074 QFont statsFont = titleMessage->font(); 00075 statsFont.setWeight(QFont::Bold); 00076 00077 titleMessage->setFont( titleFont ); 00078 //-- 00079 //create stats 00080 //-- 00081 numSubalbums = new QLabel( tr("Collections:"), this); 00082 numSubalbums->setFont( statsFont ); 00083 numSubalbumsVal = new QLabel(this); 00084 numSubalbumsVal->setText( QString("%1").arg(album->getNumSubalbums()) ); 00085 numSubalbumsVal->setFont( statsFont ); 00086 //-- 00087 numPhotos = new QLabel( tr("Photos:"), this); 00088 numPhotos->setFont( statsFont ); 00089 numPhotosVal = new QLabel(this); 00090 numPhotosVal->setText( QString("%1").arg(album->getNumPhotos()) ); 00091 numPhotosVal->setFont( statsFont ); 00092 //-- 00093 sizeOnDisk = new QLabel( tr("Size:"), this); 00094 sizeOnDisk->setFont( statsFont ); 00095 sizeOnDiskVal = new QLabel(this); 00096 sizeOnDiskVal->setFont( statsFont ); 00097 if(albumSize < 1024) 00098 sizeOnDiskVal->setText( QString(tr("~%1 Bytes")).arg(albumSize) ); 00099 else if( albumSize/1024 < 1024) 00100 sizeOnDiskVal->setText( QString(tr("~%1 Kb")).arg( ((float)albumSize)/1024 ) ); 00101 else if( albumSize/(1024*1024) < 1024) 00102 sizeOnDiskVal->setText( QString(tr("~%1 Mb")).arg( ((float)albumSize)/(1024*1024) ) ); 00103 else 00104 sizeOnDiskVal->setText( QString(tr("~%1 Gigs")).arg( ((float)albumSize)/(1024*1024*1024) ) ); 00105 //-- 00106 QString months[] = { tr("January"), 00107 tr("February"), 00108 tr("March"), 00109 tr("April"), 00110 tr("May"), 00111 tr("June"), 00112 tr("July"), 00113 tr("August"), 00114 tr("September"), 00115 tr("October"), 00116 tr("November"), 00117 tr("December") }; 00118 00119 created = new QLabel( tr("Created:"), this); 00120 created->setFont( statsFont ); 00121 QString cVal = QString("%1 %2").arg(months[album->getCreationMonth()-1]).arg(album->getCreationDay()); 00122 if(album->getCreationDay() == 1 || 00123 album->getCreationDay() == 21 || 00124 album->getCreationDay() == 31) 00125 cVal = cVal + "st"; 00126 else if(album->getCreationDay() == 2 || 00127 album->getCreationDay() == 22) 00128 cVal = cVal + "nd"; 00129 else if(album->getCreationDay() == 3 || 00130 album->getCreationDay() == 23) 00131 cVal = cVal + "rd"; 00132 else 00133 cVal = cVal + "th"; 00134 cVal = QString("%1, %2").arg(cVal).arg(album->getCreationYear()); 00135 00136 createdVal = new QLabel( cVal, this ); 00137 createdVal->setFont( statsFont ); 00138 00139 modified = new QLabel( tr("Modified:"), this); 00140 modified->setFont( statsFont ); 00141 QString mVal = QString("%1 %2").arg(months[album->getModificationMonth()-1]).arg(album->getModificationDay()); 00142 00143 if(album->getModificationDay() == 1 || 00144 album->getModificationDay() == 21 || 00145 album->getModificationDay() == 31) 00146 mVal = mVal + "st"; 00147 else if(album->getModificationDay() == 2 || 00148 album->getModificationDay() == 22) 00149 mVal = mVal + "nd"; 00150 else if(album->getModificationDay() == 3 || 00151 album->getModificationDay() == 23) 00152 mVal = mVal + "rd"; 00153 else 00154 mVal = mVal + "th"; 00155 mVal = QString("%1, %2").arg(mVal).arg(album->getModificationYear()); 00156 modifiedVal = new QLabel( mVal, this ); 00157 modifiedVal->setFont( statsFont ); 00158 //-- 00159 //create album image and title labels 00160 albumPreview = new QFrame( this ); 00161 albumIcon = new QLabel( albumPreview ); 00162 00163 //if no rep image use small version 00164 if(album->getRepresentativeImage(LARGE) != NULL) 00165 { 00166 QImage tImage = album->getRepresentativeImage( LARGE )->convertToImage(); 00167 int newWidth, newHeight; 00168 calcScaledImageDimensions( tImage.width(), tImage.height(), 00169 300, 300, 00170 newWidth, newHeight); 00171 QImage tImage2 = tImage.smoothScale( newWidth, newHeight ); 00172 albumImage = new QPixmap( newWidth, newHeight ); 00173 albumImage->convertFromImage( tImage2 ); 00174 albumIcon->setPixmap( *albumImage ); 00175 } 00176 00177 albumTitle = new QLabel( albumPreview ); 00178 if(album->getName().compare("") != 0) 00179 { 00180 albumTitle->setText( "\"" + album->getName() + "\"" ); 00181 } 00182 albumTitle->setFont( statsFont ); 00183 //-- 00184 //create close button 00185 closeButton = new QPushButton( tr("Close"), this ); 00186 closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); 00187 closeButton->setDefault(true); 00188 closeButton->setFocus(); 00189 connect( closeButton, SIGNAL(clicked()), SLOT(close()) ); 00190 //-- 00191 setPaletteBackgroundColor( darkBlue ); 00192 titleMessage->setPaletteForegroundColor( white ); 00193 titleMessage->setPaletteBackgroundColor( darkBlue ); 00194 numSubalbums->setPaletteForegroundColor( white ); 00195 numSubalbums->setPaletteBackgroundColor( darkBlue ); 00196 numSubalbumsVal->setPaletteForegroundColor( white ); 00197 numSubalbumsVal->setPaletteBackgroundColor( darkBlue ); 00198 numPhotos->setPaletteForegroundColor( white ); 00199 numPhotos->setPaletteBackgroundColor( darkBlue ); 00200 numPhotosVal->setPaletteForegroundColor( white ); 00201 numPhotosVal->setPaletteBackgroundColor( darkBlue ); 00202 sizeOnDisk->setPaletteForegroundColor( white ); 00203 sizeOnDisk->setPaletteBackgroundColor( darkBlue ); 00204 sizeOnDiskVal->setPaletteForegroundColor( white ); 00205 sizeOnDiskVal->setPaletteBackgroundColor( darkBlue ); 00206 created->setPaletteForegroundColor( white ); 00207 created->setPaletteBackgroundColor( darkBlue ); 00208 createdVal->setPaletteForegroundColor( white ); 00209 createdVal->setPaletteBackgroundColor( darkBlue ); 00210 modified->setPaletteForegroundColor( white ); 00211 modified->setPaletteBackgroundColor( darkBlue ); 00212 modifiedVal->setPaletteForegroundColor( white ); 00213 modifiedVal->setPaletteBackgroundColor( darkBlue ); 00214 albumTitle->setPaletteForegroundColor( white ); 00215 albumTitle->setPaletteBackgroundColor( darkBlue ); 00216 albumPreview->setPaletteBackgroundColor( darkBlue ); 00217 closeButton->setEraseColor(darkBlue); 00218 //-- 00219 //place widgets in grid 00220 grid = new QGridLayout( this, 10, 3, 0); 00221 grid->setMargin(WIDGET_SPACING); 00222 grid->setSpacing(WIDGET_SPACING); 00223 00224 grid->addRowSpacing( 0, 10 ); 00225 grid->setRowStretch( 0, 1 ); 00226 00227 //add statistics text 00228 grid->addMultiCellWidget( titleMessage, 1, 1, 0, 1, Qt::AlignCenter); 00229 00230 //add space between "Album Statistics" text and actual statistics 00231 grid->addRowSpacing( 2, 10 ); 00232 grid->setRowStretch( 2, 1 ); 00233 00234 grid->addWidget( numSubalbums, 3, 0 ); 00235 grid->addWidget( numSubalbumsVal, 3, 1, Qt::AlignRight ); 00236 grid->addWidget( numPhotos, 4, 0 ); 00237 grid->addWidget( numPhotosVal, 4, 1, Qt::AlignRight ); 00238 grid->addWidget( sizeOnDisk, 5, 0 ); 00239 grid->addWidget( sizeOnDiskVal, 5, 1, Qt::AlignRight ); 00240 grid->addWidget( created, 6,0 ); 00241 grid->addWidget( createdVal, 6, 1, Qt::AlignRight ); 00242 grid->addWidget( modified, 7,0 ); 00243 grid->addWidget( modifiedVal, 7, 1, Qt::AlignRight ); 00244 00245 grid->setRowStretch( 8, 1 ); 00246 00247 00248 //add album image and name 00249 grid2 = new QGridLayout( albumPreview, 2, 1, 0 ); 00250 grid2->setSpacing(WIDGET_SPACING); 00251 00252 grid2->addWidget( albumIcon, 0, 0, Qt::AlignCenter ); 00253 grid2->addWidget( albumTitle, 1, 0, Qt::AlignCenter ); 00254 grid->addMultiCellWidget( albumPreview, 0,8, 2, 2, Qt::AlignCenter ); 00255 00256 //add ok button 00257 grid->addMultiCellWidget( closeButton, 9,9, 0, 2, Qt::AlignCenter ); 00258 //-- 00259 //set window to not be resizeable 00260 show(); 00261 setFixedSize(size()); 00262 //------------------------------- }
void AlbumStatistics::closed | ( | ) | [signal] |
Referenced by closeEvent(), and reject().
void AlbumStatistics::closeEvent | ( | QCloseEvent * | e | ) | [private] |
Definition at line 269 of file albumStatistics.cpp.
References closed().
00270 { 00271 QWidget::closeEvent( e ); 00272 emit closed(); 00273 }
void AlbumStatistics::reject | ( | ) | [private, slot] |
Definition at line 275 of file albumStatistics.cpp.
References closed().
00276 { 00277 QDialog::reject(); 00278 emit closed(); 00279 }
void AlbumStatistics::setCreationDate | ( | ) | [private, slot] |
Definition at line 264 of file albumStatistics.cpp.
Album* AlbumStatistics::album [private] |
Definition at line 47 of file albumStatistics.h.
QLabel* AlbumStatistics::albumIcon [private] |
Definition at line 71 of file albumStatistics.h.
Referenced by AlbumStatistics().
QPixmap* AlbumStatistics::albumImage [private] |
Definition at line 70 of file albumStatistics.h.
Referenced by AlbumStatistics().
QFrame* AlbumStatistics::albumPreview [private] |
Definition at line 69 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::albumTitle [private] |
Definition at line 73 of file albumStatistics.h.
Referenced by AlbumStatistics().
QPushButton* AlbumStatistics::closeButton [private] |
QLabel* AlbumStatistics::created [private] |
Definition at line 62 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::createdVal [private] |
Definition at line 63 of file albumStatistics.h.
Referenced by AlbumStatistics().
QGridLayout* AlbumStatistics::grid [private] |
Definition at line 48 of file albumStatistics.h.
Referenced by AlbumStatistics().
QGridLayout* AlbumStatistics::grid2 [private] |
Definition at line 49 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::modified [private] |
Definition at line 66 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::modifiedVal [private] |
Definition at line 67 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::numPhotos [private] |
Definition at line 56 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::numPhotosVal [private] |
Definition at line 57 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::numSubalbums [private] |
Definition at line 53 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::numSubalbumsVal [private] |
Definition at line 54 of file albumStatistics.h.
Referenced by AlbumStatistics().
QPushButton* AlbumStatistics::setCreatedVal [private] |
Definition at line 64 of file albumStatistics.h.
QLabel* AlbumStatistics::sizeOnDisk [private] |
Definition at line 59 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::sizeOnDiskVal [private] |
Definition at line 60 of file albumStatistics.h.
Referenced by AlbumStatistics().
QLabel* AlbumStatistics::titleMessage [private] |
Definition at line 51 of file albumStatistics.h.
Referenced by AlbumStatistics().