15 #include <q3textstream.h> 20 #include <qapplication.h> 30 #include "../config.h" 31 #include "../gui/photoPreviewWidget.h" 32 #include "../gui/statusWidget.h" 33 #include "../gui/subalbumPreviewWidget.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)
void resetNumLoadedPhotos()
Photo * firstPhoto
Pointer to first photo.
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.
void importFromDisk(QDomNode *root, int subalbumNum, StatusWidget *status, QString dirName, bool disableCheckPhotoMods)
Builds subalbum from XML DOM node.
QString getSlideshowChecksum()
Get thumbanil checksum.
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
int number
Subalbum Number.
void setRepresentativeImage(QString imageFilename)
sets a sized representative image
Photo * lastPhoto
Pointer to last photo.
void exportToXML(StatusWidget *status, Q3TextStream &stream)
Exports subalbum to xml.
void setPrev(Subalbum *val)
Sets pointer of prev subalbum.
QPixmap * mediumRepresentativeImage
QString getMD5(std::ifstream &stream)
void exportToXML(Q3TextStream &stream)
Exports photo to xml.
Photo * getNext()
Returns next photo pointer.
Album * getAlbum()
returns the album pointer
QString description
Longer description of subalbum.
int getNumLoadedPhotos()
Returns the number of loaded photos in subalbum.
void setNext(Subalbum *val)
Sets pointer of next subalbum.
bool setImage(QString imageName, QString slideshowName, QString thumbnailName)
Setup photo using preexisting full size, slideshow, and thumbnail images.
A subalbum contains photos.
void setModified(bool val=true)
Sets the album as modified.
void setDescription(QString val)
Sets the description.
int numPhotos
Number of photos in subalbum.
Subalbum * prevSubalbum
Pointer to prev subalbum.
int getNumPhotos()
Returns the number of photos in the subalbum.
Subalbum(Album *albm, int number)
Sets default information is the Subalbum number.
QPixmap * getRepresentativeImage(int size)
gets a sized representative image
Photo * getFirst()
Returns first photo in subalbum.
Album * albm
Pointer to album subalbum is in.
void photoMoved(Photo *val)
Removes a specified photo without deleting the object.
QDateTime * importFromDisk(QDomNode *root)
Builds photo from XML DOM node, returns date modified info from xml.
QString getDescription()
Gets the Subalbum description.
Subalbum * nextSubalbum
Pointer to next subalbum.
QString getName()
Gets the Subalbum Name.
void setName(QString val)
Sets the Subalbum Name.
An album contains Subalbums.
Subalbum * getNext()
Returns pointer to next subalbum.
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...
QPixmap * largeRepresentativeImage
int getSubalbumNumber()
Returns subalbum number.
QString name
Short Name for subalbum.
void setDescription(QString val)
Sets the Subalbum description.
void setNext(Photo *val)
Sets next photo pointer.
void setSubalbumNumber(int newVal)
Sets the subalbum number to newVal.
int getNextUniquePhotoID()
Returns the next unique photo id.
QPixmap * smallRepresentativeImage
void syncPhotoList(PhotoPreviewWidget *item)
Syncs photo ordering with front end gui ordering.
Photo * getPrev()
Returns the previous photo pointer.
Subalbum * getPrev()
Returns pointer to prev subalbum.
QString getImageChecksum()
Get image checksum.
QString getThumbnailChecksum()
Get thumbanil checksum.
void removePhoto(Photo *val)
Removes a specified photo.
void setPrev(Photo *val)
Sets prev photo pointer.
Photo * getLast()
Returns last photo in subalbum.
int loadedPhotos
Number of photos in subalbum when last loaded.