15#include <q3textstream.h>
20#include <qapplication.h>
46 name = qApp->translate(
"Subalbum",
"Collection %1").arg(
number);
52 ( QString(
IMAGE_PATH)+
"miscImages/subalbum.png" );
76 while(current != NULL)
133 if(imageFilename.isNull())
139 ( QString(
IMAGE_PATH)+
"miscImages/subalbum.png" );
144 int imageWidth, imageHeight;
148 int smallRepWidth = 0;
149 int smallRepHeight = 0;
152 smallRepWidth, smallRepHeight);
153 QImage thumbnailSmall;
154 scaleImage( imageFilename, thumbnailSmall, smallRepWidth, smallRepHeight );
206 if(replaceDescription)
209 QString desc(fileName);
212 desc = desc.section( QRegExp(
"/"), -1);
215 int extensionIndex = desc.findRev(
'.' );
216 if(extensionIndex > 0 )
217 desc.truncate(extensionIndex);
220 desc = desc.replace(
'_',
' ');
256 if(!newPhoto->
setImage(imageName, slideshowName, thumbnailName))
284 if(val == NULL)
return;
316 stream <<
" <subalbum>\n";
321 stream <<
" <thumb path=\"img/" <<
number <<
"_thumb.jpg\"/>\n";
329 if(strippedName.stripWhiteSpace() ==
"")
330 stream << QString(
" <name>%1 %2</name>\n").arg(qApp->translate(
"Subalbum",
"Collection")).arg(
number);
339 while(current != NULL)
346 stream <<
" </subalbum>\n";
354 bool disableCheckPhotoMods)
357 QString repName = QString(dirName +
"/img/%1_thumb.jpg").arg(subalbumNum);
358 QImage repImage(repName);
359 if(!repImage.isNull())
364 QDomNode node = root->firstChild();
367 while( !node.isNull() )
371 if( node.isElement() && node.nodeName() ==
"name" )
373 val = node.firstChild().toText();
375 name = val.nodeValue();
376 name.replace(
"\\"",
"\"");
380 else if( node.isElement() && node.nodeName() ==
"description" )
382 val = node.firstChild().toText();
389 else if( node.isElement() && node.nodeName() ==
"photo" )
395 QString imageName = QString(dirName +
"img/%1/%2.jpg").arg(subalbumNum).arg(photoNum);
396 QString slideshowName = QString(dirName +
"img/%1/%2_slideshow.jpg").arg(subalbumNum).arg(photoNum);
397 QString thumbName = QString(dirName +
"img/%1/%2_thumb.jpg").arg(subalbumNum).arg(photoNum);
404 bool lazyLoad =
true;
407 if(!disableCheckPhotoMods)
410 info[0].setFile( imageName );
411 info[1].setFile( slideshowName );
412 info[2].setFile( thumbName );
414 modificationTimes[0] != info[0].lastModified() ||
415 modificationTimes[1] != info[1].lastModified() ||
416 modificationTimes[2] != info[2].lastModified()
424 std::ifstream imageFile ( QFile::encodeName(imageName) );
425 std::ifstream slideshowFile( QFile::encodeName(slideshowName) );
426 std::ifstream thumbnailFile( QFile::encodeName(thumbName) );
428 if( imageFile.is_open() &&
429 thumbnailFile.is_open() &&
430 slideshowFile.is_open() &&
443 slideshowFile.close();
444 thumbnailFile.close();
447 lazyAddPhoto(imageName, slideshowName, thumbName, newPhoto);
453 if(imageFile.is_open())
455 if(thumbnailFile.is_open())
456 thumbnailFile.close();
459 addPhoto(imageName,
false, newPhoto);
462 if(imageFile.is_open())
464 if(slideshowFile.is_open())
465 slideshowFile.close();
466 if(thumbnailFile.is_open())
467 thumbnailFile.close();
471 qApp->processEvents();
475 node = node.nextSibling();
487 if(val == NULL)
return;
518 while(item->nextItem() != NULL)
An album contains Subalbums.
int getNextUniquePhotoID()
Returns the next unique photo id.
void setModified(bool val=true)
Sets the album as modified.
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image,...
QDateTime * importFromDisk(QDomNode *root)
Builds photo from XML DOM node, returns date modified info from xml.
bool setImage(QString imageName, QString slideshowName, QString thumbnailName)
Setup photo using preexisting full size, slideshow, and thumbnail images.
Photo * getNext()
Returns next photo pointer.
QString getThumbnailChecksum()
Get thumbanil checksum.
void setNext(Photo *val)
Sets next photo pointer.
void setPrev(Photo *val)
Sets prev photo pointer.
Photo * getPrev()
Returns the previous photo pointer.
void exportToXML(Q3TextStream &stream)
Exports photo to xml.
QString getSlideshowChecksum()
Get thumbanil checksum.
void setDescription(QString val)
Sets the description.
QString getImageChecksum()
Get image checksum.
A subalbum contains photos.
Subalbum * getPrev()
Returns pointer to prev subalbum.
int numPhotos
Number of photos in subalbum.
bool addPhoto(QString fileName, bool replaceDescription=false, Photo *newPhoto=NULL)
Adds a new photo to the Subalbum and appends it to the end, returns TRUE if successful.
int number
Subalbum Number.
int getNumPhotos()
Returns the number of photos in the subalbum.
Photo * getLast()
Returns last photo in subalbum.
QString name
Short Name for subalbum.
int getSubalbumNumber()
Returns subalbum number.
bool lazyAddPhoto(QString imageName, QString slideshowName, QString thumbnailName, Photo *newPhoto)
Lazily adds a new photo to the subalbum without rescaling from scrath, returns TRUE if successful.
void removePhoto(Photo *val)
Removes a specified photo.
void setSubalbumNumber(int newVal)
Sets the subalbum number to newVal.
Subalbum * getNext()
Returns pointer to next subalbum.
Subalbum * prevSubalbum
Pointer to prev subalbum.
void setRepresentativeImage(QString imageFilename)
sets a sized representative image
Album * albm
Pointer to album subalbum is in.
Subalbum * nextSubalbum
Pointer to next subalbum.
Photo * lastPhoto
Pointer to last photo.
void photoMoved(Photo *val)
Removes a specified photo without deleting the object.
QString getDescription()
Gets the Subalbum description.
void setName(QString val)
Sets the Subalbum Name.
Photo * firstPhoto
Pointer to first photo.
void setPrev(Subalbum *val)
Sets pointer of prev subalbum.
QString description
Longer description of subalbum.
QPixmap * getRepresentativeImage(int size)
gets a sized representative image
QString getName()
Gets the Subalbum Name.
Photo * getFirst()
Returns first photo in subalbum.
void resetNumLoadedPhotos()
Album * getAlbum()
returns the album pointer
void setNext(Subalbum *val)
Sets pointer of next subalbum.
int loadedPhotos
Number of photos in subalbum when last loaded.
void importFromDisk(QDomNode *root, int subalbumNum, StatusWidget *status, QString dirName, bool disableCheckPhotoMods)
Builds subalbum from XML DOM node.
QPixmap * largeRepresentativeImage
void setDescription(QString val)
Sets the Subalbum description.
QPixmap * mediumRepresentativeImage
int getNumLoadedPhotos()
Returns the number of loaded photos in subalbum.
void exportToXML(StatusWidget *status, Q3TextStream &stream)
Exports subalbum to xml.
QPixmap * smallRepresentativeImage
void syncPhotoList(PhotoPreviewWidget *item)
Syncs photo ordering with front end gui ordering.
Subalbum(Album *albm, int number)
Sets default information.
QString getMD5(std::ifstream &stream)