AlbumShaper
1.0a3
|
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 album, 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.
: QDialog(parent,name) { //-------------------------------------------------------------- QColor white(255, 255, 255); QColor darkBlue(35, 75, 139); //-------------------------------------------------------------- //this album pointer this->album = album; //-- //compute size on disk int albumSize = 0; Subalbum* curSubalbum = album->getFirstSubalbum(); QFileInfo info; while(curSubalbum != NULL) { Photo* curPhoto = curSubalbum->getFirst(); while(curPhoto != NULL) { info.setFile( curPhoto->getImageFilename() ); albumSize+=info.size(); info.setFile( curPhoto->getSlideshowFilename() ); albumSize+=info.size(); curPhoto = curPhoto->getNext(); } curSubalbum = curSubalbum->getNext(); } //-- //set window title setCaption( tr("Album Statistics")); //-- //create title titleMessage = new QLabel( tr("Album Statistics:"), this); QFont titleFont = titleMessage->font(); titleFont.setWeight(QFont::Bold); titleFont.setPointSize( titleFont.pointSize() + 2 ); QFont statsFont = titleMessage->font(); statsFont.setWeight(QFont::Bold); titleMessage->setFont( titleFont ); //-- //create stats //-- numSubalbums = new QLabel( tr("Collections:"), this); numSubalbums->setFont( statsFont ); numSubalbumsVal = new QLabel(this); numSubalbumsVal->setText( QString("%1").arg(album->getNumSubalbums()) ); numSubalbumsVal->setFont( statsFont ); //-- numPhotos = new QLabel( tr("Photos:"), this); numPhotos->setFont( statsFont ); numPhotosVal = new QLabel(this); numPhotosVal->setText( QString("%1").arg(album->getNumPhotos()) ); numPhotosVal->setFont( statsFont ); //-- sizeOnDisk = new QLabel( tr("Size:"), this); sizeOnDisk->setFont( statsFont ); sizeOnDiskVal = new QLabel(this); sizeOnDiskVal->setFont( statsFont ); if(albumSize < 1024) sizeOnDiskVal->setText( QString(tr("~%1 Bytes")).arg(albumSize) ); else if( albumSize/1024 < 1024) sizeOnDiskVal->setText( QString(tr("~%1 Kb")).arg( ((float)albumSize)/1024 ) ); else if( albumSize/(1024*1024) < 1024) sizeOnDiskVal->setText( QString(tr("~%1 Mb")).arg( ((float)albumSize)/(1024*1024) ) ); else sizeOnDiskVal->setText( QString(tr("~%1 Gigs")).arg( ((float)albumSize)/(1024*1024*1024) ) ); //-- QString months[] = { tr("January"), tr("February"), tr("March"), tr("April"), tr("May"), tr("June"), tr("July"), tr("August"), tr("September"), tr("October"), tr("November"), tr("December") }; created = new QLabel( tr("Created:"), this); created->setFont( statsFont ); QString cVal = QString("%1 %2").arg(months[album->getCreationMonth()-1]).arg(album->getCreationDay()); if(album->getCreationDay() == 1 || album->getCreationDay() == 21 || album->getCreationDay() == 31) cVal = cVal + "st"; else if(album->getCreationDay() == 2 || album->getCreationDay() == 22) cVal = cVal + "nd"; else if(album->getCreationDay() == 3 || album->getCreationDay() == 23) cVal = cVal + "rd"; else cVal = cVal + "th"; cVal = QString("%1, %2").arg(cVal).arg(album->getCreationYear()); createdVal = new QLabel( cVal, this ); createdVal->setFont( statsFont ); modified = new QLabel( tr("Modified:"), this); modified->setFont( statsFont ); QString mVal = QString("%1 %2").arg(months[album->getModificationMonth()-1]).arg(album->getModificationDay()); if(album->getModificationDay() == 1 || album->getModificationDay() == 21 || album->getModificationDay() == 31) mVal = mVal + "st"; else if(album->getModificationDay() == 2 || album->getModificationDay() == 22) mVal = mVal + "nd"; else if(album->getModificationDay() == 3 || album->getModificationDay() == 23) mVal = mVal + "rd"; else mVal = mVal + "th"; mVal = QString("%1, %2").arg(mVal).arg(album->getModificationYear()); modifiedVal = new QLabel( mVal, this ); modifiedVal->setFont( statsFont ); //-- //create album image and title labels albumPreview = new QFrame( this ); albumIcon = new QLabel( albumPreview ); //if no rep image use small version if(album->getRepresentativeImage(LARGE) != NULL) { QImage tImage = album->getRepresentativeImage( LARGE )->convertToImage(); int newWidth, newHeight; calcScaledImageDimensions( tImage.width(), tImage.height(), 300, 300, newWidth, newHeight); QImage tImage2 = tImage.smoothScale( newWidth, newHeight ); albumImage = new QPixmap( newWidth, newHeight ); albumImage->convertFromImage( tImage2 ); albumIcon->setPixmap( *albumImage ); } albumTitle = new QLabel( albumPreview ); if(album->getName().compare("") != 0) { albumTitle->setText( "\"" + album->getName() + "\"" ); } albumTitle->setFont( statsFont ); //-- //create close button closeButton = new QPushButton( tr("Close"), this ); closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); closeButton->setDefault(true); closeButton->setFocus(); connect( closeButton, SIGNAL(clicked()), SLOT(close()) ); //-- setPaletteBackgroundColor( darkBlue ); titleMessage->setPaletteForegroundColor( white ); titleMessage->setPaletteBackgroundColor( darkBlue ); numSubalbums->setPaletteForegroundColor( white ); numSubalbums->setPaletteBackgroundColor( darkBlue ); numSubalbumsVal->setPaletteForegroundColor( white ); numSubalbumsVal->setPaletteBackgroundColor( darkBlue ); numPhotos->setPaletteForegroundColor( white ); numPhotos->setPaletteBackgroundColor( darkBlue ); numPhotosVal->setPaletteForegroundColor( white ); numPhotosVal->setPaletteBackgroundColor( darkBlue ); sizeOnDisk->setPaletteForegroundColor( white ); sizeOnDisk->setPaletteBackgroundColor( darkBlue ); sizeOnDiskVal->setPaletteForegroundColor( white ); sizeOnDiskVal->setPaletteBackgroundColor( darkBlue ); created->setPaletteForegroundColor( white ); created->setPaletteBackgroundColor( darkBlue ); createdVal->setPaletteForegroundColor( white ); createdVal->setPaletteBackgroundColor( darkBlue ); modified->setPaletteForegroundColor( white ); modified->setPaletteBackgroundColor( darkBlue ); modifiedVal->setPaletteForegroundColor( white ); modifiedVal->setPaletteBackgroundColor( darkBlue ); albumTitle->setPaletteForegroundColor( white ); albumTitle->setPaletteBackgroundColor( darkBlue ); albumPreview->setPaletteBackgroundColor( darkBlue ); closeButton->setEraseColor(darkBlue); //-- //place widgets in grid grid = new QGridLayout( this, 10, 3, 0); grid->setMargin(WIDGET_SPACING); grid->setSpacing(WIDGET_SPACING); grid->addRowSpacing( 0, 10 ); grid->setRowStretch( 0, 1 ); //add statistics text grid->addMultiCellWidget( titleMessage, 1, 1, 0, 1, Qt::AlignCenter); //add space between "Album Statistics" text and actual statistics grid->addRowSpacing( 2, 10 ); grid->setRowStretch( 2, 1 ); grid->addWidget( numSubalbums, 3, 0 ); grid->addWidget( numSubalbumsVal, 3, 1, Qt::AlignRight ); grid->addWidget( numPhotos, 4, 0 ); grid->addWidget( numPhotosVal, 4, 1, Qt::AlignRight ); grid->addWidget( sizeOnDisk, 5, 0 ); grid->addWidget( sizeOnDiskVal, 5, 1, Qt::AlignRight ); grid->addWidget( created, 6,0 ); grid->addWidget( createdVal, 6, 1, Qt::AlignRight ); grid->addWidget( modified, 7,0 ); grid->addWidget( modifiedVal, 7, 1, Qt::AlignRight ); grid->setRowStretch( 8, 1 ); //add album image and name grid2 = new QGridLayout( albumPreview, 2, 1, 0 ); grid2->setSpacing(WIDGET_SPACING); grid2->addWidget( albumIcon, 0, 0, Qt::AlignCenter ); grid2->addWidget( albumTitle, 1, 0, Qt::AlignCenter ); grid->addMultiCellWidget( albumPreview, 0,8, 2, 2, Qt::AlignCenter ); //add ok button grid->addMultiCellWidget( closeButton, 9,9, 0, 2, Qt::AlignCenter ); //-- //set window to not be resizeable show(); setFixedSize(size()); //------------------------------- }
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().
{ QWidget::closeEvent( e ); emit closed(); }
void AlbumStatistics::reject | ( | ) | [private, slot] |
Definition at line 275 of file albumStatistics.cpp.
References closed().
{ QDialog::reject(); emit closed(); }
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.
Referenced by AlbumStatistics().
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().