Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Photo Class Reference

#include <photo.h>

Collaboration diagram for Photo:

Collaboration graph
[legend]
List of all members.

Detailed Description

A photo consists of an image and a description.

Definition at line 41 of file photo.h.

Public Member Functions

 Photo (Subalbum *subalbum, int number)
 Sets default information.

 ~Photo ()
 Destructor.

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 getImageFilename ()
 Gets the image filename.

QString getSlideshowFilename ()
 Gets the slideshow filename.

QString getThumbnailFilename ()
 Gets the thumbnail filename.

bool setImage (const QString &imageName)
 Sets image, returns TRUE if successful, this method used when loading and image from file for the first time (aka when photo added to subalbum).

bool setImage (const QString &imageName, const QString &slideshowName, const QString &thumbnailName)
 Sets the image, uses loads thumbnail and slideshow from file (no scaling), returns TRUE if successful.

bool setImage (QImage *fullImage)
 Sets the image.

void setDescription (QString val)
 Sets the description.

QString getDescription ()
 Gets the description.

PhotogetNext ()
 Gets pointer to next photo.

void setNext (Photo *val)
 Sets pointer to next photo.

QImage * getImage (int size)
 Gets image.

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 exportThumbnailHTML (QTextStream &stream)
 Exports to thumbnail html format.

void exportSlideshowHTML (QTextStream &stream)
 Exports to slideshow html format.

void rotate90 ()
 Rotates image clockwise by 90 degrees.

void rotate270 ()
 Rotates image clockwise by 270 degrees.

void flipHorizontally ()
 Flips image about horizontal axis.

void flipVertically ()
 Flips image about vertical axis.

void setThumbnailChecksum (QString val)
 Update thumbnail checksum.

void setSlideshowChecksum (QString val)
 Update slideshow checksum.

void setImageChecksum (QString val)
 Update image checksum.

QString getThumbnailChecksum ()
 Get thumbanil checksum.

QString getSlideshowChecksum ()
 Get thumbanil checksum.

QString getImageChecksum ()
 Get image checksum.

void deallocateLargeImages ()
 Frees full image and slideshow versions to conserve memory.

void setNeedsSavingVal (bool val)
 Sets if the image needs to be saved to its permanent location.

bool getNeedsSavingVal ()
 Returns if the image needs to be saved to its permament location.

int getInitialPhotoNumber ()
 Returns initial photo number.

int getInitialSubalbumNumber ()
 Returns intiial subalbum number.

void setInitialPhotoNumber (int val)
 Sets initial photo number.

void setInitialSubalbumNumber (int val)
 Sets initial subalbum number.

int actualSlideshowWidth ()
 Return actual slideshow image width (not including whitespace).

int actualSlideshowHeight ()
 Return actual slideshow image height (not including whitespace).

void setActualSlideshowDimensions (int w, int h)
 Sets actual slideshow image size.


Private Attributes

Subalbumsubalbum
 Subalbum photo is in.

int initialNumber
int initialSubalbumNumber
Photonext
 Pointer to next photo.

QString description
 Longer description of subalbum.

QImage * thumbnailImage
 Thumbnail used for saving to disk.

QImage * paddedThumbnailImage
 A padded thumbnail used for subalbum layout.

QImage * slideshowImage
 Slideshow iamge.

QImage * fullImage
 Actual image.

QString imageChecksum
 MD5 checksums, ued to determine if image/thumbnail have been changed.

QString slideshowChecksum
QString thumbnailChecksum
QString imageLocation
 Image filename.

QString slideshowLocation
 Slideshow filename.

QString thumbnailLocation
 Thumbnail filename.

bool needsSaving
 Does the image need to be saved to the permanent location?

int slideshowWidth
 Unpadded width of slideshow image.

int slideshowHeight
 Unpadded height of slideshow image.


Constructor & Destructor Documentation

Photo::Photo Subalbum subalbum,
int  number
 

Sets default information.

Definition at line 36 of file photo.cpp.

References description, fullImage, imageChecksum, imageLocation, initialNumber, initialSubalbumNumber, needsSaving, next, paddedThumbnailImage, slideshowChecksum, slideshowHeight, slideshowImage, slideshowLocation, slideshowWidth, thumbnailChecksum, thumbnailImage, and thumbnailLocation.

00037 {
00038   //set subalbum pointer
00039   this->subalbum = subalbum;
00040   
00041   //set initial photo number and subalbum number
00042   initialNumber = number;
00043   initialSubalbumNumber = subalbum->getSubalbumNumber();
00044   
00045   //set strings to default values
00046   description = QString::null;;
00047 
00048   //set next pointer to NULL
00049   next = NULL;
00050   
00051   //set thumbnail image
00052   thumbnailImage = NULL;
00053   paddedThumbnailImage = NULL; 
00054   slideshowImage = NULL;
00055   fullImage = NULL;
00056   
00057   //set checksums to the empty string by default
00058   imageChecksum = QString::null;
00059   slideshowChecksum = QString::null;
00060   thumbnailChecksum = QString::null;
00061   
00062   //image does not need to be saved by default
00063   needsSaving = false;
00064   
00065   //filenames not set by default
00066   imageLocation = QString::null;
00067   slideshowLocation = QString::null;
00068   thumbnailLocation = QString::null;
00069   
00070   //no dimension of slideshow image known yet
00071   slideshowWidth = -1;
00072   slideshowHeight = -1;
00073 }

Photo::~Photo  ) 
 

Destructor.

Definition at line 76 of file photo.cpp.

References fullImage, paddedThumbnailImage, slideshowImage, and thumbnailImage.

00077 {
00078   if(paddedThumbnailImage != thumbnailImage)
00079     delete paddedThumbnailImage;
00080   delete thumbnailImage;
00081   delete slideshowImage;
00082   delete fullImage;
00083 } 


Member Function Documentation

int Photo::actualSlideshowHeight  ) 
 

Return actual slideshow image height (not including whitespace).

Definition at line 844 of file photo.cpp.

References slideshowHeight.

Referenced by PhotoEditWidget::adjustExposure(), PhotoViewWidget::cropSelectedPoint(), PhotoEditWidget::findActualSelection(), PhotoViewWidget::getSelection(), PhotoEditWidget::grayscaleSelection(), PhotoEditWidget::invertSelection(), and PhotoViewWidget::selectAll().

00845 {
00846   return slideshowHeight;
00847 }

int Photo::actualSlideshowWidth  ) 
 

Return actual slideshow image width (not including whitespace).

Definition at line 839 of file photo.cpp.

References slideshowWidth.

Referenced by PhotoEditWidget::adjustExposure(), PhotoViewWidget::cropSelectedPoint(), PhotoEditWidget::findActualSelection(), PhotoViewWidget::getSelection(), PhotoEditWidget::grayscaleSelection(), PhotoEditWidget::invertSelection(), and PhotoViewWidget::selectAll().

00840 {
00841   return slideshowWidth;;
00842 }

void Photo::deallocateLargeImages  ) 
 

Frees full image and slideshow versions to conserve memory.

Definition at line 770 of file photo.cpp.

References fullImage, and slideshowImage.

Referenced by Subalbum::addPhoto(), flipHorizontally(), flipVertically(), rotate270(), rotate90(), and setImage().

00771 {
00772   delete fullImage;
00773   fullImage = NULL;
00774   
00775   delete slideshowImage;
00776   slideshowImage = NULL;
00777 }

void Photo::exportSlideshowHTML QTextStream &  stream  ) 
 

Exports to slideshow html format.

Definition at line 378 of file photo.cpp.

00379 {
00380   //write photo information
00381   stream << "?";
00382 }

void Photo::exportThumbnailHTML QTextStream &  stream  ) 
 

Exports to thumbnail html format.

Definition at line 372 of file photo.cpp.

00373 {
00374   //write photo information
00375   stream << "?";
00376 }

void Photo::exportToXML QTextStream &  stream  ) 
 

Exports photo to xml.

Definition at line 314 of file photo.cpp.

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

Referenced by Subalbum::exportToXML().

00315 {
00316   QFileInfo info;
00317   
00318   
00319   //write photo information
00320   stream << "    <photo>\n";
00321   //-----
00322   stream << "      <description>" << fixXMLString(description) << "</description>\n";
00323   //-----
00324   //full image
00325   info.setFile( getImageFilename() );
00326   QDateTime modified = info.lastModified();
00327   stream << "      <image>\n";
00328   stream << "        <md5>" << fixXMLString(imageChecksum) << "</md5>\n";
00329   stream << "        <modified>";
00330   stream << modified.date().year() << " ";
00331   stream << modified.date().month() << " ";
00332   stream << modified.date().day() << " "; 
00333   stream << modified.time().hour() << " ";
00334   stream << modified.time().minute() << " ";
00335   stream << modified.time().second() << " ";
00336   stream << modified.time().msec() << "</modified>\n";
00337   stream << "      </image>\n";
00338   //-----
00339   //slidehow image
00340   info.setFile( getSlideshowFilename() );
00341   modified = info.lastModified();
00342   stream << "      <slideshow>\n";
00343   stream << "        <md5>" << fixXMLString(slideshowChecksum) << "</md5>\n";
00344   stream << "        <modified>";
00345   stream << modified.date().year() << " ";
00346   stream << modified.date().month() << " ";
00347   stream << modified.date().day() << " "; 
00348   stream << modified.time().hour() << " ";
00349   stream << modified.time().minute() << " ";
00350   stream << modified.time().second() << " ";
00351   stream << modified.time().msec() << "</modified>\n";
00352   stream << "      </slideshow>\n";
00353   //-----
00354   //thumbnail image
00355   info.setFile( getThumbnailFilename() );
00356   modified = info.lastModified();
00357   stream << "      <thumb>\n";
00358   stream << "        <md5>" << fixXMLString(thumbnailChecksum) << "</md5>\n";
00359   stream << "        <modified>";
00360   stream << modified.date().year() << " ";
00361   stream << modified.date().month() << " ";
00362   stream << modified.date().day() << " "; 
00363   stream << modified.time().hour() << " ";
00364   stream << modified.time().minute() << " ";
00365   stream << modified.time().second() << " ";
00366   stream << modified.time().msec() << "</modified>\n";
00367   stream << "      </thumb>\n";
00368   //-----
00369   stream << "    </photo>\n";
00370 }

void Photo::flipHorizontally  ) 
 

Flips image about horizontal axis.

Definition at line 670 of file photo.cpp.

References createImages(), deallocateLargeImages(), imageLocation, initialNumber, initialSubalbumNumber, needsSaving, paddedThumbnailImage, Subalbum::setModified(), slideshowHeight, slideshowImage, slideshowLocation, slideshowWidth, subalbum, and thumbnailImage.

00671 {
00672   //load up image
00673   QImage origImage(imageLocation);
00674   QImage newImage = origImage.mirror(false,true);
00675   
00676   //create thumbnail
00677   createImages(&newImage,
00678                      &slideshowImage,
00679                      &thumbnailImage,
00680                      &paddedThumbnailImage,
00681                      slideshowWidth,
00682                      slideshowHeight); 
00683   
00684   //save out updated full and slideshow images to temp folder and deallocate memory
00685   imageLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2.jpg")
00686                                                             .arg(initialSubalbumNumber)
00687                                                             .arg(initialNumber);
00688   slideshowLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2_slideshow.jpg")
00689                                                             .arg(initialSubalbumNumber)
00690                                                             .arg(initialNumber);
00691          
00692   newImage.save( imageLocation, "JPEG", 100);
00693   slideshowImage->save( slideshowLocation, "JPEG", 100); 
00694 
00695  //mark image as having been modified and hence in the tmp folder  
00696  needsSaving = true;  
00697 
00698  //deallocate qimage objects
00699  deallocateLargeImages();
00700   
00701   //set the subalbum as being modified
00702   subalbum->setModified();
00703 }

void Photo::flipVertically  ) 
 

Flips image about vertical axis.

Definition at line 705 of file photo.cpp.

References createImages(), deallocateLargeImages(), imageLocation, initialNumber, initialSubalbumNumber, needsSaving, paddedThumbnailImage, Subalbum::setModified(), slideshowHeight, slideshowImage, slideshowLocation, slideshowWidth, subalbum, and thumbnailImage.

00706 {
00707   //load up image
00708   QImage origImage(imageLocation);
00709   QImage newImage = origImage.mirror(true,false);
00710   
00711   //create thumbnail
00712   createImages(&newImage,
00713                      &slideshowImage,
00714                      &thumbnailImage,
00715                      &paddedThumbnailImage,
00716                      slideshowWidth,
00717                      slideshowHeight); 
00718   
00719   //save out updated full and slideshow images to temp folder and deallocate memory
00720   imageLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2.jpg")
00721                                                             .arg(initialSubalbumNumber)
00722                                                             .arg(initialNumber);
00723   slideshowLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2_slideshow.jpg")
00724                                                             .arg(initialSubalbumNumber)
00725                                                             .arg(initialNumber);
00726          
00727   newImage.save( imageLocation, "JPEG", 100);
00728   slideshowImage->save( slideshowLocation, "JPEG", 100); 
00729 
00730  //mark image as having been modified and hence in the tmp folder  
00731  needsSaving = true;  
00732 
00733  //deallocate qimage objects
00734  deallocateLargeImages();
00735   
00736   //set the subalbum as being modified
00737   subalbum->setModified();
00738 }

QString Photo::getDescription  ) 
 

Gets the description.

Definition at line 246 of file photo.cpp.

References description.

Referenced by PhotoWidget::updateDescription().

00247 {
00248   return QString(description);
00249 }

QImage * Photo::getImage int  size  ) 
 

Gets image.

Definition at line 266 of file photo.cpp.

References fullImage, IMAGE, imageLocation, initialNumber, initialSubalbumNumber, needsSaving, PADDED_THUMBNAIL, paddedThumbnailImage, SLIDESHOW, slideshowImage, slideshowLocation, THUMBNAIL, and thumbnailImage.

Referenced by Subalbum::addPhoto(), Album::exportSubalbumImages(), TitleWidget::setImageAction(), SubalbumWidget::setImageAction(), and PhotoWidget::updateImage().

00267 {
00268   if(size == THUMBNAIL)
00269     return thumbnailImage;
00270   else if(size == PADDED_THUMBNAIL)
00271     return paddedThumbnailImage;
00272   else if(size == SLIDESHOW)
00273   {
00274     if( slideshowImage != NULL)
00275       return slideshowImage;
00276     else
00277     {
00278       if(!needsSaving)
00279       {
00280         return new QImage(slideshowLocation);
00281       }
00282       else
00283       {
00284         QString tmpImageLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2_slideshow.jpg")
00285                                                                 .arg(initialSubalbumNumber)
00286                                                                 .arg(initialNumber);
00287          return new QImage(tmpImageLocation);
00288       }
00289     }
00290   }
00291   else if(size == IMAGE)
00292   {
00293     if( fullImage != NULL)
00294       return fullImage;
00295     else 
00296     {
00297       if(!needsSaving)
00298       {
00299         return new QImage(imageLocation);
00300       }
00301       else
00302       {
00303         QString tmpImageLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2.jpg")
00304                                                                 .arg(initialSubalbumNumber)
00305                                                                 .arg(initialNumber);
00306          return new QImage(tmpImageLocation);
00307       }
00308     }
00309   }
00310   else
00311     return NULL;
00312 }

QString Photo::getImageChecksum  ) 
 

Get image checksum.

Definition at line 765 of file photo.cpp.

References imageChecksum.

Referenced by Subalbum::importFromDisk().

00766 {
00767   return imageChecksum;
00768 }  

QString Photo::getImageFilename  ) 
 

Gets the image filename.

Definition at line 794 of file photo.cpp.

References imageLocation.

Referenced by PhotoEditWidget::adjustExposure(), AlbumStatistics::AlbumStatistics(), PhotoEditWidget::cropToRegion(), Album::exportSubalbumImages(), exportToXML(), PhotoEditWidget::grayscaleSelection(), and PhotoEditWidget::invertSelection().

00795 {
00796   return imageLocation;
00797 }

int Photo::getInitialPhotoNumber  ) 
 

Returns initial photo number.

Definition at line 819 of file photo.cpp.

References initialNumber.

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

00820 {
00821   return initialNumber;
00822 }

int Photo::getInitialSubalbumNumber  ) 
 

Returns intiial subalbum number.

Definition at line 824 of file photo.cpp.

References initialSubalbumNumber.

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

00825 {
00826   return initialSubalbumNumber;
00827 }

bool Photo::getNeedsSavingVal  ) 
 

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

Definition at line 814 of file photo.cpp.

References needsSaving.

Referenced by Album::exportSubalbumImages().

00815 {
00816   return needsSaving;
00817 }

Photo * Photo::getNext  ) 
 

Gets pointer to next photo.

Definition at line 252 of file photo.cpp.

References next.

Referenced by AlbumStatistics::AlbumStatistics(), Album::exportSubalbumImages(), Subalbum::exportToXML(), Subalbum::photoMoved(), SubalbumWidget::refreshPhotos(), Subalbum::removePhoto(), Album::reorderSubalbumImages(), and Subalbum::~Subalbum().

00253 {
00254   return next;
00255 }

QString Photo::getSlideshowChecksum  ) 
 

Get thumbanil checksum.

Definition at line 760 of file photo.cpp.

References slideshowChecksum.

Referenced by Subalbum::importFromDisk().

00761 {
00762   return slideshowChecksum;
00763 }  

QString Photo::getSlideshowFilename  ) 
 

Gets the slideshow filename.

Definition at line 799 of file photo.cpp.

References slideshowLocation.

Referenced by AlbumStatistics::AlbumStatistics(), Album::exportSubalbumImages(), exportToXML(), and PhotoViewWidget::setPhoto().

00800 {
00801   return slideshowLocation;
00802 }

QString Photo::getThumbnailChecksum  ) 
 

Get thumbanil checksum.

Definition at line 755 of file photo.cpp.

References thumbnailChecksum.

Referenced by Subalbum::importFromDisk().

00756 {
00757   return thumbnailChecksum;
00758 }  

QString Photo::getThumbnailFilename  ) 
 

Gets the thumbnail filename.

Definition at line 804 of file photo.cpp.

References thumbnailLocation.

Referenced by exportToXML().

00805 {
00806   return thumbnailLocation;
00807 }

QDateTime * Photo::importFromDisk QDomNode *  root  ) 
 

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

Definition at line 384 of file photo.cpp.

References description, imageChecksum, slideshowChecksum, and thumbnailChecksum.

Referenced by Subalbum::importFromDisk().

00385 {
00386   //create modified date/time object for returning
00387   QDateTime* modified = new QDateTime[3];
00388   
00389   QDomNode node = root->firstChild();
00390   QDomText val;  
00391   while( !node.isNull() )
00392   {
00393     //------------------------------------------------------------
00394     //photo description
00395     if( node.isElement() && node.nodeName() == "description" )
00396     { 
00397       val = node.firstChild().toText();
00398       if(!val.isNull())
00399         description = val.nodeValue();
00400     }
00401     //------------------------------------------------------------
00402     //image information
00403     else if( node.isElement() && node.nodeName() == "image" )
00404     { 
00405       QDomNode childNode = node.firstChild();
00406       while( !childNode.isNull() )
00407       {
00408         //------------------------------------------------------------
00409         if( childNode.isElement() && childNode.nodeName() == "md5" )
00410         {
00411           val = childNode.firstChild().toText();
00412           if(!val.isNull())
00413             imageChecksum = val.nodeValue();
00414         }
00415         //------------------------------------------------------------
00416         else if( childNode.isElement() && childNode.nodeName() == "modified" )
00417         {
00418           val = childNode.firstChild().toText();
00419           
00420           //split value based on spaces, should be 7 fields
00421           QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() );
00422           int i=0;
00423           int intVals[7];
00424           QStringList::Iterator it;
00425           for ( it = vals.begin(); it != vals.end(); ++it ) 
00426           {
00427             //sanity check incase more fields are provided than there should be
00428             if(i >6)
00429               break;
00430             
00431             intVals[i] = QString(*it).toInt();
00432             i++;
00433           }          
00434           modified[0].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
00435           modified[0].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
00436         }
00437         //------------------------------------------------------------
00438         childNode = childNode.nextSibling();
00439       }
00440     }
00441     //------------------------------------------------------------
00442     //slideshow information
00443     else if( node.isElement() && node.nodeName() == "slideshow" )
00444     { 
00445       QDomNode childNode = node.firstChild();
00446       while( !childNode.isNull() )
00447       {
00448         //------------------------------------------------------------
00449         if( childNode.isElement() && childNode.nodeName() == "md5" )
00450         {
00451           val = childNode.firstChild().toText();
00452           if(!val.isNull())
00453             slideshowChecksum = val.nodeValue();
00454         }
00455         //------------------------------------------------------------
00456         else if( childNode.isElement() && childNode.nodeName() == "modified" )
00457         {
00458           val = childNode.firstChild().toText();
00459           
00460           //split value based on spaces, should be 6 fields
00461           QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() );
00462           int i=0;
00463           int intVals[7];
00464           QStringList::Iterator it;
00465           for ( it = vals.begin(); it != vals.end(); ++it ) 
00466           {
00467             //sanity check incase more fields are provided than there should be
00468             if(i >6)
00469               break;
00470             
00471             intVals[i] = QString(*it).toInt();
00472             i++;
00473           }          
00474           modified[1].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
00475           modified[1].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
00476         }
00477         //------------------------------------------------------------
00478         childNode = childNode.nextSibling();
00479       }
00480     }
00481     //------------------------------------------------------------
00482     //slideshow information
00483     else if( node.isElement() && node.nodeName() == "thumb" )
00484     { 
00485       QDomNode childNode = node.firstChild();
00486       while( !childNode.isNull() )
00487       {
00488         //------------------------------------------------------------
00489         if( childNode.isElement() && childNode.nodeName() == "md5" )
00490         {
00491           val = childNode.firstChild().toText();
00492           if(!val.isNull())
00493             thumbnailChecksum = val.nodeValue();
00494         }
00495         //------------------------------------------------------------
00496         else if( childNode.isElement() && childNode.nodeName() == "modified" )
00497         {
00498           val = childNode.firstChild().toText();
00499           
00500           //split value based on spaces, should be 6 fields
00501           QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() );
00502           int i=0;
00503           int intVals[7];
00504           QStringList::Iterator it;
00505           for ( it = vals.begin(); it != vals.end(); ++it ) 
00506           {
00507             //sanity check incase more fields are provided than there should be
00508             if(i >6)
00509               break;
00510             
00511             intVals[i] = QString(*it).toInt();
00512             i++;
00513           }          
00514           modified[2].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
00515           modified[2].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
00516         }
00517         //------------------------------------------------------------
00518         childNode = childNode.nextSibling();
00519       }
00520     }
00521     //------------------------------------------------------------
00522     //------------------------------------------------------------
00523     //Handle md5 info as specified in 1.0a and 1.0a2 xml format
00524     //image md5
00525     else if( node.isElement() && node.nodeName() == "imageMD5" )
00526     { 
00527       val = node.firstChild().toText();
00528       if(!val.isNull())
00529         imageChecksum = val.nodeValue();
00530     }
00531     //------------------------------------------------------------
00532     //slideshow md5
00533     else if( node.isElement() && node.nodeName() == "slideMD5" )
00534     { 
00535       val = node.firstChild().toText();
00536       if(!val.isNull())
00537         slideshowChecksum = val.nodeValue();
00538     }
00539     //------------------------------------------------------------
00540     //thumbnail md5
00541     else if( node.isElement() && node.nodeName() == "thumbMD5" )
00542     { 
00543       val = node.firstChild().toText();
00544       if(!val.isNull())
00545         thumbnailChecksum = val.nodeValue();
00546     }
00547     //------------------------------------------------------------
00548     //------------------------------------------------------------
00549     
00550     
00551     //advance to next node   
00552     node = node.nextSibling();
00553     //------------------------------------------------------------
00554   }
00555   
00556   //return modification dates read in
00557   return modified;
00558 }

void Photo::rotate270  ) 
 

Rotates image clockwise by 270 degrees.

Definition at line 615 of file photo.cpp.

References createImages(), deallocateLargeImages(), fullImage, imageLocation, initialNumber, initialSubalbumNumber, needsSaving, paddedThumbnailImage, Subalbum::setModified(), slideshowHeight, slideshowImage, slideshowLocation, slideshowWidth, subalbum, and thumbnailImage.

00616 {
00617   //load up image
00618   //if not modified load from permanent location
00619   fullImage = new QImage(imageLocation);
00620   
00621   //create new image
00622   QImage* rotatedImage = new QImage(fullImage->height(),
00623                                     fullImage->width(),
00624                                     fullImage->depth());
00625   rotatedImage->setAlphaBuffer(true);
00626   //copy data                                    
00627   int x,y;
00628   for(x=0; x < fullImage->height(); x++)
00629   {
00630     for(y=0; y < fullImage->width(); y++)
00631     {
00632       rotatedImage->setPixel(x, fullImage->width() - 1 - y, fullImage->pixel(y, x) );
00633     }
00634   }                                    
00635 
00636   //delete old image and set new pointer
00637   delete fullImage;
00638   fullImage = rotatedImage;
00639   
00640   //create thumbnail
00641   createImages(fullImage,
00642                      &slideshowImage,
00643                      &thumbnailImage,
00644                      &paddedThumbnailImage,
00645                      slideshowWidth,
00646                      slideshowHeight); 
00647   
00648   //save out updated full and slideshow images to temp folder and deallocate memory
00649   imageLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2.jpg")
00650                                                             .arg(initialSubalbumNumber)
00651                                                             .arg(initialNumber);
00652   slideshowLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2_slideshow.jpg")
00653                                                             .arg(initialSubalbumNumber)
00654                                                             .arg(initialNumber);
00655          
00656   fullImage->save( imageLocation, "JPEG", 100);
00657   slideshowImage->save( slideshowLocation, "JPEG", 100);
00658  
00659 
00660  //mark image as having been modified and hence in the tmp folder  
00661  needsSaving = true;  
00662 
00663  //deallocate qimage objects
00664  deallocateLargeImages();
00665     
00666   //set the subalbum as being modified
00667   subalbum->setModified();
00668 }

void Photo::rotate90  ) 
 

Rotates image clockwise by 90 degrees.

Definition at line 560 of file photo.cpp.

References createImages(), deallocateLargeImages(), fullImage, imageLocation, initialNumber, initialSubalbumNumber, needsSaving, paddedThumbnailImage, Subalbum::setModified(), slideshowHeight, slideshowImage, slideshowLocation, slideshowWidth, subalbum, and thumbnailImage.

00561 {
00562   //load up image
00563   //if not modified load from permanent location
00564   fullImage = new QImage(imageLocation);
00565   
00566   //create new image
00567   QImage* rotatedImage = new QImage(fullImage->height(),
00568                                     fullImage->width(),
00569                                     fullImage->depth());
00570   rotatedImage->setAlphaBuffer(true);
00571   
00572   //copy data                                      
00573   int x,y;
00574   for(x=0; x < fullImage->height(); x++)
00575   {
00576     for(y=0; y < fullImage->width(); y++)
00577     {
00578       rotatedImage->setPixel(fullImage->height() - 1 - x, y, fullImage->pixel(y, x) );
00579     }
00580   }                                    
00581   
00582   //delete old image and set new pointer
00583   delete fullImage;
00584   fullImage = rotatedImage;
00585     
00586   //create thumbnail
00587   createImages(fullImage,
00588                      &slideshowImage,
00589                      &thumbnailImage,
00590                      &paddedThumbnailImage,
00591                      slideshowWidth,
00592                      slideshowHeight); 
00593     
00594   //save out updated full and slideshow images to temp folder and deallocate memory
00595   imageLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2.jpg")
00596                                                             .arg(initialSubalbumNumber)
00597                                                             .arg(initialNumber);
00598   slideshowLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2_slideshow.jpg")
00599                                                             .arg(initialSubalbumNumber)
00600                                                             .arg(initialNumber);
00601          
00602   fullImage->save( imageLocation, "JPEG", 100);
00603   slideshowImage->save( slideshowLocation, "JPEG", 100);
00604  
00605   //mark image as having been modified and hence in the tmp folder  
00606   needsSaving = true;  
00607 
00608   //deallocate qimage objects
00609   deallocateLargeImages();
00610     
00611   //set the subalbum as being modified
00612   subalbum->setModified();
00613 }

void Photo::setActualSlideshowDimensions int  w,
int  h
 

Sets actual slideshow image size.

Definition at line 849 of file photo.cpp.

References slideshowHeight, and slideshowWidth.

00850 {
00851   slideshowWidth = w;
00852   slideshowHeight = h;
00853 }

void Photo::setDescription QString  val  ) 
 

Sets the description.

Definition at line 236 of file photo.cpp.

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

Referenced by Subalbum::addPhoto(), PhotoWidget::sync(), and PhotoEditWidget::updateDescription().

00237 {
00238   if(description != val)
00239   {
00240     description = val;
00241     subalbum->setModified();
00242   }
00243 }

bool Photo::setImage QImage *  fullImage  ) 
 

Sets the image.

this method used when modifications have been preformed like cropping, etc. Recreates slideshow and thumnail forms, marks photo for saving

Definition at line 195 of file photo.cpp.

References createImages(), deallocateLargeImages(), fullImage, imageLocation, initialNumber, initialSubalbumNumber, needsSaving, paddedThumbnailImage, Subalbum::setModified(), slideshowHeight, slideshowImage, slideshowLocation, slideshowWidth, subalbum, thumbnailImage, and thumbnailLocation.

00196 {
00197   //reset image object
00198   delete fullImage;
00199   fullImage = newFullImage;
00200   if(fullImage->isNull()) return false;
00201 
00202   //create slideshow and thumbnail formats
00203   createImages(fullImage,
00204                &slideshowImage,
00205                &thumbnailImage,
00206                &paddedThumbnailImage,
00207                slideshowWidth,
00208                slideshowHeight); 
00209 
00210   //save out updated full and slideshow images to temp folder and deallocate memory
00211   imageLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2.jpg")
00212                                                             .arg(initialSubalbumNumber)
00213                                                             .arg(initialNumber);
00214   slideshowLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2_slideshow.jpg")
00215                                                             .arg(initialSubalbumNumber)
00216                                                             .arg(initialNumber);
00217   thumbnailLocation = QDir::homeDirPath() + QString("/.albumShaper/tmp/%1_%2_thumb.jpg")
00218                                                             .arg(initialSubalbumNumber)
00219                                                             .arg(initialNumber);
00220          
00221   fullImage->save( imageLocation, "JPEG", 100);
00222   slideshowImage->save( slideshowLocation, "JPEG", 100);
00223  
00224   //mark image as having been modified and hence in the tmp folder  
00225   needsSaving = true;  
00226 
00227   //set the subalbum as being modified
00228   subalbum->setModified();
00229   
00230   //deallocate qimage objects
00231   deallocateLargeImages();
00232   
00233   return true;
00234 }

bool Photo::setImage const QString &  imageName,
const QString &  slideshowName,
const QString &  thumbnailName
 

Sets the image, uses loads thumbnail and slideshow from file (no scaling), returns TRUE if successful.

THis method used when loading from xml and no scaling should need to be done, we hope

Definition at line 123 of file photo.cpp.

References fullImage, imageLocation, needsSaving, paddedThumbnailImage, Subalbum::setModified(), slideshowImage, slideshowLocation, subalbum, THUMBNAIL_HEIGHT, THUMBNAIL_WIDTH, thumbnailImage, and thumbnailLocation.

00126 {
00127   //---------------------------------------------------------    
00128    //free old images
00129   delete fullImage;
00130   if(paddedThumbnailImage != thumbnailImage)
00131     delete paddedThumbnailImage;
00132   delete thumbnailImage;
00133   delete slideshowImage;
00134   
00135   fullImage = NULL;
00136   paddedThumbnailImage = NULL;
00137   thumbnailImage = NULL;
00138   slideshowImage = NULL;
00139   //---------------------------------------------------------    
00140   //construct thumbnail image
00141   thumbnailImage = new QImage(thumbnailName);
00142   if(thumbnailImage->isNull()) return false;
00143   //---------------------------------------------------------    
00144   //construct padded thumbnail image
00145   //if scaled thumbnail image is same size as padded thumbnail should be reuse object
00146   if(thumbnailImage->width() == THUMBNAIL_WIDTH &&
00147      thumbnailImage->height() == THUMBNAIL_HEIGHT)
00148   {  
00149     paddedThumbnailImage = thumbnailImage;  
00150   }
00151   //else pad thumbnail
00152   else
00153   {
00154     //created padded thumbnail image
00155     paddedThumbnailImage = new QImage(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, thumbnailImage->depth());
00156     paddedThumbnailImage->setAlphaBuffer(true);
00157   
00158     //copy scaled image into centered portion of padded image
00159     int xDiff = THUMBNAIL_WIDTH - thumbnailImage->width();
00160     int yDiff = THUMBNAIL_HEIGHT - thumbnailImage->height();
00161 
00162     //set all pixels to white
00163     paddedThumbnailImage->fill(Qt::white.rgb());
00164   
00165     int x,y;
00166     int x2 = 0;
00167     int y2;
00168     for(x = xDiff/2; x< (xDiff/2) + thumbnailImage->width(); x++)
00169     {
00170       y2 = 0;
00171       for(y = yDiff/2; y < (yDiff/2) + thumbnailImage->height(); y++)
00172       {
00173         paddedThumbnailImage->setPixel(x, y, thumbnailImage->pixel(x2, y2));
00174         y2++;
00175       }
00176       x2++;  
00177     }
00178   }  
00179   //---------------------------------------------------------    
00180   //save new image filenames
00181   imageLocation = imageName;  
00182   slideshowLocation = slideshowName;
00183   thumbnailLocation = thumbnailName;
00184   //---------------------------------------------------------    
00185   //image loaded from file, no need to save it again just yet
00186   needsSaving = false;    
00187   
00188   //set the subalbum as being modified
00189   subalbum->setModified();
00190   
00191   return true;
00192   //---------------------------------------------------------    
00193 }

bool Photo::setImage const QString &  imageName  ) 
 

Sets image, returns TRUE if successful, this method used when loading and image from file for the first time (aka when photo added to subalbum).

Definition at line 85 of file photo.cpp.

References createImages(), fullImage, imageLocation, needsSaving, paddedThumbnailImage, Subalbum::setModified(), slideshowHeight, slideshowImage, slideshowWidth, subalbum, and thumbnailImage.

Referenced by Subalbum::addPhoto(), PhotoEditWidget::applyImageUpdate(), Subalbum::lazyAddPhoto(), and PhotoEditWidget::resetImageAction().

00086 {
00087   //reset image object
00088   delete fullImage;
00089   
00090   //load up image, converting it's depth...
00091   QImage tempImage = QImage(filename).convertDepth(32);
00092   fullImage = new QImage(tempImage.width(), tempImage.height(), 32);
00093   if(fullImage->isNull()) return false;
00094   int x, y;
00095   for(x = 0; x<tempImage.width(); x++)
00096   {
00097     for(y = 0; y<tempImage.height(); y++)
00098     {
00099       fullImage->setPixel(x, y, tempImage.pixel(x,y) );
00100     }
00101   }
00102     
00103   //create slideshow and thumbnail formats
00104   createImages(fullImage,
00105                      &slideshowImage,
00106                      &thumbnailImage,
00107                      &paddedThumbnailImage,
00108                      slideshowWidth,
00109                      slideshowHeight);   
00110   
00111   //store image and slideshow filenames
00112   imageLocation = filename;  
00113 
00114   //image is being stored in temp location, needs saving!
00115   needsSaving = true;
00116   
00117   //set the subalbum as being modified
00118   subalbum->setModified();
00119   
00120   return true;
00121 }

void Photo::setImageChecksum QString  val  ) 
 

Update image checksum.

Definition at line 750 of file photo.cpp.

References imageChecksum.

Referenced by Album::exportSubalbumImages().

00751 {
00752   imageChecksum = val;
00753 }  

void Photo::setImageFilename QString  val  ) 
 

Sets the image filename.

Definition at line 779 of file photo.cpp.

References imageLocation.

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

00780 {
00781   imageLocation = val;
00782 }

void Photo::setInitialPhotoNumber int  val  ) 
 

Sets initial photo number.

Definition at line 829 of file photo.cpp.

References initialNumber.

Referenced by Album::reorderSubalbumImages().

00830 {
00831  initialNumber = val; 
00832 }

void Photo::setInitialSubalbumNumber int  val  ) 
 

Sets initial subalbum number.

Definition at line 834 of file photo.cpp.

References initialSubalbumNumber.

Referenced by Album::reorderSubalbumImages().

00835 {
00836  initialSubalbumNumber = val; 
00837 }

void Photo::setNeedsSavingVal bool  val  ) 
 

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

Definition at line 809 of file photo.cpp.

References needsSaving.

Referenced by Album::exportSubalbumImages().

00810 {
00811   needsSaving = val;
00812 }

void Photo::setNext Photo val  ) 
 

Sets pointer to next photo.

Definition at line 258 of file photo.cpp.

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

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

00259 {
00260   next = val;
00261   
00262   //set the subalbum as being modified
00263   subalbum->setModified();
00264 }

void Photo::setSlideshowChecksum QString  val  ) 
 

Update slideshow checksum.

Definition at line 745 of file photo.cpp.

References slideshowChecksum.

Referenced by Album::exportSubalbumImages().

00746 {
00747   slideshowChecksum = val;
00748 }  

void Photo::setSlideshowFilename QString  val  ) 
 

Sets the slideshow filename.

Definition at line 784 of file photo.cpp.

References slideshowLocation.

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

00785 {
00786   slideshowLocation = val;
00787 }

void Photo::setThumbnailChecksum QString  val  ) 
 

Update thumbnail checksum.

Definition at line 740 of file photo.cpp.

References thumbnailChecksum.

Referenced by Album::exportSubalbumImages().

00741 {
00742   thumbnailChecksum = val;
00743 }  

void Photo::setThumbnailFilename QString  val  ) 
 

Sets the thumbnail filename.

Definition at line 789 of file photo.cpp.

References thumbnailLocation.

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

00790 {
00791   thumbnailLocation = val;
00792 }


Member Data Documentation

QString Photo::description [private]
 

Longer description of subalbum.

Definition at line 186 of file photo.h.

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

QImage* Photo::fullImage [private]
 

Actual image.

Definition at line 198 of file photo.h.

Referenced by deallocateLargeImages(), getImage(), Photo(), rotate270(), rotate90(), setImage(), and ~Photo().

QString Photo::imageChecksum [private]
 

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

Definition at line 201 of file photo.h.

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

QString Photo::imageLocation [private]
 

Image filename.

Definition at line 206 of file photo.h.

Referenced by flipHorizontally(), flipVertically(), getImage(), getImageFilename(), Photo(), rotate270(), rotate90(), setImage(), and setImageFilename().

int Photo::initialNumber [private]
 

Definition at line 177 of file photo.h.

Referenced by flipHorizontally(), flipVertically(), getImage(), getInitialPhotoNumber(), Photo(), rotate270(), rotate90(), setImage(), and setInitialPhotoNumber().

int Photo::initialSubalbumNumber [private]
 

Definition at line 180 of file photo.h.

Referenced by flipHorizontally(), flipVertically(), getImage(), getInitialSubalbumNumber(), Photo(), rotate270(), rotate90(), setImage(), and setInitialSubalbumNumber().

bool Photo::needsSaving [private]
 

Does the image need to be saved to the permanent location?

Definition at line 215 of file photo.h.

Referenced by flipHorizontally(), flipVertically(), getImage(), getNeedsSavingVal(), Photo(), rotate270(), rotate90(), setImage(), and setNeedsSavingVal().

Photo* Photo::next [private]
 

Pointer to next photo.

Definition at line 183 of file photo.h.

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

QImage* Photo::paddedThumbnailImage [private]
 

A padded thumbnail used for subalbum layout.

Definition at line 192 of file photo.h.

Referenced by flipHorizontally(), flipVertically(), getImage(), Photo(), rotate270(), rotate90(), setImage(), and ~Photo().

QString Photo::slideshowChecksum [private]
 

Definition at line 202 of file photo.h.

Referenced by exportToXML(), getSlideshowChecksum(), importFromDisk(), Photo(), and setSlideshowChecksum().

int Photo::slideshowHeight [private]
 

Unpadded height of slideshow image.

Definition at line 221 of file photo.h.

Referenced by actualSlideshowHeight(), flipHorizontally(), flipVertically(), Photo(), rotate270(), rotate90(), setActualSlideshowDimensions(), and setImage().

QImage* Photo::slideshowImage [private]
 

Slideshow iamge.

Definition at line 195 of file photo.h.

Referenced by deallocateLargeImages(), flipHorizontally(), flipVertically(), getImage(), Photo(), rotate270(), rotate90(), setImage(), and ~Photo().

QString Photo::slideshowLocation [private]
 

Slideshow filename.

Definition at line 209 of file photo.h.

Referenced by flipHorizontally(), flipVertically(), getImage(), getSlideshowFilename(), Photo(), rotate270(), rotate90(), setImage(), and setSlideshowFilename().

int Photo::slideshowWidth [private]
 

Unpadded width of slideshow image.

Definition at line 218 of file photo.h.

Referenced by actualSlideshowWidth(), flipHorizontally(), flipVertically(), Photo(), rotate270(), rotate90(), setActualSlideshowDimensions(), and setImage().

Subalbum* Photo::subalbum [private]
 

Subalbum photo is in.

Definition at line 174 of file photo.h.

Referenced by flipHorizontally(), flipVertically(), rotate270(), rotate90(), setDescription(), setImage(), and setNext().

QString Photo::thumbnailChecksum [private]
 

Definition at line 203 of file photo.h.

Referenced by exportToXML(), getThumbnailChecksum(), importFromDisk(), Photo(), and setThumbnailChecksum().

QImage* Photo::thumbnailImage [private]
 

Thumbnail used for saving to disk.

Definition at line 189 of file photo.h.

Referenced by flipHorizontally(), flipVertically(), getImage(), Photo(), rotate270(), rotate90(), setImage(), and ~Photo().

QString Photo::thumbnailLocation [private]
 

Thumbnail filename.

Definition at line 212 of file photo.h.

Referenced by getThumbnailFilename(), Photo(), setImage(), and setThumbnailFilename().


The documentation for this class was generated from the following files:
Generated on Thu Nov 13 00:11:11 2003 for AlbumShaper by doxygen 1.3.4