A photo consists of a full size image, a smaller slide show image, a very small thumbnail image, and a desription. More...
#include <photo.h>
Public Member Functions | |
Photo (Subalbum *subalbum, Photo *prev, int photoNumber) | |
Sets default information. | |
~Photo () | |
QImage * | getThumbnailImage () |
Gets thumbnail image. | |
bool | constructSmallerImages () |
Construct thumbnail and slideshow images, load up thumbnail image, and set photo has being modified. | |
bool | setImage (QString imageName, QString slideshowName, QString thumbnailName) |
Setup photo using preexisting full size, slideshow, and thumbnail images. | |
bool | setImage (QString imageName, int uniqueID) |
Setup photo using a new image. We'll need to create slideshow and thumbnail images. | |
bool | setImage (QString editedImageFilename) |
Reset photo data after photo editing has taken place. | |
QString | getImageFilename () |
Gets the image filename. | |
QString | getSlideshowFilename () |
Gets the slideshow filename. | |
QString | getThumbnailFilename () |
Gets the thumbnail filename. | |
void | setImageFilename (QString val) |
Sets the image filename. | |
void | setSlideshowFilename (QString val) |
Sets the slideshow filename. | |
void | setThumbnailFilename (QString val) |
Sets the thumbnail filename. | |
QString | getImageChecksum () |
Get image checksum. | |
QString | getThumbnailChecksum () |
Get thumbanil checksum. | |
QString | getSlideshowChecksum () |
Get thumbanil checksum. | |
void | setImageChecksum (QString val) |
Update image checksum. | |
void | setThumbnailChecksum (QString val) |
Update thumbnail checksum. | |
void | setSlideshowChecksum (QString val) |
Update slideshow checksum. | |
QString | getDescription () |
Gets the description. | |
void | setDescription (QString val) |
Sets the description. | |
Photo * | getPrev () |
Returns the previous photo pointer. | |
Photo * | getNext () |
Returns next photo pointer. | |
void | setPrev (Photo *val) |
Sets prev photo pointer. | |
void | setNext (Photo *val) |
Sets next photo pointer. | |
QDateTime * | importFromDisk (QDomNode *root) |
Builds photo from XML DOM node, returns date modified info from xml. | |
void | exportToXML (QTextStream &stream) |
Exports photo to xml. | |
void | rotate90 () |
Rotates image clockwise 90 degrees. | |
void | rotate270 () |
Rotates image clockwise 270 degrees. | |
void | flipHorizontally () |
Flips image about horizontal axis. | |
void | flipVertically () |
Flips image about vertical axis. | |
void | applyTransformation (TRANSFORM_CODE transformation) |
Apply transformation. | |
bool | getNeedsSavingVal () |
Returns if the image needs to be saved to its permament location. | |
void | setNeedsSavingVal (bool val) |
Sets if the image needs to be saved to its permanent location. | |
bool | getEverSaved () |
Returns if the image has ever been saved to a permanant location. | |
void | setEverSaved (bool val) |
sets everSaved | |
void | revertPhoto () |
revert photo to original form | |
bool | revertPossible () |
can photo be reverted to a differnt original form | |
bool | getRecentlyReverted () |
was the photo recently reverted? if so ignore the presence of orig files on disk | |
void | setRecentlyReverted (bool val) |
reset the recently reverted value to val | |
QString | originalImageFilename () |
orig filename | |
int | getInitialPhotoNumber () |
Returns initial photo number. | |
void | setInitialPhotoNumber (int val) |
Sets initial photo number. | |
int | getInitialSubalbumNumber () |
Returns initial subalbum number. | |
void | setInitialSubalbumNumber (int val) |
Sets initial subalbum number. | |
Private Attributes | |
Subalbum * | subalbum |
Subalbum photo is in. | |
Photo * | prev |
Pointer to prev photo. | |
Photo * | next |
Pointer to next photo. | |
int | initialPhotoNumber |
int | initialSubalbumNumber |
QString | description |
Photo description. | |
QImage * | thumbnailImage |
Thumbnail Image. | |
QString | imageLocation |
Filenames. | |
QString | slideshowLocation |
QString | thumbnailLocation |
QString | imageChecksum |
MD5 checksums, used to determine if image/thumbnail have been changed. | |
QString | slideshowChecksum |
QString | thumbnailChecksum |
bool | needsSaving |
Unsaved modifications? | |
bool | everSaved |
Has the photo ever been saved? | |
bool | recentlyReverted |
Has the photo recently been reverted to it's original form? If so during the next save the orig file can safely be remove. |
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image, and a desription.
Definition at line 41 of file photo.h.
Sets default information.
Definition at line 31 of file photo.cpp.
References description, everSaved, Subalbum::getSubalbumNumber(), imageChecksum, imageLocation, initialPhotoNumber, initialSubalbumNumber, needsSaving, next, recentlyReverted, slideshowChecksum, slideshowLocation, thumbnailChecksum, thumbnailImage, and thumbnailLocation.
00032 { 00033 //set subalbum pointer 00034 this->subalbum = subalbum; 00035 00036 //set prev pointer 00037 this->prev = prev; 00038 00039 //set next pointer to NULL, new photos are always 00040 //inserted at the end of collections 00041 next = NULL; 00042 00043 //set initial photo and subalbum numbers 00044 initialPhotoNumber = photoNumber; 00045 initialSubalbumNumber = subalbum->getSubalbumNumber(); 00046 00047 //set default to the empty string 00048 description = QString::null; 00049 00050 //set thumbnail image 00051 thumbnailImage = NULL; 00052 00053 //set filenames and checksums to null until the actual photo data has been set 00054 imageLocation = QString::null; 00055 imageChecksum = QString::null; 00056 00057 slideshowLocation = QString::null; 00058 slideshowChecksum = QString::null; 00059 00060 thumbnailLocation = QString::null; 00061 thumbnailChecksum = QString::null; 00062 00063 //a default photo is not interesting. once the 00064 //actual photo data or description files have 00065 //been reset the photo will need to be saved. 00066 needsSaving = false; 00067 00068 //by default a photos are assumed to be saved. 00069 //new photos are setup with a uniqueID and we'll set this bool false there 00070 everSaved = true; 00071 00072 //photo not recently reverted 00073 recentlyReverted = false; 00074 }
Photo::~Photo | ( | ) |
Definition at line 76 of file photo.cpp.
References thumbnailImage.
00077 { 00078 //free the thumbnail image 00079 delete thumbnailImage; 00080 }
void Photo::applyTransformation | ( | TRANSFORM_CODE | transformation | ) |
Apply transformation.
Definition at line 475 of file photo.cpp.
References constructSmallerImages(), Subalbum::getAlbum(), getEverSaved(), Album::getTmpDir(), imageLocation, initialPhotoNumber, initialSubalbumNumber, moveFile(), needsSaving, recentlyReverted, slideshowLocation, subalbum, thumbnailLocation, and transformImage().
Referenced by flipHorizontally(), flipVertically(), rotate270(), and rotate90().
00476 { 00477 //backup old filename 00478 QString oldName = imageLocation; 00479 00480 //if the image did not previously need saving, 00481 //reset filenames to point to temporary location and 00482 //immediately perform transformation 00483 if(!needsSaving) 00484 { 00485 imageLocation = subalbum->getAlbum()->getTmpDir() + QString("/%1_%2.jpg") 00486 .arg(initialSubalbumNumber) 00487 .arg(initialPhotoNumber); 00488 slideshowLocation = subalbum->getAlbum()->getTmpDir() + QString("/%1_%2_slideshow.jpg") 00489 .arg(initialSubalbumNumber) 00490 .arg(initialPhotoNumber); 00491 thumbnailLocation = subalbum->getAlbum()->getTmpDir() + QString("/%1_%2_thumb.jpg") 00492 .arg(initialSubalbumNumber) 00493 .arg(initialPhotoNumber); 00494 transformImage( oldName, imageLocation, transformation ); 00495 } 00496 else 00497 { 00498 //images that need saving already exist in the temporary directory 00499 //this poses two problems: 00500 //1.) fast jpeg transformations cannot be done in place, so we'll employ an 00501 // intermediate image 00502 QString intermediateName = QString("%1_intermdiate.jpg").arg(oldName); 00503 transformImage( oldName, intermediateName, transformation ); 00504 00505 //2.) If the photo has never been saved and an orig file in the temporary 00506 // directory does not exist then the current file is the original version. we 00507 // must make sure that this original photo is maintained using an orig file so 00508 // in the future users can revert the photo to it's original form. 00509 QString origName = subalbum->getAlbum()->getTmpDir() + QString("/0_%1_orig.jpg") 00510 .arg(initialPhotoNumber); 00511 QDir tmpDir; 00512 if( !getEverSaved() && !tmpDir.exists(origName) ) 00513 { 00514 moveFile( oldName, origName ); 00515 moveFile( intermediateName, imageLocation ); 00516 } 00517 else 00518 { 00519 moveFile( intermediateName, imageLocation ); 00520 } 00521 } 00522 00523 //image now modified from original form so orig file needs to be kept 00524 recentlyReverted = false; 00525 00526 //construct smaller iamges 00527 constructSmallerImages(); 00528 }
bool Photo::constructSmallerImages | ( | ) |
Construct thumbnail and slideshow images, load up thumbnail image, and set photo has being modified.
Definition at line 84 of file photo.cpp.
References constructImages(), imageLocation, needsSaving, Subalbum::setModified(), slideshowLocation, subalbum, thumbnailImage, and thumbnailLocation.
Referenced by applyTransformation(), and setImage().
00085 { 00086 //construct and save slideshow and thumbnail images 00087 QImage TslideshowImage, TthumbnailImage; 00088 constructImages( imageLocation, TslideshowImage, TthumbnailImage ); 00089 TslideshowImage.save( slideshowLocation, "JPEG", 95 ); 00090 TthumbnailImage.save( thumbnailLocation, "JPEG", 95 ); 00091 00092 //load up thumbnail image 00093 delete thumbnailImage; 00094 thumbnailImage = new QImage(thumbnailLocation); 00095 00096 //image is being stored in temp location, needs saving! 00097 needsSaving = true; 00098 00099 //set the subalbum as being modified and return 00100 subalbum->setModified(); 00101 return true; 00102 }
void Photo::exportToXML | ( | QTextStream & | stream | ) |
Exports photo to xml.
Definition at line 413 of file photo.cpp.
References description, fixXMLString(), getImageFilename(), getSlideshowFilename(), getThumbnailFilename(), imageChecksum, slideshowChecksum, and thumbnailChecksum.
Referenced by Subalbum::exportToXML().
00414 { 00415 QFileInfo info; 00416 00417 //write photo information 00418 stream << " <photo>\n"; 00419 //----- 00420 stream << " <description>" << fixXMLString(description) << "</description>\n"; 00421 //----- 00422 //full image 00423 info.setFile( getImageFilename() ); 00424 QDateTime modified = info.lastModified(); 00425 stream << " <image>\n"; 00426 stream << " <md5>" << fixXMLString(imageChecksum) << "</md5>\n"; 00427 stream << " <modified>"; 00428 stream << modified.date().year() << " "; 00429 stream << modified.date().month() << " "; 00430 stream << modified.date().day() << " "; 00431 stream << modified.time().hour() << " "; 00432 stream << modified.time().minute() << " "; 00433 stream << modified.time().second() << " "; 00434 stream << modified.time().msec() << "</modified>\n"; 00435 stream << " </image>\n"; 00436 //----- 00437 //slidehow image 00438 info.setFile( getSlideshowFilename() ); 00439 modified = info.lastModified(); 00440 stream << " <slideshow>\n"; 00441 stream << " <md5>" << fixXMLString(slideshowChecksum) << "</md5>\n"; 00442 stream << " <modified>"; 00443 stream << modified.date().year() << " "; 00444 stream << modified.date().month() << " "; 00445 stream << modified.date().day() << " "; 00446 stream << modified.time().hour() << " "; 00447 stream << modified.time().minute() << " "; 00448 stream << modified.time().second() << " "; 00449 stream << modified.time().msec() << "</modified>\n"; 00450 stream << " </slideshow>\n"; 00451 //----- 00452 //thumbnail image 00453 info.setFile( getThumbnailFilename() ); 00454 modified = info.lastModified(); 00455 stream << " <thumb>\n"; 00456 stream << " <md5>" << fixXMLString(thumbnailChecksum) << "</md5>\n"; 00457 stream << " <modified>"; 00458 stream << modified.date().year() << " "; 00459 stream << modified.date().month() << " "; 00460 stream << modified.date().day() << " "; 00461 stream << modified.time().hour() << " "; 00462 stream << modified.time().minute() << " "; 00463 stream << modified.time().second() << " "; 00464 stream << modified.time().msec() << "</modified>\n"; 00465 stream << " </thumb>\n"; 00466 //----- 00467 stream << " </photo>\n"; 00468 }
void Photo::flipHorizontally | ( | ) |
Flips image about horizontal axis.
Definition at line 472 of file photo.cpp.
References applyTransformation(), and FLIP_H.
00472 { applyTransformation( FLIP_H ); }
void Photo::flipVertically | ( | ) |
Flips image about vertical axis.
Definition at line 473 of file photo.cpp.
References applyTransformation(), and FLIP_V.
00473 { applyTransformation( FLIP_V ); }
QString Photo::getDescription | ( | ) |
Gets the description.
Definition at line 207 of file photo.cpp.
References description.
Referenced by PhotoDescEdit::PhotoDescEdit(), PhotoPreviewWidget::PhotoPreviewWidget(), SlideshowWidget::showPhoto(), and PhotoPreviewWidget::updateDescription().
00207 { return QString(description); }
bool Photo::getEverSaved | ( | ) |
Returns if the image has ever been saved to a permanant location.
Definition at line 533 of file photo.cpp.
References everSaved.
Referenced by applyTransformation(), Album::exportSubalbumImages(), originalImageFilename(), and setImage().
00533 { return everSaved; }
QString Photo::getImageChecksum | ( | ) |
Get image checksum.
Definition at line 199 of file photo.cpp.
References imageChecksum.
Referenced by Subalbum::importFromDisk().
00199 { return imageChecksum; }
QString Photo::getImageFilename | ( | ) |
Gets the image filename.
Definition at line 191 of file photo.cpp.
References imageLocation.
Referenced by EditingInterface::adjustGrain(), AlbumStatistics::AlbumStatistics(), EditingInterface::applyEffect(), EditingInterface::applyImageUpdate(), EditingInterface::colorBalance(), EditingInterface::crop(), EditingInterface::enhanceContrast(), Album::exportLargeImages(), Album::exportSubalbumImages(), exportToXML(), EditingInterface::finishCorrectTilt(), SlideshowWidget::loadPhoto(), PhotoDescEdit::PhotoDescEdit(), EditingInterface::removeRedeye(), Album::removeStagnantOrigFiles(), EditingInterface::revertCurrentPhoto(), revertPossible(), EditingInterface::rotateFlip(), TitleWidget::setAlbumImage(), EditingInterface::setPhoto(), setWallpaper(), EditingInterface::showNextPrevFirstLastPhoto(), and EditingInterface::tuneLevels().
00191 { return imageLocation; }
int Photo::getInitialPhotoNumber | ( | ) |
Returns initial photo number.
Definition at line 607 of file photo.cpp.
References initialPhotoNumber.
Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().
00607 { return initialPhotoNumber; }
int Photo::getInitialSubalbumNumber | ( | ) |
Returns initial subalbum number.
Definition at line 610 of file photo.cpp.
References initialSubalbumNumber.
Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().
00610 { return initialSubalbumNumber; }
bool Photo::getNeedsSavingVal | ( | ) |
Returns if the image needs to be saved to its permament location.
Definition at line 530 of file photo.cpp.
References needsSaving.
Referenced by Album::exportSubalbumImages().
00530 { return needsSaving; }
Photo * Photo::getNext | ( | ) |
Returns next photo pointer.
Definition at line 224 of file photo.cpp.
References next.
Referenced by SlideshowWidget::advancePhoto(), AlbumStatistics::AlbumStatistics(), SlideshowWidget::beginSlideshow(), Album::exportCompressedWebAlbum(), Album::exportLargeImages(), Album::exportSubalbumImages(), Subalbum::exportToXML(), Album::getThumbnailFilenames(), Subalbum::photoMoved(), SubalbumWidget::refreshPhotos(), Subalbum::removePhoto(), Album::removeStagnantOrigFiles(), Album::reorderSubalbumImages(), EditingInterface::setPhoto(), EditingInterface::showNextPhoto(), EditingInterface::showNextPrevFirstLastPhoto(), Subalbum::syncPhotoList(), and Subalbum::~Subalbum().
00224 { return next; }
Photo * Photo::getPrev | ( | ) |
Returns the previous photo pointer.
Definition at line 223 of file photo.cpp.
References prev.
Referenced by SlideshowWidget::backupPhoto(), Subalbum::photoMoved(), Subalbum::removePhoto(), EditingInterface::setPhoto(), EditingInterface::showNextPrevFirstLastPhoto(), and EditingInterface::showPrevPhoto().
00223 { return prev; }
bool Photo::getRecentlyReverted | ( | ) |
was the photo recently reverted? if so ignore the presence of orig files on disk
Definition at line 546 of file photo.cpp.
References recentlyReverted.
Referenced by Album::exportSubalbumImages(), and Album::removeStagnantOrigFiles().
00547 { 00548 return recentlyReverted; 00549 }
QString Photo::getSlideshowChecksum | ( | ) |
Get thumbanil checksum.
Definition at line 201 of file photo.cpp.
References slideshowChecksum.
Referenced by Subalbum::importFromDisk().
00201 { return slideshowChecksum; }
QString Photo::getSlideshowFilename | ( | ) |
Gets the slideshow filename.
Definition at line 192 of file photo.cpp.
References slideshowLocation.
Referenced by AlbumStatistics::AlbumStatistics(), Album::exportCompressedWebAlbum(), Album::exportSubalbumImages(), exportToXML(), and PhotoDescEdit::PhotoDescEdit().
00192 { return slideshowLocation; }
QString Photo::getThumbnailChecksum | ( | ) |
Get thumbanil checksum.
Definition at line 200 of file photo.cpp.
References thumbnailChecksum.
Referenced by Subalbum::importFromDisk().
00200 { return thumbnailChecksum; }
QString Photo::getThumbnailFilename | ( | ) |
Gets the thumbnail filename.
Definition at line 193 of file photo.cpp.
References thumbnailLocation.
Referenced by Album::exportCompressedWebAlbum(), Album::exportSubalbumImages(), exportToXML(), Album::getThumbnailFilenames(), PhotoDescEdit::PhotoDescEdit(), TitleWidget::setSubalbumImage(), and PhotoPreviewWidget::updateImage().
00193 { return thumbnailLocation; }
QImage * Photo::getThumbnailImage | ( | ) |
Gets thumbnail image.
Definition at line 82 of file photo.cpp.
References thumbnailImage.
00082 { return thumbnailImage; }
QDateTime * Photo::importFromDisk | ( | QDomNode * | root | ) |
Builds photo from XML DOM node, returns date modified info from xml.
Definition at line 238 of file photo.cpp.
References description, imageChecksum, slideshowChecksum, and thumbnailChecksum.
Referenced by Subalbum::importFromDisk().
00239 { 00240 //create modified date/time object for returning 00241 QDateTime* modified = new QDateTime[3]; 00242 00243 QDomNode node = root->firstChild(); 00244 QDomText val; 00245 while( !node.isNull() ) 00246 { 00247 //------------------------------------------------------------ 00248 //photo description 00249 if( node.isElement() && node.nodeName() == "description" ) 00250 { 00251 val = node.firstChild().toText(); 00252 if(!val.isNull()) 00253 description = val.nodeValue(); 00254 description.replace("\\"","\""); 00255 } 00256 //------------------------------------------------------------ 00257 //image information 00258 else if( node.isElement() && node.nodeName() == "image" ) 00259 { 00260 QDomNode childNode = node.firstChild(); 00261 while( !childNode.isNull() ) 00262 { 00263 //------------------------------------------------------------ 00264 if( childNode.isElement() && childNode.nodeName() == "md5" ) 00265 { 00266 val = childNode.firstChild().toText(); 00267 if(!val.isNull()) 00268 imageChecksum = val.nodeValue(); 00269 } 00270 //------------------------------------------------------------ 00271 else if( childNode.isElement() && childNode.nodeName() == "modified" ) 00272 { 00273 val = childNode.firstChild().toText(); 00274 00275 //split value based on spaces, should be 7 fields 00276 QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() ); 00277 int i=0; 00278 int intVals[7]; 00279 QStringList::Iterator it; 00280 for ( it = vals.begin(); it != vals.end(); ++it ) 00281 { 00282 //sanity check incase more fields are provided than there should be 00283 if(i >6) 00284 break; 00285 00286 intVals[i] = QString(*it).toInt(); 00287 i++; 00288 } 00289 modified[0].setDate( QDate(intVals[0], intVals[1], intVals[2]) ); 00290 modified[0].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) ); 00291 } 00292 //------------------------------------------------------------ 00293 childNode = childNode.nextSibling(); 00294 } 00295 } 00296 //------------------------------------------------------------ 00297 //slideshow information 00298 else if( node.isElement() && node.nodeName() == "slideshow" ) 00299 { 00300 QDomNode childNode = node.firstChild(); 00301 while( !childNode.isNull() ) 00302 { 00303 //------------------------------------------------------------ 00304 if( childNode.isElement() && childNode.nodeName() == "md5" ) 00305 { 00306 val = childNode.firstChild().toText(); 00307 if(!val.isNull()) 00308 slideshowChecksum = val.nodeValue(); 00309 } 00310 //------------------------------------------------------------ 00311 else if( childNode.isElement() && childNode.nodeName() == "modified" ) 00312 { 00313 val = childNode.firstChild().toText(); 00314 00315 //split value based on spaces, should be 6 fields 00316 QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() ); 00317 int i=0; 00318 int intVals[7]; 00319 QStringList::Iterator it; 00320 for ( it = vals.begin(); it != vals.end(); ++it ) 00321 { 00322 //sanity check incase more fields are provided than there should be 00323 if(i >6) 00324 break; 00325 00326 intVals[i] = QString(*it).toInt(); 00327 i++; 00328 } 00329 modified[1].setDate( QDate(intVals[0], intVals[1], intVals[2]) ); 00330 modified[1].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) ); 00331 } 00332 //------------------------------------------------------------ 00333 childNode = childNode.nextSibling(); 00334 } 00335 } 00336 //------------------------------------------------------------ 00337 //slideshow information 00338 else if( node.isElement() && node.nodeName() == "thumb" ) 00339 { 00340 QDomNode childNode = node.firstChild(); 00341 while( !childNode.isNull() ) 00342 { 00343 //------------------------------------------------------------ 00344 if( childNode.isElement() && childNode.nodeName() == "md5" ) 00345 { 00346 val = childNode.firstChild().toText(); 00347 if(!val.isNull()) 00348 thumbnailChecksum = val.nodeValue(); 00349 } 00350 //------------------------------------------------------------ 00351 else if( childNode.isElement() && childNode.nodeName() == "modified" ) 00352 { 00353 val = childNode.firstChild().toText(); 00354 00355 //split value based on spaces, should be 6 fields 00356 QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() ); 00357 int i=0; 00358 int intVals[7]; 00359 QStringList::Iterator it; 00360 for ( it = vals.begin(); it != vals.end(); ++it ) 00361 { 00362 //sanity check incase more fields are provided than there should be 00363 if(i >6) 00364 break; 00365 00366 intVals[i] = QString(*it).toInt(); 00367 i++; 00368 } 00369 modified[2].setDate( QDate(intVals[0], intVals[1], intVals[2]) ); 00370 modified[2].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) ); 00371 } 00372 //------------------------------------------------------------ 00373 childNode = childNode.nextSibling(); 00374 } 00375 } 00376 //------------------------------------------------------------ 00377 //------------------------------------------------------------ 00378 //Handle md5 info as specified in 1.0a and 1.0a2 xml format 00379 //image md5 00380 else if( node.isElement() && node.nodeName() == "imageMD5" ) 00381 { 00382 val = node.firstChild().toText(); 00383 if(!val.isNull()) 00384 imageChecksum = val.nodeValue(); 00385 } 00386 //------------------------------------------------------------ 00387 //slideshow md5 00388 else if( node.isElement() && node.nodeName() == "slideMD5" ) 00389 { 00390 val = node.firstChild().toText(); 00391 if(!val.isNull()) 00392 slideshowChecksum = val.nodeValue(); 00393 } 00394 //------------------------------------------------------------ 00395 //thumbnail md5 00396 else if( node.isElement() && node.nodeName() == "thumbMD5" ) 00397 { 00398 val = node.firstChild().toText(); 00399 if(!val.isNull()) 00400 thumbnailChecksum = val.nodeValue(); 00401 } 00402 //------------------------------------------------------------ 00403 //------------------------------------------------------------ 00404 //advance to next node 00405 node = node.nextSibling(); 00406 //------------------------------------------------------------ 00407 } 00408 00409 //return modification dates read in 00410 return modified; 00411 }
QString Photo::originalImageFilename | ( | ) |
orig filename
Definition at line 571 of file photo.cpp.
References Subalbum::getAlbum(), getEverSaved(), Album::getSaveLocation(), imageLocation, initialPhotoNumber, initialSubalbumNumber, and subalbum.
Referenced by Album::removeStagnantOrigFiles(), EditingInterface::revertCurrentPhoto(), revertPhoto(), and revertPossible().
00572 { 00573 //determining the an images original filename is tricky 00574 //if the photo has never been saved check for presence of an _orig file, 00575 //otherwise use the current filename since the photo has not yet been modified 00576 if( !getEverSaved() ) 00577 { 00578 QString tempOrigLocation = imageLocation; 00579 tempOrigLocation.truncate( imageLocation.length() - 4 ); 00580 tempOrigLocation = tempOrigLocation + "_orig.jpg"; 00581 00582 QDir tmpDir; 00583 if(tmpDir.exists( tempOrigLocation ) ) 00584 return tempOrigLocation; 00585 else 00586 return imageLocation; 00587 } 00588 //if the photo was previously saved, it's original form could either be: 00589 //1.) the permanant storage location + _orig 00590 //2.) the permanant storage location 00591 else 00592 { 00593 QString storedOrigLocation = subalbum->getAlbum()->getSaveLocation() + 00594 QString("/img/%1/%2_orig.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber); 00595 00596 QString lastSavedLocation = subalbum->getAlbum()->getSaveLocation() + 00597 QString("/img/%1/%2.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber); 00598 00599 QDir tmpDir; 00600 if(tmpDir.exists( storedOrigLocation ) ) 00601 return storedOrigLocation; 00602 else 00603 return lastSavedLocation; 00604 } 00605 }
void Photo::revertPhoto | ( | ) |
revert photo to original form
Definition at line 556 of file photo.cpp.
References originalImageFilename(), recentlyReverted, revertPossible(), and setImage().
Referenced by EditingInterface::revertCurrentPhoto().
00557 { 00558 //ignore if revert is not possible 00559 if(!revertPossible()) 00560 return; 00561 00562 //set image to reverted form 00563 QString origName = originalImageFilename(); 00564 setImage( origName ); 00565 00566 //recently reverted, orig file should be 00567 //removed during next save since it's redundant 00568 recentlyReverted = true; 00569 }
bool Photo::revertPossible | ( | ) |
can photo be reverted to a differnt original form
Definition at line 536 of file photo.cpp.
References getImageFilename(), originalImageFilename(), and recentlyReverted.
Referenced by EditingInterface::currentPhotoRevertable(), and revertPhoto().
00537 { 00538 //if photo not recently reverted and orig and current filenames differ 00539 QString newName = getImageFilename(); 00540 QString origName = originalImageFilename(); 00541 00542 return ( !recentlyReverted && 00543 origName.compare( newName ) !=0 ); 00544 }
void Photo::rotate270 | ( | ) |
Rotates image clockwise 270 degrees.
Definition at line 471 of file photo.cpp.
References applyTransformation(), and ROTATE_270.
00471 { applyTransformation( ROTATE_270 ); }
void Photo::rotate90 | ( | ) |
Rotates image clockwise 90 degrees.
Definition at line 470 of file photo.cpp.
References applyTransformation(), and ROTATE_90.
00470 { applyTransformation( ROTATE_90 ); }
void Photo::setDescription | ( | QString | val | ) |
Sets the description.
Definition at line 209 of file photo.cpp.
References description, Subalbum::setModified(), and subalbum.
Referenced by Subalbum::addPhoto(), and PhotoDescEdit::disappear().
00210 { 00211 //set empty strings as null, takes up less space and necessary 00212 //to check for string modification 00213 if( val.isEmpty() ) 00214 val = QString::null; 00215 00216 if(description.compare(val) != 0) 00217 { 00218 description = val; 00219 subalbum->setModified(); 00220 } 00221 }
void Photo::setEverSaved | ( | bool | val | ) |
sets everSaved
Definition at line 534 of file photo.cpp.
References everSaved.
Referenced by Album::exportSubalbumImages(), and setImage().
00534 { everSaved = val; }
bool Photo::setImage | ( | QString | editedImageFilename | ) |
Reset photo data after photo editing has taken place.
Slideshow and thumbnail images need to be regenerated.
Definition at line 155 of file photo.cpp.
References constructSmallerImages(), copyFile(), Subalbum::getAlbum(), getEverSaved(), Album::getTmpDir(), imageLocation, initialPhotoNumber, initialSubalbumNumber, recentlyReverted, slideshowLocation, subalbum, and thumbnailLocation.
00156 { 00157 //if the image has been saved then simply change the image,slideshow/thubnail 00158 //filename handles to point to the temporary directory. We don't need to worry about backing up the 00159 //image because the new version will be written to the temporary directory and the save location 00160 if( getEverSaved() ) 00161 { 00162 imageLocation = subalbum->getAlbum()->getTmpDir() + 00163 QString("/%1_%2.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber); 00164 slideshowLocation = subalbum->getAlbum()->getTmpDir() + 00165 QString("/%1_%2_slideshow.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber); 00166 thumbnailLocation = subalbum->getAlbum()->getTmpDir() + 00167 QString("/%1_%2_thumb.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber); 00168 } 00169 //otherwise image has never been saved, make sure original form has been backed up! 00170 else 00171 { 00172 QString tempOrigLocation = imageLocation; 00173 tempOrigLocation.truncate( imageLocation.length() - 4 ); 00174 tempOrigLocation = tempOrigLocation + "_orig.jpg"; 00175 00176 QDir tmpDir; 00177 if(!tmpDir.exists( tempOrigLocation ) ) 00178 { copyFile( imageLocation, tempOrigLocation ); } 00179 } 00180 00181 //copy over full size image 00182 copyFile( editedImageFilename, imageLocation ); 00183 00184 //reset revert flag since image has not been modified 00185 recentlyReverted = false; 00186 00187 //construct smaller iamges 00188 return constructSmallerImages(); 00189 }
bool Photo::setImage | ( | QString | imageName, | |
int | uniqueID | |||
) |
Setup photo using a new image. We'll need to create slideshow and thumbnail images.
Definition at line 123 of file photo.cpp.
References constructSmallerImages(), copyFile(), Subalbum::getAlbum(), Album::getTmpDir(), imageLocation, initialPhotoNumber, initialSubalbumNumber, isJpeg(), setEverSaved(), slideshowLocation, subalbum, and thumbnailLocation.
00124 { 00125 //this is a new photo, use a unique ID to construct temporary filenames 00126 setEverSaved(false); 00127 initialSubalbumNumber = 0; 00128 initialPhotoNumber = uniqueID; 00129 00130 QString tmpDir = subalbum->getAlbum()->getTmpDir(); 00131 imageLocation = QString("%1/%2_%3.jpg") .arg(tmpDir).arg(initialSubalbumNumber).arg(initialPhotoNumber); 00132 slideshowLocation = QString("%1/%2_%3_slideshow.jpg").arg(tmpDir).arg(initialSubalbumNumber).arg(initialPhotoNumber); 00133 thumbnailLocation = QString("%1/%2_%3_thumb.jpg") .arg(tmpDir).arg(initialSubalbumNumber).arg(initialPhotoNumber); 00134 00135 //if image in jpeg format simply copy file over 00136 if( isJpeg(imageName) ) 00137 { 00138 copyFile( imageName, imageLocation ); 00139 } 00140 //otherwise we must load it up and save it out as jpeg 00141 else 00142 { 00143 //if unable to open image at all using Qt then giveup 00144 QImage tempImage(imageName); 00145 if( tempImage.isNull() ) { return false; } 00146 00147 //save out as jpeg 00148 tempImage.save( imageLocation, "JPEG", 95 ); 00149 } 00150 00151 //construct smaller iamges 00152 return constructSmallerImages(); 00153 }
bool Photo::setImage | ( | QString | imageName, | |
QString | slideshowName, | |||
QString | thumbnailName | |||
) |
Setup photo using preexisting full size, slideshow, and thumbnail images.
We call this method when loading photos from disk and resizing is not necessary.
Definition at line 104 of file photo.cpp.
References imageLocation, needsSaving, slideshowLocation, thumbnailImage, and thumbnailLocation.
Referenced by Subalbum::addPhoto(), EditingInterface::applyImageUpdate(), Subalbum::lazyAddPhoto(), revertPhoto(), and EditingInterface::rotateFlip().
00107 { 00108 //set filenames, we'll lazily compute MD5 checksums for files when saving 00109 imageLocation = imageName; 00110 slideshowLocation = slideshowName; 00111 thumbnailLocation = thumbnailName; 00112 00113 //load thumbnail image 00114 delete thumbnailImage; 00115 thumbnailImage = new QImage(thumbnailName); 00116 if(thumbnailImage->isNull()) return false; 00117 00118 //image just loaded, no changes yet 00119 needsSaving = false; 00120 return true; 00121 }
void Photo::setImageChecksum | ( | QString | val | ) |
Update image checksum.
Definition at line 203 of file photo.cpp.
References imageChecksum.
Referenced by Album::exportSubalbumImages().
00203 { imageChecksum = val; }
void Photo::setImageFilename | ( | QString | val | ) |
Sets the image filename.
Definition at line 195 of file photo.cpp.
References imageLocation.
Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().
00195 { imageLocation = val; }
void Photo::setInitialPhotoNumber | ( | int | val | ) |
Sets initial photo number.
Definition at line 608 of file photo.cpp.
References initialPhotoNumber.
Referenced by Album::reorderSubalbumImages().
00608 { initialPhotoNumber = val; }
void Photo::setInitialSubalbumNumber | ( | int | val | ) |
Sets initial subalbum number.
Definition at line 611 of file photo.cpp.
References initialSubalbumNumber.
Referenced by Album::reorderSubalbumImages().
00611 { initialSubalbumNumber = val; }
void Photo::setNeedsSavingVal | ( | bool | val | ) |
Sets if the image needs to be saved to its permanent location.
Definition at line 531 of file photo.cpp.
References needsSaving.
Referenced by Album::exportSubalbumImages().
00531 { needsSaving = val; }
void Photo::setNext | ( | Photo * | val | ) |
Sets next photo pointer.
Definition at line 232 of file photo.cpp.
References next, Subalbum::setModified(), and subalbum.
Referenced by Subalbum::addPhoto(), Subalbum::lazyAddPhoto(), Subalbum::photoMoved(), Subalbum::removePhoto(), and Subalbum::syncPhotoList().
00233 { 00234 next = val; 00235 subalbum->setModified(); 00236 }
void Photo::setPrev | ( | Photo * | val | ) |
Sets prev photo pointer.
Definition at line 226 of file photo.cpp.
References prev, Subalbum::setModified(), and subalbum.
Referenced by Subalbum::addPhoto(), Subalbum::lazyAddPhoto(), Subalbum::photoMoved(), Subalbum::removePhoto(), and Subalbum::syncPhotoList().
00227 { 00228 prev = val; 00229 subalbum->setModified(); 00230 }
void Photo::setRecentlyReverted | ( | bool | val | ) |
reset the recently reverted value to val
Definition at line 551 of file photo.cpp.
References recentlyReverted.
Referenced by Album::removeStagnantOrigFiles().
00552 { 00553 recentlyReverted = val; 00554 }
void Photo::setSlideshowChecksum | ( | QString | val | ) |
Update slideshow checksum.
Definition at line 205 of file photo.cpp.
References slideshowChecksum.
Referenced by Album::exportSubalbumImages().
00205 { slideshowChecksum = val; }
void Photo::setSlideshowFilename | ( | QString | val | ) |
Sets the slideshow filename.
Definition at line 196 of file photo.cpp.
References slideshowLocation.
Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().
00196 { slideshowLocation = val; }
void Photo::setThumbnailChecksum | ( | QString | val | ) |
Update thumbnail checksum.
Definition at line 204 of file photo.cpp.
References thumbnailChecksum.
Referenced by Album::exportSubalbumImages().
00204 { thumbnailChecksum = val; }
void Photo::setThumbnailFilename | ( | QString | val | ) |
Sets the thumbnail filename.
Definition at line 197 of file photo.cpp.
References thumbnailLocation.
Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().
00197 { thumbnailLocation = val; }
QString Photo::description [private] |
Photo description.
Definition at line 202 of file photo.h.
Referenced by exportToXML(), getDescription(), importFromDisk(), Photo(), and setDescription().
bool Photo::everSaved [private] |
Has the photo ever been saved?
Definition at line 221 of file photo.h.
Referenced by getEverSaved(), Photo(), and setEverSaved().
QString Photo::imageChecksum [private] |
MD5 checksums, used to determine if image/thumbnail have been changed.
Definition at line 213 of file photo.h.
Referenced by exportToXML(), getImageChecksum(), importFromDisk(), Photo(), and setImageChecksum().
QString Photo::imageLocation [private] |
Filenames.
Definition at line 208 of file photo.h.
Referenced by applyTransformation(), constructSmallerImages(), getImageFilename(), originalImageFilename(), Photo(), setImage(), and setImageFilename().
int Photo::initialPhotoNumber [private] |
Definition at line 196 of file photo.h.
Referenced by applyTransformation(), getInitialPhotoNumber(), originalImageFilename(), Photo(), setImage(), and setInitialPhotoNumber().
int Photo::initialSubalbumNumber [private] |
Definition at line 199 of file photo.h.
Referenced by applyTransformation(), getInitialSubalbumNumber(), originalImageFilename(), Photo(), setImage(), and setInitialSubalbumNumber().
bool Photo::needsSaving [private] |
Unsaved modifications?
Definition at line 218 of file photo.h.
Referenced by applyTransformation(), constructSmallerImages(), getNeedsSavingVal(), Photo(), setImage(), and setNeedsSavingVal().
Photo* Photo::next [private] |
Photo* Photo::prev [private] |
bool Photo::recentlyReverted [private] |
Has the photo recently been reverted to it's original form? If so during the next save the orig file can safely be remove.
Definition at line 225 of file photo.h.
Referenced by applyTransformation(), getRecentlyReverted(), Photo(), revertPhoto(), revertPossible(), setImage(), and setRecentlyReverted().
QString Photo::slideshowChecksum [private] |
Definition at line 214 of file photo.h.
Referenced by exportToXML(), getSlideshowChecksum(), importFromDisk(), Photo(), and setSlideshowChecksum().
QString Photo::slideshowLocation [private] |
Definition at line 209 of file photo.h.
Referenced by applyTransformation(), constructSmallerImages(), getSlideshowFilename(), Photo(), setImage(), and setSlideshowFilename().
Subalbum* Photo::subalbum [private] |
Subalbum photo is in.
Definition at line 187 of file photo.h.
Referenced by applyTransformation(), constructSmallerImages(), originalImageFilename(), setDescription(), setImage(), setNext(), and setPrev().
QString Photo::thumbnailChecksum [private] |
Definition at line 215 of file photo.h.
Referenced by exportToXML(), getThumbnailChecksum(), importFromDisk(), Photo(), and setThumbnailChecksum().
QImage* Photo::thumbnailImage [private] |
Thumbnail Image.
Definition at line 205 of file photo.h.
Referenced by constructSmallerImages(), getThumbnailImage(), Photo(), setImage(), and ~Photo().
QString Photo::thumbnailLocation [private] |
Definition at line 210 of file photo.h.
Referenced by applyTransformation(), constructSmallerImages(), getThumbnailFilename(), Photo(), setImage(), and setThumbnailFilename().