AlbumShaper 1.0a3
Photo Class Reference

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>

Collaboration diagram for Photo:

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.
 
PhotogetPrev ()
 Returns the previous photo pointer.
 
PhotogetNext ()
 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 (Q3TextStream &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

Subalbumsubalbum
 Subalbum photo is in.
 
Photoprev
 Pointer to prev photo.
 
Photonext
 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.
 

Detailed Description

A photo consists of a full size image, a smaller slide show image, a very small thumbnail image, and a desription.

Definition at line 44 of file photo.h.

Constructor & Destructor Documentation

◆ Photo()

Photo::Photo ( Subalbum * subalbum,
Photo * prev,
int photoNumber )

Sets default information.

Definition at line 32 of file photo.cpp.

33{
34 //set subalbum pointer
35 this->subalbum = subalbum;
36
37 //set prev pointer
38 this->prev = prev;
39
40 //set next pointer to NULL, new photos are always
41 //inserted at the end of collections
42 next = NULL;
43
44 //set initial photo and subalbum numbers
45 initialPhotoNumber = photoNumber;
47
48 //set default to the empty string
49 description = QString::null;
50
51 //set thumbnail image
52 thumbnailImage = NULL;
53
54 //set filenames and checksums to null until the actual photo data has been set
55 imageLocation = QString::null;
56 imageChecksum = QString::null;
57
58 slideshowLocation = QString::null;
59 slideshowChecksum = QString::null;
60
61 thumbnailLocation = QString::null;
62 thumbnailChecksum = QString::null;
63
64 //a default photo is not interesting. once the
65 //actual photo data or description files have
66 //been reset the photo will need to be saved.
67 needsSaving = false;
68
69 //by default a photos are assumed to be saved.
70 //new photos are setup with a uniqueID and we'll set this bool false there
71 everSaved = true;
72
73 //photo not recently reverted
74 recentlyReverted = false;
75}
Subalbum * subalbum
Subalbum photo is in.
Definition photo.h:190
bool everSaved
Has the photo ever been saved?
Definition photo.h:224
QString thumbnailChecksum
Definition photo.h:218
Photo * prev
Pointer to prev photo.
Definition photo.h:193
QString description
Photo description.
Definition photo.h:205
QString thumbnailLocation
Definition photo.h:213
QString slideshowChecksum
Definition photo.h:217
Photo * next
Pointer to next photo.
Definition photo.h:196
QString imageChecksum
MD5 checksums, used to determine if image/thumbnail have been changed.
Definition photo.h:216
int initialSubalbumNumber
Definition photo.h:202
QString imageLocation
Filenames
Definition photo.h:211
bool recentlyReverted
Has the photo recently been reverted to it's original form? If so during the next save the orig file ...
Definition photo.h:228
int initialPhotoNumber
Definition photo.h:199
bool needsSaving
Unsaved modifications?
Definition photo.h:221
QString slideshowLocation
Definition photo.h:212
QImage * thumbnailImage
Thumbnail Image.
Definition photo.h:208
int getSubalbumNumber()
Returns subalbum number.
Definition subalbum.cpp:103

References description, everSaved, Subalbum::getSubalbumNumber(), imageChecksum, imageLocation, initialPhotoNumber, initialSubalbumNumber, needsSaving, next, prev, recentlyReverted, slideshowChecksum, slideshowLocation, subalbum, thumbnailChecksum, thumbnailImage, and thumbnailLocation.

◆ ~Photo()

Photo::~Photo ( )

Definition at line 77 of file photo.cpp.

78{
79 //free the thumbnail image
80 delete thumbnailImage;
81}

References thumbnailImage.

Member Function Documentation

◆ applyTransformation()

void Photo::applyTransformation ( TRANSFORM_CODE transformation)

Apply transformation.

Definition at line 476 of file photo.cpp.

477{
478 //backup old filename
479 QString oldName = imageLocation;
480
481 //if the image did not previously need saving,
482 //reset filenames to point to temporary location and
483 //immediately perform transformation
484 if(!needsSaving)
485 {
486 imageLocation = subalbum->getAlbum()->getTmpDir() + QString("/%1_%2.jpg")
488 .arg(initialPhotoNumber);
489 slideshowLocation = subalbum->getAlbum()->getTmpDir() + QString("/%1_%2_slideshow.jpg")
491 .arg(initialPhotoNumber);
492 thumbnailLocation = subalbum->getAlbum()->getTmpDir() + QString("/%1_%2_thumb.jpg")
494 .arg(initialPhotoNumber);
495 transformImage( oldName, imageLocation, transformation );
496 }
497 else
498 {
499 //images that need saving already exist in the temporary directory
500 //this poses two problems:
501 //1.) fast jpeg transformations cannot be done in place, so we'll employ an
502 // intermediate image
503 QString intermediateName = QString("%1_intermdiate.jpg").arg(oldName);
504 transformImage( oldName, intermediateName, transformation );
505
506 //2.) If the photo has never been saved and an orig file in the temporary
507 // directory does not exist then the current file is the original version. we
508 // must make sure that this original photo is maintained using an orig file so
509 // in the future users can revert the photo to it's original form.
510 QString origName = subalbum->getAlbum()->getTmpDir() + QString("/0_%1_orig.jpg")
511 .arg(initialPhotoNumber);
512 QDir tmpDir;
513 if( !getEverSaved() && !tmpDir.exists(origName) )
514 {
515 moveFile( oldName, origName );
516 moveFile( intermediateName, imageLocation );
517 }
518 else
519 {
520 moveFile( intermediateName, imageLocation );
521 }
522 }
523
524 //image now modified from original form so orig file needs to be kept
525 recentlyReverted = false;
526
527 //construct smaller iamges
529}
QString getTmpDir()
Returns the temporary directory for use when modifying and adding new images.
Definition album.cpp:142
bool getEverSaved()
Returns if the image has ever been saved to a permanant location.
Definition photo.cpp:534
bool constructSmallerImages()
Construct thumbnail and slideshow images, load up thumbnail image, and set photo has being modified.
Definition photo.cpp:85
Album * getAlbum()
returns the album pointer
Definition subalbum.cpp:95
bool moveFile(QString oldName, QString newName)
Definition fileTools.cpp:40
bool transformImage(QString fileIn, QString fileOut, TRANSFORM_CODE transformation)
Apply image transformation on image

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().

◆ constructSmallerImages()

bool Photo::constructSmallerImages ( )

Construct thumbnail and slideshow images, load up thumbnail image, and set photo has being modified.

Definition at line 85 of file photo.cpp.

86{
87 //construct and save slideshow and thumbnail images
88 QImage TslideshowImage, TthumbnailImage;
89 constructImages( imageLocation, TslideshowImage, TthumbnailImage );
90 TslideshowImage.save( slideshowLocation, "JPEG", 95 );
91 TthumbnailImage.save( thumbnailLocation, "JPEG", 95 );
92
93 //load up thumbnail image
94 delete thumbnailImage;
96
97 //image is being stored in temp location, needs saving!
98 needsSaving = true;
99
100 //set the subalbum as being modified and return
102 return true;
103}
void setModified()
Definition subalbum.cpp:172
void constructImages(QString imageName, QImage &slideshowImage, QImage &thumbnailImage)
Constructs slideshow and thumbnail images for a full sized image.

References constructImages(), imageLocation, needsSaving, Subalbum::setModified(), slideshowLocation, subalbum, thumbnailImage, and thumbnailLocation.

Referenced by applyTransformation(), setImage(), and setImage().

◆ exportToXML()

void Photo::exportToXML ( Q3TextStream & stream)

Exports photo to xml.

Definition at line 414 of file photo.cpp.

415{
416 QFileInfo info;
417
418 //write photo information
419 stream << " <photo>\n";
420 //-----
421 stream << " <description>" << fixXMLString(description) << "</description>\n";
422 //-----
423 //full image
424 info.setFile( getImageFilename() );
425 QDateTime modified = info.lastModified();
426 stream << " <image>\n";
427 stream << " <md5>" << fixXMLString(imageChecksum) << "</md5>\n";
428 stream << " <modified>";
429 stream << modified.date().year() << " ";
430 stream << modified.date().month() << " ";
431 stream << modified.date().day() << " ";
432 stream << modified.time().hour() << " ";
433 stream << modified.time().minute() << " ";
434 stream << modified.time().second() << " ";
435 stream << modified.time().msec() << "</modified>\n";
436 stream << " </image>\n";
437 //-----
438 //slidehow image
439 info.setFile( getSlideshowFilename() );
440 modified = info.lastModified();
441 stream << " <slideshow>\n";
442 stream << " <md5>" << fixXMLString(slideshowChecksum) << "</md5>\n";
443 stream << " <modified>";
444 stream << modified.date().year() << " ";
445 stream << modified.date().month() << " ";
446 stream << modified.date().day() << " ";
447 stream << modified.time().hour() << " ";
448 stream << modified.time().minute() << " ";
449 stream << modified.time().second() << " ";
450 stream << modified.time().msec() << "</modified>\n";
451 stream << " </slideshow>\n";
452 //-----
453 //thumbnail image
454 info.setFile( getThumbnailFilename() );
455 modified = info.lastModified();
456 stream << " <thumb>\n";
457 stream << " <md5>" << fixXMLString(thumbnailChecksum) << "</md5>\n";
458 stream << " <modified>";
459 stream << modified.date().year() << " ";
460 stream << modified.date().month() << " ";
461 stream << modified.date().day() << " ";
462 stream << modified.time().hour() << " ";
463 stream << modified.time().minute() << " ";
464 stream << modified.time().second() << " ";
465 stream << modified.time().msec() << "</modified>\n";
466 stream << " </thumb>\n";
467 //-----
468 stream << " </photo>\n";
469}
QString getImageFilename()
Gets the image filename.
Definition photo.cpp:192
QString getThumbnailFilename()
Gets the thumbnail filename.
Definition photo.cpp:194
QString getSlideshowFilename()
Gets the slideshow filename.
Definition photo.cpp:193
QString fixXMLString(QString text)
Fix strings before exporting to XML such that & becomes &, etc...
Definition xmlTools.cpp:36

References description, fixXMLString(), getImageFilename(), getSlideshowFilename(), getThumbnailFilename(), imageChecksum, slideshowChecksum, and thumbnailChecksum.

Referenced by Subalbum::exportToXML().

◆ flipHorizontally()

void Photo::flipHorizontally ( )

Flips image about horizontal axis.

Definition at line 473 of file photo.cpp.

void applyTransformation(TRANSFORM_CODE transformation)
Apply transformation.
Definition photo.cpp:476
@ FLIP_H
Definition imageTools.h:28

References applyTransformation(), and FLIP_H.

◆ flipVertically()

void Photo::flipVertically ( )

Flips image about vertical axis.

Definition at line 474 of file photo.cpp.

@ FLIP_V
Definition imageTools.h:29

References applyTransformation(), and FLIP_V.

◆ getDescription()

QString Photo::getDescription ( )

Gets the description.

Definition at line 208 of file photo.cpp.

208{ return QString(description); }

References description.

Referenced by PhotoDescEdit::PhotoDescEdit(), PhotoPreviewWidget::PhotoPreviewWidget(), SlideshowWidget::showPhoto(), and PhotoPreviewWidget::updateDescription().

◆ getEverSaved()

bool Photo::getEverSaved ( )

Returns if the image has ever been saved to a permanant location.

Definition at line 534 of file photo.cpp.

534{ return everSaved; }

References everSaved.

Referenced by applyTransformation(), Album::exportSubalbumImages(), originalImageFilename(), and setImage().

◆ getImageChecksum()

QString Photo::getImageChecksum ( )

Get image checksum.

Definition at line 200 of file photo.cpp.

200{ return imageChecksum; }

References imageChecksum.

Referenced by Subalbum::importFromDisk().

◆ getImageFilename()

◆ getInitialPhotoNumber()

int Photo::getInitialPhotoNumber ( )

Returns initial photo number.

Definition at line 608 of file photo.cpp.

608{ return initialPhotoNumber; }

References initialPhotoNumber.

Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().

◆ getInitialSubalbumNumber()

int Photo::getInitialSubalbumNumber ( )

Returns initial subalbum number.

Definition at line 611 of file photo.cpp.

611{ return initialSubalbumNumber; }

References initialSubalbumNumber.

Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().

◆ getNeedsSavingVal()

bool Photo::getNeedsSavingVal ( )

Returns if the image needs to be saved to its permament location.

Definition at line 531 of file photo.cpp.

531{ return needsSaving; }

References needsSaving.

Referenced by Album::exportSubalbumImages().

◆ getNext()

◆ getPrev()

Photo * Photo::getPrev ( )

◆ getRecentlyReverted()

bool Photo::getRecentlyReverted ( )

was the photo recently reverted? if so ignore the presence of orig files on disk

Definition at line 547 of file photo.cpp.

548{
549 return recentlyReverted;
550}

References recentlyReverted.

Referenced by Album::exportSubalbumImages(), and Album::removeStagnantOrigFiles().

◆ getSlideshowChecksum()

QString Photo::getSlideshowChecksum ( )

Get thumbanil checksum.

Definition at line 202 of file photo.cpp.

202{ return slideshowChecksum; }

References slideshowChecksum.

Referenced by Subalbum::importFromDisk().

◆ getSlideshowFilename()

QString Photo::getSlideshowFilename ( )

◆ getThumbnailChecksum()

QString Photo::getThumbnailChecksum ( )

Get thumbanil checksum.

Definition at line 201 of file photo.cpp.

201{ return thumbnailChecksum; }

References thumbnailChecksum.

Referenced by Subalbum::importFromDisk().

◆ getThumbnailFilename()

◆ getThumbnailImage()

QImage * Photo::getThumbnailImage ( )

Gets thumbnail image.

Definition at line 83 of file photo.cpp.

83{ return thumbnailImage; }

References thumbnailImage.

◆ importFromDisk()

QDateTime * Photo::importFromDisk ( QDomNode * root)

Builds photo from XML DOM node, returns date modified info from xml.

Definition at line 239 of file photo.cpp.

240{
241 //create modified date/time object for returning
242 QDateTime* modified = new QDateTime[3];
243
244 QDomNode node = root->firstChild();
245 QDomText val;
246 while( !node.isNull() )
247 {
248 //------------------------------------------------------------
249 //photo description
250 if( node.isElement() && node.nodeName() == "description" )
251 {
252 val = node.firstChild().toText();
253 if(!val.isNull())
254 description = val.nodeValue();
255 description.replace("\\&quot;","\"");
256 }
257 //------------------------------------------------------------
258 //image information
259 else if( node.isElement() && node.nodeName() == "image" )
260 {
261 QDomNode childNode = node.firstChild();
262 while( !childNode.isNull() )
263 {
264 //------------------------------------------------------------
265 if( childNode.isElement() && childNode.nodeName() == "md5" )
266 {
267 val = childNode.firstChild().toText();
268 if(!val.isNull())
269 imageChecksum = val.nodeValue();
270 }
271 //------------------------------------------------------------
272 else if( childNode.isElement() && childNode.nodeName() == "modified" )
273 {
274 val = childNode.firstChild().toText();
275
276 //split value based on spaces, should be 7 fields
277 QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() );
278 int i=0;
279 int intVals[7];
280 QStringList::Iterator it;
281 for ( it = vals.begin(); it != vals.end(); ++it )
282 {
283 //sanity check incase more fields are provided than there should be
284 if(i >6)
285 break;
286
287 intVals[i] = QString(*it).toInt();
288 i++;
289 }
290 modified[0].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
291 modified[0].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
292 }
293 //------------------------------------------------------------
294 childNode = childNode.nextSibling();
295 }
296 }
297 //------------------------------------------------------------
298 //slideshow information
299 else if( node.isElement() && node.nodeName() == "slideshow" )
300 {
301 QDomNode childNode = node.firstChild();
302 while( !childNode.isNull() )
303 {
304 //------------------------------------------------------------
305 if( childNode.isElement() && childNode.nodeName() == "md5" )
306 {
307 val = childNode.firstChild().toText();
308 if(!val.isNull())
309 slideshowChecksum = val.nodeValue();
310 }
311 //------------------------------------------------------------
312 else if( childNode.isElement() && childNode.nodeName() == "modified" )
313 {
314 val = childNode.firstChild().toText();
315
316 //split value based on spaces, should be 6 fields
317 QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() );
318 int i=0;
319 int intVals[7];
320 QStringList::Iterator it;
321 for ( it = vals.begin(); it != vals.end(); ++it )
322 {
323 //sanity check incase more fields are provided than there should be
324 if(i >6)
325 break;
326
327 intVals[i] = QString(*it).toInt();
328 i++;
329 }
330 modified[1].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
331 modified[1].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
332 }
333 //------------------------------------------------------------
334 childNode = childNode.nextSibling();
335 }
336 }
337 //------------------------------------------------------------
338 //slideshow information
339 else if( node.isElement() && node.nodeName() == "thumb" )
340 {
341 QDomNode childNode = node.firstChild();
342 while( !childNode.isNull() )
343 {
344 //------------------------------------------------------------
345 if( childNode.isElement() && childNode.nodeName() == "md5" )
346 {
347 val = childNode.firstChild().toText();
348 if(!val.isNull())
349 thumbnailChecksum = val.nodeValue();
350 }
351 //------------------------------------------------------------
352 else if( childNode.isElement() && childNode.nodeName() == "modified" )
353 {
354 val = childNode.firstChild().toText();
355
356 //split value based on spaces, should be 6 fields
357 QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() );
358 int i=0;
359 int intVals[7];
360 QStringList::Iterator it;
361 for ( it = vals.begin(); it != vals.end(); ++it )
362 {
363 //sanity check incase more fields are provided than there should be
364 if(i >6)
365 break;
366
367 intVals[i] = QString(*it).toInt();
368 i++;
369 }
370 modified[2].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
371 modified[2].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
372 }
373 //------------------------------------------------------------
374 childNode = childNode.nextSibling();
375 }
376 }
377 //------------------------------------------------------------
378 //------------------------------------------------------------
379 //Handle md5 info as specified in 1.0a and 1.0a2 xml format
380 //image md5
381 else if( node.isElement() && node.nodeName() == "imageMD5" )
382 {
383 val = node.firstChild().toText();
384 if(!val.isNull())
385 imageChecksum = val.nodeValue();
386 }
387 //------------------------------------------------------------
388 //slideshow md5
389 else if( node.isElement() && node.nodeName() == "slideMD5" )
390 {
391 val = node.firstChild().toText();
392 if(!val.isNull())
393 slideshowChecksum = val.nodeValue();
394 }
395 //------------------------------------------------------------
396 //thumbnail md5
397 else if( node.isElement() && node.nodeName() == "thumbMD5" )
398 {
399 val = node.firstChild().toText();
400 if(!val.isNull())
401 thumbnailChecksum = val.nodeValue();
402 }
403 //------------------------------------------------------------
404 //------------------------------------------------------------
405 //advance to next node
406 node = node.nextSibling();
407 //------------------------------------------------------------
408 }
409
410 //return modification dates read in
411 return modified;
412}

References description, imageChecksum, slideshowChecksum, and thumbnailChecksum.

Referenced by Subalbum::importFromDisk().

◆ originalImageFilename()

QString Photo::originalImageFilename ( )

orig filename

Definition at line 572 of file photo.cpp.

573{
574 //determining the an images original filename is tricky
575 //if the photo has never been saved check for presence of an _orig file,
576 //otherwise use the current filename since the photo has not yet been modified
577 if( !getEverSaved() )
578 {
579 QString tempOrigLocation = imageLocation;
580 tempOrigLocation.truncate( imageLocation.length() - 4 );
581 tempOrigLocation = tempOrigLocation + "_orig.jpg";
582
583 QDir tmpDir;
584 if(tmpDir.exists( tempOrigLocation ) )
585 return tempOrigLocation;
586 else
587 return imageLocation;
588 }
589 //if the photo was previously saved, it's original form could either be:
590 //1.) the permanant storage location + _orig
591 //2.) the permanant storage location
592 else
593 {
594 QString storedOrigLocation = subalbum->getAlbum()->getSaveLocation() +
595 QString("/img/%1/%2_orig.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber);
596
597 QString lastSavedLocation = subalbum->getAlbum()->getSaveLocation() +
598 QString("/img/%1/%2.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber);
599
600 QDir tmpDir;
601 if(tmpDir.exists( storedOrigLocation ) )
602 return storedOrigLocation;
603 else
604 return lastSavedLocation;
605 }
606}
QString getSaveLocation()
Returns the current save location of all images.
Definition album.cpp:141

References Subalbum::getAlbum(), getEverSaved(), Album::getSaveLocation(), imageLocation, initialPhotoNumber, initialSubalbumNumber, and subalbum.

Referenced by Album::removeStagnantOrigFiles(), EditingInterface::revertCurrentPhoto(), revertPhoto(), and revertPossible().

◆ revertPhoto()

void Photo::revertPhoto ( )

revert photo to original form

Definition at line 557 of file photo.cpp.

558{
559 //ignore if revert is not possible
560 if(!revertPossible())
561 return;
562
563 //set image to reverted form
564 QString origName = originalImageFilename();
565 setImage( origName );
566
567 //recently reverted, orig file should be
568 //removed during next save since it's redundant
569 recentlyReverted = true;
570}
bool setImage(QString imageName, QString slideshowName, QString thumbnailName)
Setup photo using preexisting full size, slideshow, and thumbnail images.
Definition photo.cpp:105
QString originalImageFilename()
orig filename
Definition photo.cpp:572
bool revertPossible()
can photo be reverted to a differnt original form
Definition photo.cpp:537

References originalImageFilename(), recentlyReverted, revertPossible(), and setImage().

Referenced by EditingInterface::revertCurrentPhoto().

◆ revertPossible()

bool Photo::revertPossible ( )

can photo be reverted to a differnt original form

Definition at line 537 of file photo.cpp.

538{
539 //if photo not recently reverted and orig and current filenames differ
540 QString newName = getImageFilename();
541 QString origName = originalImageFilename();
542
543 return ( !recentlyReverted &&
544 origName.compare( newName ) !=0 );
545}

References getImageFilename(), originalImageFilename(), and recentlyReverted.

Referenced by EditingInterface::currentPhotoRevertable(), and revertPhoto().

◆ rotate270()

void Photo::rotate270 ( )

Rotates image clockwise 270 degrees.

Definition at line 472 of file photo.cpp.

@ ROTATE_270
Definition imageTools.h:27

References applyTransformation(), and ROTATE_270.

◆ rotate90()

void Photo::rotate90 ( )

Rotates image clockwise 90 degrees.

Definition at line 471 of file photo.cpp.

@ ROTATE_90
Definition imageTools.h:26

References applyTransformation(), and ROTATE_90.

◆ setDescription()

void Photo::setDescription ( QString val)

Sets the description.

Definition at line 210 of file photo.cpp.

211{
212 //set empty strings as null, takes up less space and necessary
213 //to check for string modification
214 if( val.isEmpty() )
215 val = QString::null;
216
217 if(description.compare(val) != 0)
218 {
219 description = val;
221 }
222}

References description, Subalbum::setModified(), and subalbum.

Referenced by Subalbum::addPhoto(), and PhotoDescEdit::disappear().

◆ setEverSaved()

void Photo::setEverSaved ( bool val)

sets everSaved

Definition at line 535 of file photo.cpp.

535{ everSaved = val; }

References everSaved.

Referenced by Album::exportSubalbumImages(), and setImage().

◆ setImage() [1/3]

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 156 of file photo.cpp.

157{
158 //if the image has been saved then simply change the image,slideshow/thubnail
159 //filename handles to point to the temporary directory. We don't need to worry about backing up the
160 //image because the new version will be written to the temporary directory and the save location
161 if( getEverSaved() )
162 {
164 QString("/%1_%2.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber);
166 QString("/%1_%2_slideshow.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber);
168 QString("/%1_%2_thumb.jpg").arg(initialSubalbumNumber).arg(initialPhotoNumber);
169 }
170 //otherwise image has never been saved, make sure original form has been backed up!
171 else
172 {
173 QString tempOrigLocation = imageLocation;
174 tempOrigLocation.truncate( imageLocation.length() - 4 );
175 tempOrigLocation = tempOrigLocation + "_orig.jpg";
176
177 QDir tmpDir;
178 if(!tmpDir.exists( tempOrigLocation ) )
179 { copyFile( imageLocation, tempOrigLocation ); }
180 }
181
182 //copy over full size image
183 copyFile( editedImageFilename, imageLocation );
184
185 //reset revert flag since image has not been modified
186 recentlyReverted = false;
187
188 //construct smaller iamges
189 return constructSmallerImages();
190}
bool copyFile(QString oldFilePath, QString newFilePath)
Copies a file from one location to another.
Definition fileTools.cpp:61

References constructSmallerImages(), copyFile(), Subalbum::getAlbum(), getEverSaved(), Album::getTmpDir(), imageLocation, initialPhotoNumber, initialSubalbumNumber, recentlyReverted, slideshowLocation, subalbum, and thumbnailLocation.

◆ setImage() [2/3]

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 124 of file photo.cpp.

125{
126 //this is a new photo, use a unique ID to construct temporary filenames
127 setEverSaved(false);
129 initialPhotoNumber = uniqueID;
130
131 QString tmpDir = subalbum->getAlbum()->getTmpDir();
132 imageLocation = QString("%1/%2_%3.jpg") .arg(tmpDir).arg(initialSubalbumNumber).arg(initialPhotoNumber);
133 slideshowLocation = QString("%1/%2_%3_slideshow.jpg").arg(tmpDir).arg(initialSubalbumNumber).arg(initialPhotoNumber);
134 thumbnailLocation = QString("%1/%2_%3_thumb.jpg") .arg(tmpDir).arg(initialSubalbumNumber).arg(initialPhotoNumber);
135
136 //if image in jpeg format simply copy file over
137 if( isJpeg(imageName) )
138 {
139 copyFile( imageName, imageLocation );
140 }
141 //otherwise we must load it up and save it out as jpeg
142 else
143 {
144 //if unable to open image at all using Qt then giveup
145 QImage tempImage(imageName);
146 if( tempImage.isNull() ) { return false; }
147
148 //save out as jpeg
149 tempImage.save( imageLocation, "JPEG", 95 );
150 }
151
152 //construct smaller iamges
153 return constructSmallerImages();
154}
void setEverSaved(bool val)
sets everSaved
Definition photo.cpp:535
bool isJpeg(const char *filename)
Checks to see if an image is a valid jpg by seeing if the image dimensions can be read.

References constructSmallerImages(), copyFile(), Subalbum::getAlbum(), Album::getTmpDir(), imageLocation, initialPhotoNumber, initialSubalbumNumber, isJpeg(), setEverSaved(), slideshowLocation, subalbum, and thumbnailLocation.

◆ setImage() [3/3]

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 105 of file photo.cpp.

108{
109 //set filenames, we'll lazily compute MD5 checksums for files when saving
110 imageLocation = imageName;
111 slideshowLocation = slideshowName;
112 thumbnailLocation = thumbnailName;
113
114 //load thumbnail image
115 delete thumbnailImage;
116 thumbnailImage = new QImage(thumbnailName);
117 if(thumbnailImage->isNull()) return false;
118
119 //image just loaded, no changes yet
120 needsSaving = false;
121 return true;
122}

References imageLocation, needsSaving, slideshowLocation, thumbnailImage, and thumbnailLocation.

Referenced by Subalbum::addPhoto(), EditingInterface::applyImageUpdate(), Subalbum::lazyAddPhoto(), revertPhoto(), and EditingInterface::rotateFlip().

◆ setImageChecksum()

void Photo::setImageChecksum ( QString val)

Update image checksum.

Definition at line 204 of file photo.cpp.

204{ imageChecksum = val; }

References imageChecksum.

Referenced by Album::exportSubalbumImages().

◆ setImageFilename()

void Photo::setImageFilename ( QString val)

Sets the image filename.

Definition at line 196 of file photo.cpp.

196{ imageLocation = val; }

References imageLocation.

Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().

◆ setInitialPhotoNumber()

void Photo::setInitialPhotoNumber ( int val)

Sets initial photo number.

Definition at line 609 of file photo.cpp.

609{ initialPhotoNumber = val; }

References initialPhotoNumber.

Referenced by Album::reorderSubalbumImages().

◆ setInitialSubalbumNumber()

void Photo::setInitialSubalbumNumber ( int val)

Sets initial subalbum number.

Definition at line 612 of file photo.cpp.

612{ initialSubalbumNumber = val; }

References initialSubalbumNumber.

Referenced by Album::reorderSubalbumImages().

◆ setNeedsSavingVal()

void Photo::setNeedsSavingVal ( bool val)

Sets if the image needs to be saved to its permanent location.

Definition at line 532 of file photo.cpp.

532{ needsSaving = val; }

References needsSaving.

Referenced by Album::exportSubalbumImages().

◆ setNext()

void Photo::setNext ( Photo * val)

Sets next photo pointer.

Definition at line 233 of file photo.cpp.

234{
235 next = val;
237}

References next, Subalbum::setModified(), and subalbum.

Referenced by Subalbum::addPhoto(), Subalbum::addPhoto(), Subalbum::lazyAddPhoto(), Subalbum::photoMoved(), Subalbum::removePhoto(), and Subalbum::syncPhotoList().

◆ setPrev()

void Photo::setPrev ( Photo * val)

Sets prev photo pointer.

Definition at line 227 of file photo.cpp.

228{
229 prev = val;
231}

References prev, Subalbum::setModified(), and subalbum.

Referenced by Subalbum::addPhoto(), Subalbum::addPhoto(), Subalbum::lazyAddPhoto(), Subalbum::photoMoved(), Subalbum::removePhoto(), and Subalbum::syncPhotoList().

◆ setRecentlyReverted()

void Photo::setRecentlyReverted ( bool val)

reset the recently reverted value to val

Definition at line 552 of file photo.cpp.

553{
554 recentlyReverted = val;
555}

References recentlyReverted.

Referenced by Album::removeStagnantOrigFiles().

◆ setSlideshowChecksum()

void Photo::setSlideshowChecksum ( QString val)

Update slideshow checksum.

Definition at line 206 of file photo.cpp.

206{ slideshowChecksum = val; }

References slideshowChecksum.

Referenced by Album::exportSubalbumImages().

◆ setSlideshowFilename()

void Photo::setSlideshowFilename ( QString val)

Sets the slideshow filename.

Definition at line 197 of file photo.cpp.

197{ slideshowLocation = val; }

References slideshowLocation.

Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().

◆ setThumbnailChecksum()

void Photo::setThumbnailChecksum ( QString val)

Update thumbnail checksum.

Definition at line 205 of file photo.cpp.

205{ thumbnailChecksum = val; }

References thumbnailChecksum.

Referenced by Album::exportSubalbumImages().

◆ setThumbnailFilename()

void Photo::setThumbnailFilename ( QString val)

Sets the thumbnail filename.

Definition at line 198 of file photo.cpp.

198{ thumbnailLocation = val; }

References thumbnailLocation.

Referenced by Album::exportSubalbumImages(), and Album::reorderSubalbumImages().

Member Data Documentation

◆ description

QString Photo::description
private

Photo description.

Definition at line 205 of file photo.h.

Referenced by exportToXML(), getDescription(), importFromDisk(), Photo(), and setDescription().

◆ everSaved

bool Photo::everSaved
private

Has the photo ever been saved?

Definition at line 224 of file photo.h.

Referenced by getEverSaved(), Photo(), and setEverSaved().

◆ imageChecksum

QString Photo::imageChecksum
private

MD5 checksums, used to determine if image/thumbnail have been changed.

Definition at line 216 of file photo.h.

Referenced by exportToXML(), getImageChecksum(), importFromDisk(), Photo(), and setImageChecksum().

◆ imageLocation

QString Photo::imageLocation
private

◆ initialPhotoNumber

int Photo::initialPhotoNumber
private

◆ initialSubalbumNumber

int Photo::initialSubalbumNumber
private

◆ needsSaving

bool Photo::needsSaving
private

Unsaved modifications?

Definition at line 221 of file photo.h.

Referenced by applyTransformation(), constructSmallerImages(), getNeedsSavingVal(), Photo(), setImage(), and setNeedsSavingVal().

◆ next

Photo* Photo::next
private

Pointer to next photo.

Definition at line 196 of file photo.h.

Referenced by getNext(), Photo(), and setNext().

◆ prev

Photo* Photo::prev
private

Pointer to prev photo.

Definition at line 193 of file photo.h.

Referenced by getPrev(), Photo(), and setPrev().

◆ recentlyReverted

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 228 of file photo.h.

Referenced by applyTransformation(), getRecentlyReverted(), Photo(), revertPhoto(), revertPossible(), setImage(), and setRecentlyReverted().

◆ slideshowChecksum

QString Photo::slideshowChecksum
private

◆ slideshowLocation

QString Photo::slideshowLocation
private

◆ subalbum

Subalbum* Photo::subalbum
private

◆ thumbnailChecksum

QString Photo::thumbnailChecksum
private

◆ thumbnailImage

QImage* Photo::thumbnailImage
private

Thumbnail Image.

Definition at line 208 of file photo.h.

Referenced by constructSmallerImages(), getThumbnailImage(), Photo(), setImage(), and ~Photo().

◆ thumbnailLocation

QString Photo::thumbnailLocation
private

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