00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qlayout.h>
00013
#include <qlabel.h>
00014
#include <qfont.h>
00015
#include <qpixmap.h>
00016
#include <qimage.h>
00017
#include <qpushbutton.h>
00018
#include <qfileinfo.h>
00019
00020
#include <qtoolbutton.h>
00021
00022
00023
#include "albumStatistics.h"
00024
#include "../../config.h"
00025
#include "../../backend/album.h"
00026
#include "../../backend/subalbum.h"
00027
#include "../../backend/photo.h"
00028
#include "../../backend/tools/imageTools.h"
00029
00030
00031 AlbumStatistics::AlbumStatistics(
Album* album,
00032
QWidget* parent,
00033
const char* name ) :
00034
QDialog(parent,name)
00035 {
00036
00037 QColor white(255, 255, 255);
00038 QColor darkBlue(35, 75, 139);
00039
00040
00041 this->album = album;
00042
00043
00044
int albumSize = 0;
00045
Subalbum* curSubalbum = album->
getFirstSubalbum();
00046 QFileInfo info;
00047
while(curSubalbum != NULL)
00048 {
00049
Photo* curPhoto = curSubalbum->
getFirst();
00050
while(curPhoto != NULL)
00051 {
00052 info.setFile( curPhoto->
getImageFilename() );
00053 albumSize+=info.size();
00054
00055 info.setFile( curPhoto->
getSlideshowFilename() );
00056 albumSize+=info.size();
00057
00058 curPhoto = curPhoto->
getNext();
00059 }
00060 curSubalbum = curSubalbum->
getNext();
00061 }
00062
00063
00064 setCaption( tr(
"Album Statistics"));
00065
00066
00067
titleMessage =
new QLabel( tr(
"Album Statistics:"),
this);
00068
00069 QFont titleFont =
titleMessage->font();
00070 titleFont.setWeight(QFont::Bold);
00071 titleFont.setPointSize( titleFont.pointSize() + 2 );
00072
00073 QFont statsFont =
titleMessage->font();
00074 statsFont.setWeight(QFont::Bold);
00075
00076
titleMessage->setFont( titleFont );
00077
00078
00079
00080
numSubalbums =
new QLabel( tr(
"Collections:"),
this);
00081
numSubalbums->setFont( statsFont );
00082
numSubalbumsVal =
new QLabel(
this);
00083
numSubalbumsVal->setText( QString(
"%1").arg(album->getNumSubalbums()) );
00084
numSubalbumsVal->setFont( statsFont );
00085
00086
numPhotos =
new QLabel( tr(
"Photos:"),
this);
00087
numPhotos->setFont( statsFont );
00088
numPhotosVal =
new QLabel(
this);
00089
numPhotosVal->setText( QString(
"%1").arg(album->getNumPhotos()) );
00090
numPhotosVal->setFont( statsFont );
00091
00092
sizeOnDisk =
new QLabel( tr(
"Size:"),
this);
00093
sizeOnDisk->setFont( statsFont );
00094
sizeOnDiskVal =
new QLabel(
this);
00095
sizeOnDiskVal->setFont( statsFont );
00096
if(albumSize < 1024)
00097
sizeOnDiskVal->setText( QString(tr(
"~%1 Bytes")).arg(albumSize) );
00098
else if( albumSize/1024 < 1024)
00099
sizeOnDiskVal->setText( QString(tr(
"~%1 Kb")).arg( ((
float)albumSize)/1024 ) );
00100
else if( albumSize/(1024*1024) < 1024)
00101
sizeOnDiskVal->setText( QString(tr(
"~%1 Mb")).arg( ((
float)albumSize)/(1024*1024) ) );
00102
else
00103
sizeOnDiskVal->setText( QString(tr(
"~%1 Gigs")).arg( ((
float)albumSize)/(1024*1024*1024) ) );
00104
00105 QString months[] = { tr(
"January"),
00106 tr(
"February"),
00107 tr(
"March"),
00108 tr(
"April"),
00109 tr(
"May"),
00110 tr(
"June"),
00111 tr(
"July"),
00112 tr(
"August"),
00113 tr(
"September"),
00114 tr(
"October"),
00115 tr(
"November"),
00116 tr(
"December") };
00117
00118
created =
new QLabel( tr(
"Created:"),
this);
00119
created->setFont( statsFont );
00120 QString cVal = QString(
"%1 %2").arg(months[album->getCreationMonth()-1]).arg(album->getCreationDay());
00121
if(album->getCreationDay() == 1 ||
00122 album->getCreationDay() == 21 ||
00123 album->getCreationDay() == 31)
00124 cVal = cVal +
"st";
00125
else if(album->getCreationDay() == 2 ||
00126 album->getCreationDay() == 22)
00127 cVal = cVal +
"nd";
00128
else if(album->getCreationDay() == 3 ||
00129 album->getCreationDay() == 23)
00130 cVal = cVal +
"rd";
00131
else
00132 cVal = cVal +
"th";
00133 cVal = QString(
"%1, %2").arg(cVal).arg(album->getCreationYear());
00134
00135
createdVal =
new QLabel( cVal,
this );
00136
createdVal->setFont( statsFont );
00137
00138
modified =
new QLabel( tr(
"Modified:"),
this);
00139
modified->setFont( statsFont );
00140 QString mVal = QString(
"%1 %2").arg(months[album->getModificationMonth()-1]).arg(album->getModificationDay());
00141
00142
if(album->getModificationDay() == 1 ||
00143 album->getModificationDay() == 21 ||
00144 album->getModificationDay() == 31)
00145 mVal = mVal +
"st";
00146
else if(album->getModificationDay() == 2 ||
00147 album->getModificationDay() == 22)
00148 mVal = mVal +
"nd";
00149
else if(album->getModificationDay() == 3 ||
00150 album->getModificationDay() == 23)
00151 mVal = mVal +
"rd";
00152
else
00153 mVal = mVal +
"th";
00154 mVal = QString(
"%1, %2").arg(mVal).arg(album->getModificationYear());
00155
modifiedVal =
new QLabel( mVal,
this );
00156
modifiedVal->setFont( statsFont );
00157
00158
00159
albumPreview =
new QFrame(
this );
00160
albumIcon =
new QLabel(
albumPreview );
00161
00162
00163
if(album->getRepresentativeImage(
LARGE) != NULL)
00164 {
00165 QImage tImage = album->getRepresentativeImage(
LARGE )->convertToImage();
00166
int newWidth, newHeight;
00167
calcScaledImageDimensions( tImage.width(), tImage.height(),
00168 300, 300,
00169 newWidth, newHeight);
00170 QImage tImage2 = tImage.smoothScale( newWidth, newHeight );
00171
albumImage =
new QPixmap( newWidth, newHeight );
00172
albumImage->convertFromImage( tImage2 );
00173
albumIcon->setPixmap( *
albumImage );
00174 }
00175
00176
albumTitle =
new QLabel(
albumPreview );
00177
if(album->getName().compare(
"") != 0)
00178 {
00179
albumTitle->setText(
"\"" + album->getName() +
"\"" );
00180 }
00181
albumTitle->setFont( statsFont );
00182
00183
00184
closeButton =
new QPushButton( tr(
"Close"),
this );
00185
closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
00186
closeButton->setDefault(
true);
00187
closeButton->setFocus();
00188 connect(
closeButton, SIGNAL(clicked()), SLOT(close()) );
00189
00190 setPaletteBackgroundColor( darkBlue );
00191
titleMessage->setPaletteForegroundColor( white );
00192
titleMessage->setPaletteBackgroundColor( darkBlue );
00193
numSubalbums->setPaletteForegroundColor( white );
00194
numSubalbums->setPaletteBackgroundColor( darkBlue );
00195
numSubalbumsVal->setPaletteForegroundColor( white );
00196
numSubalbumsVal->setPaletteBackgroundColor( darkBlue );
00197
numPhotos->setPaletteForegroundColor( white );
00198
numPhotos->setPaletteBackgroundColor( darkBlue );
00199
numPhotosVal->setPaletteForegroundColor( white );
00200
numPhotosVal->setPaletteBackgroundColor( darkBlue );
00201
sizeOnDisk->setPaletteForegroundColor( white );
00202
sizeOnDisk->setPaletteBackgroundColor( darkBlue );
00203
sizeOnDiskVal->setPaletteForegroundColor( white );
00204
sizeOnDiskVal->setPaletteBackgroundColor( darkBlue );
00205
created->setPaletteForegroundColor( white );
00206
created->setPaletteBackgroundColor( darkBlue );
00207
createdVal->setPaletteForegroundColor( white );
00208
createdVal->setPaletteBackgroundColor( darkBlue );
00209
modified->setPaletteForegroundColor( white );
00210
modified->setPaletteBackgroundColor( darkBlue );
00211
modifiedVal->setPaletteForegroundColor( white );
00212
modifiedVal->setPaletteBackgroundColor( darkBlue );
00213
albumTitle->setPaletteForegroundColor( white );
00214
albumTitle->setPaletteBackgroundColor( darkBlue );
00215
albumPreview->setPaletteBackgroundColor( darkBlue );
00216
closeButton->setEraseColor(darkBlue);
00217
00218
00219
grid =
new QGridLayout(
this, 10, 3, 0);
00220
grid->setMargin(
WIDGET_SPACING);
00221
grid->setSpacing(
WIDGET_SPACING);
00222
00223
grid->addRowSpacing( 0, 10 );
00224
grid->setRowStretch( 0, 1 );
00225
00226
00227
grid->addMultiCellWidget(
titleMessage, 1, 1, 0, 1, Qt::AlignCenter);
00228
00229
00230
grid->addRowSpacing( 2, 10 );
00231
grid->setRowStretch( 2, 1 );
00232
00233
grid->addWidget(
numSubalbums, 3, 0 );
00234
grid->addWidget(
numSubalbumsVal, 3, 1, Qt::AlignRight );
00235
grid->addWidget(
numPhotos, 4, 0 );
00236
grid->addWidget(
numPhotosVal, 4, 1, Qt::AlignRight );
00237
grid->addWidget(
sizeOnDisk, 5, 0 );
00238
grid->addWidget(
sizeOnDiskVal, 5, 1, Qt::AlignRight );
00239
grid->addWidget(
created, 6,0 );
00240
grid->addWidget(
createdVal, 6, 1, Qt::AlignRight );
00241
grid->addWidget(
modified, 7,0 );
00242
grid->addWidget(
modifiedVal, 7, 1, Qt::AlignRight );
00243
00244
grid->setRowStretch( 8, 1 );
00245
00246
00247
00248
grid2 =
new QGridLayout(
albumPreview, 2, 1, 0 );
00249
grid2->setSpacing(
WIDGET_SPACING);
00250
00251
grid2->addWidget(
albumIcon, 0, 0, Qt::AlignCenter );
00252
grid2->addWidget(
albumTitle, 1, 0, Qt::AlignCenter );
00253
grid->addMultiCellWidget(
albumPreview, 0,8, 2, 2, Qt::AlignCenter );
00254
00255
00256
grid->addMultiCellWidget(
closeButton, 9,9, 0, 2, Qt::AlignCenter );
00257
00258
00259 show();
00260 setFixedSize(size());
00261
00262 }
00263
00264 void AlbumStatistics::setCreationDate()
00265 {
00266
00267 }
00268
00269 void AlbumStatistics::closeEvent( QCloseEvent* e)
00270 {
00271 QWidget::closeEvent( e );
00272 emit
closed();
00273 }
00274
00275 void AlbumStatistics::reject()
00276 {
00277 QDialog::reject();
00278 emit
closed();
00279 }
00280