AlbumShaper  1.0a3
Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
AlbumStatistics Class Reference

Album Statistics Window. More...

#include <albumStatistics.h>

Inheritance diagram for AlbumStatistics:
Inheritance graph
[legend]
Collaboration diagram for AlbumStatistics:
Collaboration graph
[legend]

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

Albumalbum
 
Q3GridLayout * grid
 
Q3GridLayout * grid2
 
QLabeltitleMessage
 
QLabelnumSubalbums
 
QLabelnumSubalbumsVal
 
QLabelnumPhotos
 
QLabelnumPhotosVal
 
QLabelsizeOnDisk
 
QLabelsizeOnDiskVal
 
QLabelcreated
 
QLabelcreatedVal
 
QPushButton * setCreatedVal
 
QLabelmodified
 
QLabelmodifiedVal
 
Q3FramealbumPreview
 
QPixmap * albumImage
 
QLabelalbumIcon
 
QLabelalbumTitle
 
QPushButton * closeButton
 Close button. More...
 

Detailed Description

Album Statistics Window.

Definition at line 36 of file albumStatistics.h.

Constructor & Destructor Documentation

§ AlbumStatistics()

AlbumStatistics::AlbumStatistics ( Album album,
QWidget parent = 0,
const char *  name = 0 
)

Definition at line 35 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.

37  :
38  QDialog(parent,name)
39 {
40  //--------------------------------------------------------------
41  QColor white(255, 255, 255);
42  QColor darkBlue(35, 75, 139);
43  //--------------------------------------------------------------
44  //this album pointer
45  this->album = album;
46  //--
47  //compute size on disk
48  int albumSize = 0;
49  Subalbum* curSubalbum = album->getFirstSubalbum();
50  QFileInfo info;
51  while(curSubalbum != NULL)
52  {
53  Photo* curPhoto = curSubalbum->getFirst();
54  while(curPhoto != NULL)
55  {
56  info.setFile( curPhoto->getImageFilename() );
57  albumSize+=info.size();
58 
59  info.setFile( curPhoto->getSlideshowFilename() );
60  albumSize+=info.size();
61 
62  curPhoto = curPhoto->getNext();
63  }
64  curSubalbum = curSubalbum->getNext();
65  }
66  //--
67  //set window title
68  setCaption( tr("Album Statistics"));
69  //--
70  //create title
71  titleMessage = new QLabel( tr("Album Statistics:"), this);
72 
73  QFont titleFont = titleMessage->font();
74  titleFont.setWeight(QFont::Bold);
75  titleFont.setPointSize( titleFont.pointSize() + 2 );
76 
77  QFont statsFont = titleMessage->font();
78  statsFont.setWeight(QFont::Bold);
79 
80  titleMessage->setFont( titleFont );
81  //--
82  //create stats
83  //--
84  numSubalbums = new QLabel( tr("Collections:"), this);
85  numSubalbums->setFont( statsFont );
86  numSubalbumsVal = new QLabel(this);
87  numSubalbumsVal->setText( QString("%1").arg(album->getNumSubalbums()) );
88  numSubalbumsVal->setFont( statsFont );
89  //--
90  numPhotos = new QLabel( tr("Photos:"), this);
91  numPhotos->setFont( statsFont );
92  numPhotosVal = new QLabel(this);
93  numPhotosVal->setText( QString("%1").arg(album->getNumPhotos()) );
94  numPhotosVal->setFont( statsFont );
95  //--
96  sizeOnDisk = new QLabel( tr("Size:"), this);
97  sizeOnDisk->setFont( statsFont );
98  sizeOnDiskVal = new QLabel(this);
99  sizeOnDiskVal->setFont( statsFont );
100  if(albumSize < 1024)
101  sizeOnDiskVal->setText( QString(tr("~%1 Bytes")).arg(albumSize) );
102  else if( albumSize/1024 < 1024)
103  sizeOnDiskVal->setText( QString(tr("~%1 Kb")).arg( ((float)albumSize)/1024 ) );
104  else if( albumSize/(1024*1024) < 1024)
105  sizeOnDiskVal->setText( QString(tr("~%1 Mb")).arg( ((float)albumSize)/(1024*1024) ) );
106  else
107  sizeOnDiskVal->setText( QString(tr("~%1 Gigs")).arg( ((float)albumSize)/(1024*1024*1024) ) );
108  //--
109  QString months[] = { tr("January"),
110  tr("February"),
111  tr("March"),
112  tr("April"),
113  tr("May"),
114  tr("June"),
115  tr("July"),
116  tr("August"),
117  tr("September"),
118  tr("October"),
119  tr("November"),
120  tr("December") };
121 
122  created = new QLabel( tr("Created:"), this);
123  created->setFont( statsFont );
124  QString cVal = QString("%1 %2").arg(months[album->getCreationMonth()-1]).arg(album->getCreationDay());
125  if(album->getCreationDay() == 1 ||
126  album->getCreationDay() == 21 ||
127  album->getCreationDay() == 31)
128  cVal = cVal + "st";
129  else if(album->getCreationDay() == 2 ||
130  album->getCreationDay() == 22)
131  cVal = cVal + "nd";
132  else if(album->getCreationDay() == 3 ||
133  album->getCreationDay() == 23)
134  cVal = cVal + "rd";
135  else
136  cVal = cVal + "th";
137  cVal = QString("%1, %2").arg(cVal).arg(album->getCreationYear());
138 
139  createdVal = new QLabel( cVal, this );
140  createdVal->setFont( statsFont );
141 
142  modified = new QLabel( tr("Modified:"), this);
143  modified->setFont( statsFont );
144  QString mVal = QString("%1 %2").arg(months[album->getModificationMonth()-1]).arg(album->getModificationDay());
145 
146  if(album->getModificationDay() == 1 ||
147  album->getModificationDay() == 21 ||
148  album->getModificationDay() == 31)
149  mVal = mVal + "st";
150  else if(album->getModificationDay() == 2 ||
151  album->getModificationDay() == 22)
152  mVal = mVal + "nd";
153  else if(album->getModificationDay() == 3 ||
154  album->getModificationDay() == 23)
155  mVal = mVal + "rd";
156  else
157  mVal = mVal + "th";
158  mVal = QString("%1, %2").arg(mVal).arg(album->getModificationYear());
159  modifiedVal = new QLabel( mVal, this );
160  modifiedVal->setFont( statsFont );
161  //--
162  //create album image and title labels
163  albumPreview = new Q3Frame( this );
164  albumIcon = new QLabel( albumPreview );
165 
166  //if no rep image use small version
167  if(album->getRepresentativeImage(LARGE) != NULL)
168  {
169  QImage tImage = album->getRepresentativeImage( LARGE )->convertToImage();
170  int newWidth, newHeight;
171  calcScaledImageDimensions( tImage.width(), tImage.height(),
172  300, 300,
173  newWidth, newHeight);
174  QImage tImage2 = tImage.smoothScale( newWidth, newHeight );
175  albumImage = new QPixmap( newWidth, newHeight );
176  albumImage->convertFromImage( tImage2 );
177  albumIcon->setPixmap( *albumImage );
178  }
179 
180  albumTitle = new QLabel( albumPreview );
181  if(album->getName().compare("") != 0)
182  {
183  albumTitle->setText( "\"" + album->getName() + "\"" );
184  }
185  albumTitle->setFont( statsFont );
186  //--
187  //create close button
188  closeButton = new QPushButton( tr("Close"), this );
189  closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
190  closeButton->setDefault(true);
191  closeButton->setFocus();
192  connect( closeButton, SIGNAL(clicked()), SLOT(close()) );
193  //--
194  setPaletteBackgroundColor( darkBlue );
195  titleMessage->setPaletteForegroundColor( white );
196  titleMessage->setPaletteBackgroundColor( darkBlue );
197  numSubalbums->setPaletteForegroundColor( white );
198  numSubalbums->setPaletteBackgroundColor( darkBlue );
199  numSubalbumsVal->setPaletteForegroundColor( white );
200  numSubalbumsVal->setPaletteBackgroundColor( darkBlue );
201  numPhotos->setPaletteForegroundColor( white );
202  numPhotos->setPaletteBackgroundColor( darkBlue );
203  numPhotosVal->setPaletteForegroundColor( white );
204  numPhotosVal->setPaletteBackgroundColor( darkBlue );
205  sizeOnDisk->setPaletteForegroundColor( white );
206  sizeOnDisk->setPaletteBackgroundColor( darkBlue );
207  sizeOnDiskVal->setPaletteForegroundColor( white );
208  sizeOnDiskVal->setPaletteBackgroundColor( darkBlue );
209  created->setPaletteForegroundColor( white );
210  created->setPaletteBackgroundColor( darkBlue );
211  createdVal->setPaletteForegroundColor( white );
212  createdVal->setPaletteBackgroundColor( darkBlue );
213  modified->setPaletteForegroundColor( white );
214  modified->setPaletteBackgroundColor( darkBlue );
215  modifiedVal->setPaletteForegroundColor( white );
216  modifiedVal->setPaletteBackgroundColor( darkBlue );
217  albumTitle->setPaletteForegroundColor( white );
218  albumTitle->setPaletteBackgroundColor( darkBlue );
219  albumPreview->setPaletteBackgroundColor( darkBlue );
220  closeButton->setEraseColor(darkBlue);
221  //--
222  //place widgets in grid
223  grid = new Q3GridLayout( this, 10, 3, 0);
224  grid->setMargin(WIDGET_SPACING);
225  grid->setSpacing(WIDGET_SPACING);
226 
227  grid->addRowSpacing( 0, 10 );
228  grid->setRowStretch( 0, 1 );
229 
230  //add statistics text
231  grid->addMultiCellWidget( titleMessage, 1, 1, 0, 1, Qt::AlignCenter);
232 
233  //add space between "Album Statistics" text and actual statistics
234  grid->addRowSpacing( 2, 10 );
235  grid->setRowStretch( 2, 1 );
236 
237  grid->addWidget( numSubalbums, 3, 0 );
238  grid->addWidget( numSubalbumsVal, 3, 1, Qt::AlignRight );
239  grid->addWidget( numPhotos, 4, 0 );
240  grid->addWidget( numPhotosVal, 4, 1, Qt::AlignRight );
241  grid->addWidget( sizeOnDisk, 5, 0 );
242  grid->addWidget( sizeOnDiskVal, 5, 1, Qt::AlignRight );
243  grid->addWidget( created, 6,0 );
244  grid->addWidget( createdVal, 6, 1, Qt::AlignRight );
245  grid->addWidget( modified, 7,0 );
246  grid->addWidget( modifiedVal, 7, 1, Qt::AlignRight );
247 
248  grid->setRowStretch( 8, 1 );
249 
250 
251  //add album image and name
252  grid2 = new Q3GridLayout( albumPreview, 2, 1, 0 );
253  grid2->setSpacing(WIDGET_SPACING);
254 
255  grid2->addWidget( albumIcon, 0, 0, Qt::AlignCenter );
256  grid2->addWidget( albumTitle, 1, 0, Qt::AlignCenter );
257  grid->addMultiCellWidget( albumPreview, 0,8, 2, 2, Qt::AlignCenter );
258 
259  //add ok button
260  grid->addMultiCellWidget( closeButton, 9,9, 0, 2, Qt::AlignCenter );
261  //--
262  //set window to not be resizeable
263  show();
264  setFixedSize(size());
265  //-------------------------------
266 }
QLabel * numPhotosVal
Q3GridLayout * grid
QString getName()
Gets the album name.
Definition: album.cpp:124
QLabel * numSubalbumsVal
QString getImageFilename()
Gets the image filename.
Definition: photo.cpp:192
#define LARGE
Definition: album.h:19
int getModificationMonth()
Returns the last modified month.
Definition: album.cpp:117
int getCreationYear()
Returns the creation year.
Definition: album.cpp:120
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
Definition: photo.h:44
int getNumSubalbums()
Returns number of subalbums.
Definition: album.cpp:144
QLabel * titleMessage
QLabel * sizeOnDiskVal
QPixmap * getRepresentativeImage(int size)
Returns the representative image.
Definition: album.cpp:128
QPushButton * closeButton
Close button.
Photo * getNext()
Returns next photo pointer.
Definition: photo.cpp:225
QLabel * numSubalbums
int getNumPhotos()
Returns the number of photos.
Definition: album.cpp:146
A subalbum contains photos.
Definition: subalbum.h:48
int getModificationYear()
Returns the last modified year.
Definition: album.cpp:116
QLabel * modifiedVal
QPixmap * albumImage
Q3Frame * albumPreview
int getCreationMonth()
Returns the creation month.
Definition: album.cpp:121
#define WIDGET_SPACING
Definition: config.h:31
Q3GridLayout * grid2
Photo * getFirst()
Returns first photo in subalbum.
Definition: subalbum.cpp:100
Subalbum * getFirstSubalbum()
Returns a pointer to the first Subalbum.
Definition: album.cpp:135
QString getSlideshowFilename()
Gets the slideshow filename.
Definition: photo.cpp:193
int getModificationDay()
Returns the last modified day.
Definition: album.cpp:118
int getCreationDay()
Returnst he creation day.
Definition: album.cpp:122
Subalbum * getNext()
Returns pointer to next subalbum.
Definition: subalbum.cpp:98
void calcScaledImageDimensions(int origWidth, int origHeight, int idealWidth, int idealHeight, int &width, int &height)
Computes scale of image dimensions while respecting aspect ratio, equivalent to a QImage::scaleMin wi...
Definition: imageTools.cpp:39

Member Function Documentation

§ closed

void AlbumStatistics::closed ( )
signal

Referenced by closeEvent(), and reject().

§ closeEvent()

void AlbumStatistics::closeEvent ( QCloseEvent *  e)
private

Definition at line 273 of file albumStatistics.cpp.

References closed().

274 {
275  QWidget::closeEvent( e );
276  emit closed();
277 }

§ reject

void AlbumStatistics::reject ( )
privateslot

Definition at line 279 of file albumStatistics.cpp.

References closed().

280 {
281  QDialog::reject();
282  emit closed();
283 }

§ setCreationDate

void AlbumStatistics::setCreationDate ( )
privateslot

Definition at line 268 of file albumStatistics.cpp.

269 {
270 
271 }

Member Data Documentation

§ album

Album* AlbumStatistics::album
private

Definition at line 53 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ albumIcon

QLabel* AlbumStatistics::albumIcon
private

Definition at line 77 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ albumImage

QPixmap* AlbumStatistics::albumImage
private

Definition at line 76 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ albumPreview

Q3Frame* AlbumStatistics::albumPreview
private

Definition at line 75 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ albumTitle

QLabel* AlbumStatistics::albumTitle
private

Definition at line 79 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ closeButton

QPushButton* AlbumStatistics::closeButton
private

Close button.

Definition at line 82 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ created

QLabel* AlbumStatistics::created
private

Definition at line 68 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ createdVal

QLabel* AlbumStatistics::createdVal
private

Definition at line 69 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ grid

Q3GridLayout* AlbumStatistics::grid
private

Definition at line 54 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ grid2

Q3GridLayout* AlbumStatistics::grid2
private

Definition at line 55 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ modified

QLabel* AlbumStatistics::modified
private

Definition at line 72 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ modifiedVal

QLabel* AlbumStatistics::modifiedVal
private

Definition at line 73 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ numPhotos

QLabel* AlbumStatistics::numPhotos
private

Definition at line 62 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ numPhotosVal

QLabel* AlbumStatistics::numPhotosVal
private

Definition at line 63 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ numSubalbums

QLabel* AlbumStatistics::numSubalbums
private

Definition at line 59 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ numSubalbumsVal

QLabel* AlbumStatistics::numSubalbumsVal
private

Definition at line 60 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ setCreatedVal

QPushButton* AlbumStatistics::setCreatedVal
private

Definition at line 70 of file albumStatistics.h.

§ sizeOnDisk

QLabel* AlbumStatistics::sizeOnDisk
private

Definition at line 65 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ sizeOnDiskVal

QLabel* AlbumStatistics::sizeOnDiskVal
private

Definition at line 66 of file albumStatistics.h.

Referenced by AlbumStatistics().

§ titleMessage

QLabel* AlbumStatistics::titleMessage
private

Definition at line 57 of file albumStatistics.h.

Referenced by AlbumStatistics().


The documentation for this class was generated from the following files: