Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 4f45e7bdfd4a5ff17f5f8eaab90d017f > files > 1429

albumshaper-2.1-6mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>AlbumShaper: photo.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>photo.cpp</h1><a href="photo_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==============================================</span>
<a name="l00002"></a>00002 <span class="comment">//  copyright            : (C) 2003-2005 by Will Stokes</span>
<a name="l00003"></a>00003 <span class="comment">//==============================================</span>
<a name="l00004"></a>00004 <span class="comment">//  This program is free software; you can redistribute it</span>
<a name="l00005"></a>00005 <span class="comment">//  and/or modify it under the terms of the GNU General</span>
<a name="l00006"></a>00006 <span class="comment">//  Public License as published by the Free Software</span>
<a name="l00007"></a>00007 <span class="comment">//  Foundation; either version 2 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">//  (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//==============================================</span>
<a name="l00010"></a>00010 <span class="comment">//Systemwide includes</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;qpixmap.h&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;qimage.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;qstring.h&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;qtextstream.h&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;qdom.h&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;qdir.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;qfileinfo.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;qregexp.h&gt;</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="comment">//Projectwide includes</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="photo_8h.html">photo.h</a>"</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="subalbum_8h.html">subalbum.h</a>"</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="album_8h.html">album.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="fileTools_8h.html">tools/fileTools.h</a>"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="imageTools_8h.html">tools/imageTools.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="xmlTools_8h.html">tools/xmlTools.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="md5_8h.html">tools/md5.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "../config.h"</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="comment">//==============================================</span>
<a name="l00031"></a><a class="code" href="classPhoto.html#33eea102dcc5f39222ea11618f9b93c1">00031</a> <a class="code" href="classPhoto.html#33eea102dcc5f39222ea11618f9b93c1" title="Sets default information.">Photo::Photo</a>(<a class="code" href="classSubalbum.html" title="A subalbum contains photos.">Subalbum</a>* subalbum, <a class="code" href="classPhoto.html" title="A photo consists of a full size image, a smaller slide show image, a very small thumbnail...">Photo</a>* prev, <span class="keywordtype">int</span> photoNumber)
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033   <span class="comment">//set subalbum pointer</span>
<a name="l00034"></a>00034   this-&gt;subalbum = subalbum;
<a name="l00035"></a>00035 
<a name="l00036"></a>00036   <span class="comment">//set prev pointer</span>
<a name="l00037"></a>00037   this-&gt;prev = prev;
<a name="l00038"></a>00038   
<a name="l00039"></a>00039   <span class="comment">//set next pointer to NULL, new photos are always</span>
<a name="l00040"></a>00040   <span class="comment">//inserted at the end of collections</span>
<a name="l00041"></a>00041   <a class="code" href="classPhoto.html#8fd5de011a756f9974e9cd1f458e2678" title="Pointer to next photo.">next</a> = NULL;
<a name="l00042"></a>00042   
<a name="l00043"></a>00043   <span class="comment">//set initial photo and subalbum numbers</span>
<a name="l00044"></a>00044   <a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a> = photoNumber;
<a name="l00045"></a>00045   <a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a> = subalbum-&gt;<a class="code" href="classSubalbum.html#421e48eea5937cd4718a34410bdc29cb" title="Returns subalbum number.">getSubalbumNumber</a>();
<a name="l00046"></a>00046 
<a name="l00047"></a>00047   <span class="comment">//set default to the empty string</span>
<a name="l00048"></a>00048   <a class="code" href="classPhoto.html#6fe05dc549b7caf2ee3232476d41e760" title="Photo description.">description</a> = QString::null;
<a name="l00049"></a>00049 
<a name="l00050"></a>00050   <span class="comment">//set thumbnail image</span>
<a name="l00051"></a>00051   <a class="code" href="classPhoto.html#dee2a5bb92cbc903f3574d952c622867" title="Thumbnail Image.">thumbnailImage</a> = NULL;
<a name="l00052"></a>00052 
<a name="l00053"></a>00053   <span class="comment">//set filenames and checksums to null until the actual photo data has been set</span>
<a name="l00054"></a>00054   <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>     = QString::null;
<a name="l00055"></a>00055   <a class="code" href="classPhoto.html#a3f68b264dc2e072e651331b9de6aed0" title="MD5 checksums, used to determine if image/thumbnail have been changed.">imageChecksum</a>     = QString::null;
<a name="l00056"></a>00056   
<a name="l00057"></a>00057   <a class="code" href="classPhoto.html#cfe4c2b45cf6b5b5a24cbbc85ea609ed">slideshowLocation</a> = QString::null;
<a name="l00058"></a>00058   <a class="code" href="classPhoto.html#8cb3aa1eaaf8f0f14d626b475b21f465">slideshowChecksum</a> = QString::null;
<a name="l00059"></a>00059   
<a name="l00060"></a>00060   <a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a> = QString::null;
<a name="l00061"></a>00061   <a class="code" href="classPhoto.html#4c418b827ae16ec1e96a6f1d0f1c84dd">thumbnailChecksum</a> = QString::null;
<a name="l00062"></a>00062 
<a name="l00063"></a>00063   <span class="comment">//a default photo is not interesting. once the </span>
<a name="l00064"></a>00064   <span class="comment">//actual photo data or description files have</span>
<a name="l00065"></a>00065   <span class="comment">//been reset the photo will need to be saved.</span>
<a name="l00066"></a>00066   <a class="code" href="classPhoto.html#c53f4bdf11a948daef3c1a300668d331" title="Unsaved modifications?">needsSaving</a> = <span class="keyword">false</span>;
<a name="l00067"></a>00067   
<a name="l00068"></a>00068   <span class="comment">//by default a photos are assumed to be saved. </span>
<a name="l00069"></a>00069   <span class="comment">//new photos are setup with a uniqueID and we'll set this bool false there</span>
<a name="l00070"></a>00070   <a class="code" href="classPhoto.html#441a3e1ea66da5e86fa02ecf7d41c09d" title="Has the photo ever been saved?">everSaved</a> = <span class="keyword">true</span>;
<a name="l00071"></a>00071   
<a name="l00072"></a>00072   <span class="comment">//photo not recently reverted</span>
<a name="l00073"></a>00073   <a class="code" href="classPhoto.html#b0cffd8b36cb5a5b18d4543dfe69046b" title="Has the photo recently been reverted to it&amp;#39;s original form? If so during the...">recentlyReverted</a> = <span class="keyword">false</span>;
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 <span class="comment">//==============================================</span>
<a name="l00076"></a><a class="code" href="classPhoto.html#dc366234be6226600360c7cbba8e7fcf">00076</a> <a class="code" href="classPhoto.html#dc366234be6226600360c7cbba8e7fcf">Photo::~Photo</a>()
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078   <span class="comment">//free the thumbnail image</span>
<a name="l00079"></a>00079   <span class="keyword">delete</span> <a class="code" href="classPhoto.html#dee2a5bb92cbc903f3574d952c622867" title="Thumbnail Image.">thumbnailImage</a>;
<a name="l00080"></a>00080 }
<a name="l00081"></a>00081 <span class="comment">//==============================================</span>
<a name="l00082"></a><a class="code" href="classPhoto.html#96dcf5c6210ca39c534ae2287be1df90">00082</a> QImage* <a class="code" href="classPhoto.html#96dcf5c6210ca39c534ae2287be1df90" title="Gets thumbnail image.">Photo::getThumbnailImage</a>() { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#dee2a5bb92cbc903f3574d952c622867" title="Thumbnail Image.">thumbnailImage</a>; }
<a name="l00083"></a>00083 <span class="comment">//==============================================</span>
<a name="l00084"></a><a class="code" href="classPhoto.html#f4d602874536f89799f828abd2a34848">00084</a> <span class="keywordtype">bool</span> <a class="code" href="classPhoto.html#f4d602874536f89799f828abd2a34848" title="Construct thumbnail and slideshow images, load up thumbnail image, and set photo...">Photo::constructSmallerImages</a>()
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086   <span class="comment">//construct and save slideshow and thumbnail images</span>
<a name="l00087"></a>00087   QImage TslideshowImage, TthumbnailImage;
<a name="l00088"></a>00088   <a class="code" href="imageTools_8cpp.html#136ce4737ac4d5dfa526d752ab8aab33" title="Constructs slideshow and thumbnail images for a full sized image.">constructImages</a>( <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>, TslideshowImage, TthumbnailImage );  
<a name="l00089"></a>00089   TslideshowImage.save( <a class="code" href="classPhoto.html#cfe4c2b45cf6b5b5a24cbbc85ea609ed">slideshowLocation</a>, <span class="stringliteral">"JPEG"</span>, 95 );
<a name="l00090"></a>00090   TthumbnailImage.save( <a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a>, <span class="stringliteral">"JPEG"</span>, 95 );
<a name="l00091"></a>00091 
<a name="l00092"></a>00092   <span class="comment">//load up thumbnail image</span>
<a name="l00093"></a>00093   <span class="keyword">delete</span> <a class="code" href="classPhoto.html#dee2a5bb92cbc903f3574d952c622867" title="Thumbnail Image.">thumbnailImage</a>;
<a name="l00094"></a>00094   <a class="code" href="classPhoto.html#dee2a5bb92cbc903f3574d952c622867" title="Thumbnail Image.">thumbnailImage</a> = <span class="keyword">new</span> QImage(<a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a>);
<a name="l00095"></a>00095 
<a name="l00096"></a>00096   <span class="comment">//image is being stored in temp location, needs saving!</span>
<a name="l00097"></a>00097   <a class="code" href="classPhoto.html#c53f4bdf11a948daef3c1a300668d331" title="Unsaved modifications?">needsSaving</a> = <span class="keyword">true</span>;
<a name="l00098"></a>00098 
<a name="l00099"></a>00099   <span class="comment">//set the subalbum as being modified and return</span>
<a name="l00100"></a>00100   <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#a01ad19461ce049774595512960f73cb">setModified</a>();
<a name="l00101"></a>00101   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00102"></a>00102 }
<a name="l00103"></a>00103 <span class="comment">//==============================================</span>
<a name="l00104"></a><a class="code" href="classPhoto.html#29e2aae62991d904c3cb763ec838d9bd">00104</a> <span class="keywordtype">bool</span> <a class="code" href="classPhoto.html#29e2aae62991d904c3cb763ec838d9bd" title="Setup photo using preexisting full size, slideshow, and thumbnail images.">Photo::setImage</a>(QString imageName,
<a name="l00105"></a>00105                      QString slideshowName,
<a name="l00106"></a>00106                      QString thumbnailName)
<a name="l00107"></a>00107 {  
<a name="l00108"></a>00108   <span class="comment">//set filenames, we'll lazily compute MD5 checksums for files when saving</span>
<a name="l00109"></a>00109   <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>     = imageName;
<a name="l00110"></a>00110   <a class="code" href="classPhoto.html#cfe4c2b45cf6b5b5a24cbbc85ea609ed">slideshowLocation</a> = slideshowName;
<a name="l00111"></a>00111   <a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a> = thumbnailName;
<a name="l00112"></a>00112   
<a name="l00113"></a>00113   <span class="comment">//load thumbnail image</span>
<a name="l00114"></a>00114   <span class="keyword">delete</span> <a class="code" href="classPhoto.html#dee2a5bb92cbc903f3574d952c622867" title="Thumbnail Image.">thumbnailImage</a>;
<a name="l00115"></a>00115   <a class="code" href="classPhoto.html#dee2a5bb92cbc903f3574d952c622867" title="Thumbnail Image.">thumbnailImage</a> = <span class="keyword">new</span> QImage(thumbnailName);
<a name="l00116"></a>00116   <span class="keywordflow">if</span>(<a class="code" href="classPhoto.html#dee2a5bb92cbc903f3574d952c622867" title="Thumbnail Image.">thumbnailImage</a>-&gt;isNull()) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00117"></a>00117   
<a name="l00118"></a>00118   <span class="comment">//image just loaded, no changes yet</span>
<a name="l00119"></a>00119   <a class="code" href="classPhoto.html#c53f4bdf11a948daef3c1a300668d331" title="Unsaved modifications?">needsSaving</a> = <span class="keyword">false</span>;
<a name="l00120"></a>00120   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00121"></a>00121 }
<a name="l00122"></a>00122 <span class="comment">//==============================================</span>
<a name="l00123"></a><a class="code" href="classPhoto.html#49be0b8f7e4b4cc83395ce13e4462632">00123</a> <span class="keywordtype">bool</span> <a class="code" href="classPhoto.html#29e2aae62991d904c3cb763ec838d9bd" title="Setup photo using preexisting full size, slideshow, and thumbnail images.">Photo::setImage</a>(QString imageName, <span class="keywordtype">int</span> uniqueID)
<a name="l00124"></a>00124 { 
<a name="l00125"></a>00125   <span class="comment">//this is a new photo, use a unique ID to construct temporary filenames</span>
<a name="l00126"></a>00126   <a class="code" href="classPhoto.html#60408934b0cb03ad0ad359ab1b5393a3" title="sets everSaved">setEverSaved</a>(<span class="keyword">false</span>);
<a name="l00127"></a>00127   <a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a> = 0;
<a name="l00128"></a>00128   <a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a> = uniqueID;
<a name="l00129"></a>00129 
<a name="l00130"></a>00130   QString tmpDir = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#a7000c4e580d93ccb7a3fdbc84e49952" title="Returns the temporary directory for use when modifying and adding new images.">getTmpDir</a>();
<a name="l00131"></a>00131   <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>     = QString(<span class="stringliteral">"%1/%2_%3.jpg"</span>)          .arg(tmpDir).arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>).arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00132"></a>00132   <a class="code" href="classPhoto.html#cfe4c2b45cf6b5b5a24cbbc85ea609ed">slideshowLocation</a> = QString(<span class="stringliteral">"%1/%2_%3_slideshow.jpg"</span>).arg(tmpDir).arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>).arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00133"></a>00133   <a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a> = QString(<span class="stringliteral">"%1/%2_%3_thumb.jpg"</span>)    .arg(tmpDir).arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>).arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00134"></a>00134   
<a name="l00135"></a>00135   <span class="comment">//if image in jpeg format simply copy file over</span>
<a name="l00136"></a>00136   <span class="keywordflow">if</span>( <a class="code" href="imageTools_8cpp.html#f483fb1d0e6d890227ff2fecd321aad2" title="Checks to see if an image is a valid jpg by seeing if the image dimensions can be...">isJpeg</a>(imageName) )
<a name="l00137"></a>00137   {
<a name="l00138"></a>00138     <a class="code" href="fileTools_8cpp.html#f41848ecf008f6b6579f5b0975faea5a" title="Copies a file from one location to another.">copyFile</a>( imageName, <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a> );
<a name="l00139"></a>00139   }
<a name="l00140"></a>00140   <span class="comment">//otherwise we must load it up and save it out as jpeg</span>
<a name="l00141"></a>00141   <span class="keywordflow">else</span>
<a name="l00142"></a>00142   {
<a name="l00143"></a>00143     <span class="comment">//if unable to open image at all using Qt then giveup</span>
<a name="l00144"></a>00144     QImage tempImage(imageName);
<a name="l00145"></a>00145     <span class="keywordflow">if</span>( tempImage.isNull() ) { <span class="keywordflow">return</span> <span class="keyword">false</span>; }
<a name="l00146"></a>00146     
<a name="l00147"></a>00147     <span class="comment">//save out as jpeg</span>
<a name="l00148"></a>00148     tempImage.save( <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>, <span class="stringliteral">"JPEG"</span>, 95 );
<a name="l00149"></a>00149   }  
<a name="l00150"></a>00150   
<a name="l00151"></a>00151   <span class="comment">//construct smaller iamges</span>
<a name="l00152"></a>00152   <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#f4d602874536f89799f828abd2a34848" title="Construct thumbnail and slideshow images, load up thumbnail image, and set photo...">constructSmallerImages</a>();
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154 <span class="comment">//==============================================</span>
<a name="l00155"></a><a class="code" href="classPhoto.html#da55883a113f7a5b9021ccb2a48466ed">00155</a> <span class="keywordtype">bool</span> <a class="code" href="classPhoto.html#29e2aae62991d904c3cb763ec838d9bd" title="Setup photo using preexisting full size, slideshow, and thumbnail images.">Photo::setImage</a>(QString editedImageFilename)
<a name="l00156"></a>00156 {
<a name="l00157"></a>00157   <span class="comment">//if the image has been saved then simply change the image,slideshow/thubnail </span>
<a name="l00158"></a>00158   <span class="comment">//filename handles to point to the temporary directory. We don't need to worry about backing up the</span>
<a name="l00159"></a>00159   <span class="comment">//image because the new version will be written to the temporary directory and the save location</span>
<a name="l00160"></a>00160   <span class="keywordflow">if</span>( <a class="code" href="classPhoto.html#6626ec8af77a3804f1127ab85295e9e8" title="Returns if the image has ever been saved to a permanant location.">getEverSaved</a>() )
<a name="l00161"></a>00161   {
<a name="l00162"></a>00162     <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a> = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#a7000c4e580d93ccb7a3fdbc84e49952" title="Returns the temporary directory for use when modifying and adding new images.">getTmpDir</a>() + 
<a name="l00163"></a>00163                     QString(<span class="stringliteral">"/%1_%2.jpg"</span>).arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>).arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00164"></a>00164     <a class="code" href="classPhoto.html#cfe4c2b45cf6b5b5a24cbbc85ea609ed">slideshowLocation</a> = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#a7000c4e580d93ccb7a3fdbc84e49952" title="Returns the temporary directory for use when modifying and adding new images.">getTmpDir</a>() + 
<a name="l00165"></a>00165                         QString(<span class="stringliteral">"/%1_%2_slideshow.jpg"</span>).arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>).arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00166"></a>00166     <a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a> = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#a7000c4e580d93ccb7a3fdbc84e49952" title="Returns the temporary directory for use when modifying and adding new images.">getTmpDir</a>() + 
<a name="l00167"></a>00167                         QString(<span class="stringliteral">"/%1_%2_thumb.jpg"</span>).arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>).arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00168"></a>00168   }
<a name="l00169"></a>00169   <span class="comment">//otherwise image has never been saved, make sure original form has been backed up!</span>
<a name="l00170"></a>00170   <span class="keywordflow">else</span>
<a name="l00171"></a>00171   {
<a name="l00172"></a>00172     QString tempOrigLocation = <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>;
<a name="l00173"></a>00173     tempOrigLocation.truncate( <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>.length() - 4 );
<a name="l00174"></a>00174     tempOrigLocation = tempOrigLocation + <span class="stringliteral">"_orig.jpg"</span>;
<a name="l00175"></a>00175        
<a name="l00176"></a>00176     QDir tmpDir;
<a name="l00177"></a>00177     <span class="keywordflow">if</span>(!tmpDir.exists( tempOrigLocation ) )
<a name="l00178"></a>00178     { <a class="code" href="fileTools_8cpp.html#f41848ecf008f6b6579f5b0975faea5a" title="Copies a file from one location to another.">copyFile</a>( <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>, tempOrigLocation ); }    
<a name="l00179"></a>00179   }
<a name="l00180"></a>00180   
<a name="l00181"></a>00181   <span class="comment">//copy over full size image</span>
<a name="l00182"></a>00182   <a class="code" href="fileTools_8cpp.html#f41848ecf008f6b6579f5b0975faea5a" title="Copies a file from one location to another.">copyFile</a>( editedImageFilename, <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a> );
<a name="l00183"></a>00183   
<a name="l00184"></a>00184   <span class="comment">//reset revert flag since image has not been modified</span>
<a name="l00185"></a>00185   <a class="code" href="classPhoto.html#b0cffd8b36cb5a5b18d4543dfe69046b" title="Has the photo recently been reverted to it&amp;#39;s original form? If so during the...">recentlyReverted</a> = <span class="keyword">false</span>;
<a name="l00186"></a>00186   
<a name="l00187"></a>00187   <span class="comment">//construct smaller iamges</span>
<a name="l00188"></a>00188   <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#f4d602874536f89799f828abd2a34848" title="Construct thumbnail and slideshow images, load up thumbnail image, and set photo...">constructSmallerImages</a>();
<a name="l00189"></a>00189 }
<a name="l00190"></a>00190 <span class="comment">//==============================================</span>
<a name="l00191"></a><a class="code" href="classPhoto.html#5ebb6fccddd609df5d407498957e1089">00191</a> QString <a class="code" href="classPhoto.html#5ebb6fccddd609df5d407498957e1089" title="Gets the image filename.">Photo::getImageFilename</a>()             { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>;     }
<a name="l00192"></a><a class="code" href="classPhoto.html#d16ff6833a7ddc4340d7c296e2eeac99">00192</a> QString <a class="code" href="classPhoto.html#d16ff6833a7ddc4340d7c296e2eeac99" title="Gets the slideshow filename.">Photo::getSlideshowFilename</a>()         { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#cfe4c2b45cf6b5b5a24cbbc85ea609ed">slideshowLocation</a>; }
<a name="l00193"></a><a class="code" href="classPhoto.html#937a069696ef937d5ddd030b16946ded">00193</a> QString <a class="code" href="classPhoto.html#937a069696ef937d5ddd030b16946ded" title="Gets the thumbnail filename.">Photo::getThumbnailFilename</a>()         { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a>; }
<a name="l00194"></a>00194 
<a name="l00195"></a><a class="code" href="classPhoto.html#ce2956fdb7c227242265e30fca8247e2">00195</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#ce2956fdb7c227242265e30fca8247e2" title="Sets the image filename.">Photo::setImageFilename</a>(QString val)     { <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a> = val;     }
<a name="l00196"></a><a class="code" href="classPhoto.html#b583bd230c73111707224cbe973263b7">00196</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#b583bd230c73111707224cbe973263b7" title="Sets the slideshow filename.">Photo::setSlideshowFilename</a>(QString val) { <a class="code" href="classPhoto.html#cfe4c2b45cf6b5b5a24cbbc85ea609ed">slideshowLocation</a> = val; }
<a name="l00197"></a><a class="code" href="classPhoto.html#8c9ab31a5158bb44e9d8b972c12ff0f9">00197</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#8c9ab31a5158bb44e9d8b972c12ff0f9" title="Sets the thumbnail filename.">Photo::setThumbnailFilename</a>(QString val) { <a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a> = val; }
<a name="l00198"></a>00198 <span class="comment">//==============================================</span>
<a name="l00199"></a><a class="code" href="classPhoto.html#bc9851216524158d20580556219424a7">00199</a> QString <a class="code" href="classPhoto.html#bc9851216524158d20580556219424a7" title="Get image checksum.">Photo::getImageChecksum</a>()             { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#a3f68b264dc2e072e651331b9de6aed0" title="MD5 checksums, used to determine if image/thumbnail have been changed.">imageChecksum</a>; }
<a name="l00200"></a><a class="code" href="classPhoto.html#580439da79d239dba26e6f21abadbaf4">00200</a> QString <a class="code" href="classPhoto.html#580439da79d239dba26e6f21abadbaf4" title="Get thumbanil checksum.">Photo::getThumbnailChecksum</a>()         { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#4c418b827ae16ec1e96a6f1d0f1c84dd">thumbnailChecksum</a>; }
<a name="l00201"></a><a class="code" href="classPhoto.html#b4adadc959070279d7ab7dfc1a030c23">00201</a> QString <a class="code" href="classPhoto.html#b4adadc959070279d7ab7dfc1a030c23" title="Get thumbanil checksum.">Photo::getSlideshowChecksum</a>()         { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#8cb3aa1eaaf8f0f14d626b475b21f465">slideshowChecksum</a>; }
<a name="l00202"></a>00202 
<a name="l00203"></a><a class="code" href="classPhoto.html#e79da2eb5300276a3b1d7f5649316f7a">00203</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#e79da2eb5300276a3b1d7f5649316f7a" title="Update image checksum.">Photo::setImageChecksum</a>(QString val)     { <a class="code" href="classPhoto.html#a3f68b264dc2e072e651331b9de6aed0" title="MD5 checksums, used to determine if image/thumbnail have been changed.">imageChecksum</a> = val; }
<a name="l00204"></a><a class="code" href="classPhoto.html#191bff87fa41c0f77409a0a5e25c8d1e">00204</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#191bff87fa41c0f77409a0a5e25c8d1e" title="Update thumbnail checksum.">Photo::setThumbnailChecksum</a>(QString val) { <a class="code" href="classPhoto.html#4c418b827ae16ec1e96a6f1d0f1c84dd">thumbnailChecksum</a> = val; }
<a name="l00205"></a><a class="code" href="classPhoto.html#054e5a51249e511536d6549099c617bf">00205</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#054e5a51249e511536d6549099c617bf" title="Update slideshow checksum.">Photo::setSlideshowChecksum</a>(QString val) { <a class="code" href="classPhoto.html#8cb3aa1eaaf8f0f14d626b475b21f465">slideshowChecksum</a> = val; }
<a name="l00206"></a>00206 <span class="comment">//==============================================</span>
<a name="l00207"></a><a class="code" href="classPhoto.html#db7ed08547098feeaff5753f2600f4bc">00207</a> QString <a class="code" href="classPhoto.html#db7ed08547098feeaff5753f2600f4bc" title="Gets the description.">Photo::getDescription</a>() { <span class="keywordflow">return</span> QString(<a class="code" href="classPhoto.html#6fe05dc549b7caf2ee3232476d41e760" title="Photo description.">description</a>); }
<a name="l00208"></a>00208 <span class="comment">//==============================================</span>
<a name="l00209"></a><a class="code" href="classPhoto.html#b9460c196309be9f0084bbeb91ac04c6">00209</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#b9460c196309be9f0084bbeb91ac04c6" title="Sets the description.">Photo::setDescription</a>(QString val)
<a name="l00210"></a>00210 {
<a name="l00211"></a>00211   <span class="comment">//set empty strings as null, takes up less space and necessary</span>
<a name="l00212"></a>00212   <span class="comment">//to check for string modification</span>
<a name="l00213"></a>00213   <span class="keywordflow">if</span>( val.isEmpty() )
<a name="l00214"></a>00214     val = QString::null;
<a name="l00215"></a>00215 
<a name="l00216"></a>00216   <span class="keywordflow">if</span>(<a class="code" href="classPhoto.html#6fe05dc549b7caf2ee3232476d41e760" title="Photo description.">description</a>.compare(val) != 0)
<a name="l00217"></a>00217   {
<a name="l00218"></a>00218     <a class="code" href="classPhoto.html#6fe05dc549b7caf2ee3232476d41e760" title="Photo description.">description</a> = val;
<a name="l00219"></a>00219     <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#a01ad19461ce049774595512960f73cb">setModified</a>();
<a name="l00220"></a>00220   }
<a name="l00221"></a>00221 }
<a name="l00222"></a>00222 <span class="comment">//==============================================</span>
<a name="l00223"></a><a class="code" href="classPhoto.html#9740a1e6a5ad83534e1c3b2b2622cf7a">00223</a> <a class="code" href="classPhoto.html" title="A photo consists of a full size image, a smaller slide show image, a very small thumbnail...">Photo</a>* <a class="code" href="classPhoto.html#9740a1e6a5ad83534e1c3b2b2622cf7a" title="Returns the previous photo pointer.">Photo::getPrev</a>() { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#6d8d3898cc546889f7c0213b8bc3051a" title="Pointer to prev photo.">prev</a>; }
<a name="l00224"></a><a class="code" href="classPhoto.html#357f9d79451532a37f41142d3aaba9f9">00224</a> <a class="code" href="classPhoto.html" title="A photo consists of a full size image, a smaller slide show image, a very small thumbnail...">Photo</a>* <a class="code" href="classPhoto.html#357f9d79451532a37f41142d3aaba9f9" title="Returns next photo pointer.">Photo::getNext</a>() { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#8fd5de011a756f9974e9cd1f458e2678" title="Pointer to next photo.">next</a>; }
<a name="l00225"></a>00225 <span class="comment">//==============================================</span>
<a name="l00226"></a><a class="code" href="classPhoto.html#7ee24d63bde8307b79829737dfa2cd8f">00226</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#7ee24d63bde8307b79829737dfa2cd8f" title="Sets prev photo pointer.">Photo::setPrev</a>(<a class="code" href="classPhoto.html" title="A photo consists of a full size image, a smaller slide show image, a very small thumbnail...">Photo</a>* val) 
<a name="l00227"></a>00227 { 
<a name="l00228"></a>00228   <a class="code" href="classPhoto.html#6d8d3898cc546889f7c0213b8bc3051a" title="Pointer to prev photo.">prev</a> = val;
<a name="l00229"></a>00229   <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#a01ad19461ce049774595512960f73cb">setModified</a>();
<a name="l00230"></a>00230 }
<a name="l00231"></a>00231 <span class="comment">//==============================================</span>
<a name="l00232"></a><a class="code" href="classPhoto.html#6f4cb7532382e6d58daeb0163166e1e4">00232</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#6f4cb7532382e6d58daeb0163166e1e4" title="Sets next photo pointer.">Photo::setNext</a>(<a class="code" href="classPhoto.html" title="A photo consists of a full size image, a smaller slide show image, a very small thumbnail...">Photo</a>* val) 
<a name="l00233"></a>00233 { 
<a name="l00234"></a>00234   <a class="code" href="classPhoto.html#8fd5de011a756f9974e9cd1f458e2678" title="Pointer to next photo.">next</a> = val;
<a name="l00235"></a>00235   <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#a01ad19461ce049774595512960f73cb">setModified</a>();
<a name="l00236"></a>00236 }
<a name="l00237"></a>00237 <span class="comment">//==============================================</span>
<a name="l00238"></a><a class="code" href="classPhoto.html#175031feb8124b3aa22d6145cd45cf4f">00238</a> QDateTime* <a class="code" href="classPhoto.html#175031feb8124b3aa22d6145cd45cf4f" title="Builds photo from XML DOM node, returns date modified info from xml.">Photo::importFromDisk</a>(QDomNode* root)
<a name="l00239"></a>00239 {
<a name="l00240"></a>00240   <span class="comment">//create modified date/time object for returning</span>
<a name="l00241"></a>00241   QDateTime* modified = <span class="keyword">new</span> QDateTime[3];
<a name="l00242"></a>00242 
<a name="l00243"></a>00243   QDomNode node = root-&gt;firstChild();
<a name="l00244"></a>00244   QDomText val;
<a name="l00245"></a>00245   <span class="keywordflow">while</span>( !node.isNull() )
<a name="l00246"></a>00246   {
<a name="l00247"></a>00247     <span class="comment">//------------------------------------------------------------</span>
<a name="l00248"></a>00248     <span class="comment">//photo description</span>
<a name="l00249"></a>00249     <span class="keywordflow">if</span>( node.isElement() &amp;&amp; node.nodeName() == <span class="stringliteral">"description"</span> )
<a name="l00250"></a>00250     {
<a name="l00251"></a>00251       val = node.firstChild().toText();
<a name="l00252"></a>00252       <span class="keywordflow">if</span>(!val.isNull())
<a name="l00253"></a>00253         <a class="code" href="classPhoto.html#6fe05dc549b7caf2ee3232476d41e760" title="Photo description.">description</a> = val.nodeValue();
<a name="l00254"></a>00254      <a class="code" href="classPhoto.html#6fe05dc549b7caf2ee3232476d41e760" title="Photo description.">description</a>.replace(<span class="stringliteral">"\\&amp;quot;"</span>,<span class="stringliteral">"\""</span>);
<a name="l00255"></a>00255     }
<a name="l00256"></a>00256     <span class="comment">//------------------------------------------------------------</span>
<a name="l00257"></a>00257     <span class="comment">//image information</span>
<a name="l00258"></a>00258     <span class="keywordflow">else</span> <span class="keywordflow">if</span>( node.isElement() &amp;&amp; node.nodeName() == <span class="stringliteral">"image"</span> )
<a name="l00259"></a>00259     {
<a name="l00260"></a>00260       QDomNode childNode = node.firstChild();
<a name="l00261"></a>00261       <span class="keywordflow">while</span>( !childNode.isNull() )
<a name="l00262"></a>00262       {
<a name="l00263"></a>00263         <span class="comment">//------------------------------------------------------------</span>
<a name="l00264"></a>00264         <span class="keywordflow">if</span>( childNode.isElement() &amp;&amp; childNode.nodeName() == <span class="stringliteral">"md5"</span> )
<a name="l00265"></a>00265         {
<a name="l00266"></a>00266           val = childNode.firstChild().toText();
<a name="l00267"></a>00267           <span class="keywordflow">if</span>(!val.isNull())
<a name="l00268"></a>00268             <a class="code" href="classPhoto.html#a3f68b264dc2e072e651331b9de6aed0" title="MD5 checksums, used to determine if image/thumbnail have been changed.">imageChecksum</a> = val.nodeValue();
<a name="l00269"></a>00269         }
<a name="l00270"></a>00270         <span class="comment">//------------------------------------------------------------</span>
<a name="l00271"></a>00271         <span class="keywordflow">else</span> <span class="keywordflow">if</span>( childNode.isElement() &amp;&amp; childNode.nodeName() == <span class="stringliteral">"modified"</span> )
<a name="l00272"></a>00272         {
<a name="l00273"></a>00273           val = childNode.firstChild().toText();
<a name="l00274"></a>00274 
<a name="l00275"></a>00275           <span class="comment">//split value based on spaces, should be 7 fields</span>
<a name="l00276"></a>00276           QStringList vals = QStringList::split( QRegExp(<span class="stringliteral">" "</span>), val.nodeValue() );
<a name="l00277"></a>00277           <span class="keywordtype">int</span> i=0;
<a name="l00278"></a>00278           <span class="keywordtype">int</span> intVals[7];
<a name="l00279"></a>00279           QStringList::Iterator it;
<a name="l00280"></a>00280           <span class="keywordflow">for</span> ( it = vals.begin(); it != vals.end(); ++it )
<a name="l00281"></a>00281           {
<a name="l00282"></a>00282             <span class="comment">//sanity check incase more fields are provided than there should be</span>
<a name="l00283"></a>00283             <span class="keywordflow">if</span>(i &gt;6)
<a name="l00284"></a>00284               <span class="keywordflow">break</span>;
<a name="l00285"></a>00285 
<a name="l00286"></a>00286             intVals[i] = QString(*it).toInt();
<a name="l00287"></a>00287             i++;
<a name="l00288"></a>00288           }
<a name="l00289"></a>00289           modified[0].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
<a name="l00290"></a>00290           modified[0].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
<a name="l00291"></a>00291         }
<a name="l00292"></a>00292         <span class="comment">//------------------------------------------------------------</span>
<a name="l00293"></a>00293         childNode = childNode.nextSibling();
<a name="l00294"></a>00294       }
<a name="l00295"></a>00295     }
<a name="l00296"></a>00296     <span class="comment">//------------------------------------------------------------</span>
<a name="l00297"></a>00297     <span class="comment">//slideshow information</span>
<a name="l00298"></a>00298     <span class="keywordflow">else</span> <span class="keywordflow">if</span>( node.isElement() &amp;&amp; node.nodeName() == <span class="stringliteral">"slideshow"</span> )
<a name="l00299"></a>00299     {
<a name="l00300"></a>00300       QDomNode childNode = node.firstChild();
<a name="l00301"></a>00301       <span class="keywordflow">while</span>( !childNode.isNull() )
<a name="l00302"></a>00302       {
<a name="l00303"></a>00303         <span class="comment">//------------------------------------------------------------</span>
<a name="l00304"></a>00304         <span class="keywordflow">if</span>( childNode.isElement() &amp;&amp; childNode.nodeName() == <span class="stringliteral">"md5"</span> )
<a name="l00305"></a>00305         {
<a name="l00306"></a>00306           val = childNode.firstChild().toText();
<a name="l00307"></a>00307           <span class="keywordflow">if</span>(!val.isNull())
<a name="l00308"></a>00308             <a class="code" href="classPhoto.html#8cb3aa1eaaf8f0f14d626b475b21f465">slideshowChecksum</a> = val.nodeValue();
<a name="l00309"></a>00309         }
<a name="l00310"></a>00310         <span class="comment">//------------------------------------------------------------</span>
<a name="l00311"></a>00311         <span class="keywordflow">else</span> <span class="keywordflow">if</span>( childNode.isElement() &amp;&amp; childNode.nodeName() == <span class="stringliteral">"modified"</span> )
<a name="l00312"></a>00312         {
<a name="l00313"></a>00313           val = childNode.firstChild().toText();
<a name="l00314"></a>00314 
<a name="l00315"></a>00315           <span class="comment">//split value based on spaces, should be 6 fields</span>
<a name="l00316"></a>00316           QStringList vals = QStringList::split( QRegExp(<span class="stringliteral">" "</span>), val.nodeValue() );
<a name="l00317"></a>00317           <span class="keywordtype">int</span> i=0;
<a name="l00318"></a>00318           <span class="keywordtype">int</span> intVals[7];
<a name="l00319"></a>00319           QStringList::Iterator it;
<a name="l00320"></a>00320           <span class="keywordflow">for</span> ( it = vals.begin(); it != vals.end(); ++it )
<a name="l00321"></a>00321           {
<a name="l00322"></a>00322             <span class="comment">//sanity check incase more fields are provided than there should be</span>
<a name="l00323"></a>00323             <span class="keywordflow">if</span>(i &gt;6)
<a name="l00324"></a>00324               <span class="keywordflow">break</span>;
<a name="l00325"></a>00325 
<a name="l00326"></a>00326             intVals[i] = QString(*it).toInt();
<a name="l00327"></a>00327             i++;
<a name="l00328"></a>00328           }
<a name="l00329"></a>00329           modified[1].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
<a name="l00330"></a>00330           modified[1].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
<a name="l00331"></a>00331         }
<a name="l00332"></a>00332         <span class="comment">//------------------------------------------------------------</span>
<a name="l00333"></a>00333         childNode = childNode.nextSibling();
<a name="l00334"></a>00334       }
<a name="l00335"></a>00335     }
<a name="l00336"></a>00336     <span class="comment">//------------------------------------------------------------</span>
<a name="l00337"></a>00337     <span class="comment">//slideshow information</span>
<a name="l00338"></a>00338     <span class="keywordflow">else</span> <span class="keywordflow">if</span>( node.isElement() &amp;&amp; node.nodeName() == <span class="stringliteral">"thumb"</span> )
<a name="l00339"></a>00339     {
<a name="l00340"></a>00340       QDomNode childNode = node.firstChild();
<a name="l00341"></a>00341       <span class="keywordflow">while</span>( !childNode.isNull() )
<a name="l00342"></a>00342       {
<a name="l00343"></a>00343         <span class="comment">//------------------------------------------------------------</span>
<a name="l00344"></a>00344         <span class="keywordflow">if</span>( childNode.isElement() &amp;&amp; childNode.nodeName() == <span class="stringliteral">"md5"</span> )
<a name="l00345"></a>00345         {
<a name="l00346"></a>00346           val = childNode.firstChild().toText();
<a name="l00347"></a>00347           <span class="keywordflow">if</span>(!val.isNull())
<a name="l00348"></a>00348             <a class="code" href="classPhoto.html#4c418b827ae16ec1e96a6f1d0f1c84dd">thumbnailChecksum</a> = val.nodeValue();
<a name="l00349"></a>00349         }
<a name="l00350"></a>00350         <span class="comment">//------------------------------------------------------------</span>
<a name="l00351"></a>00351         <span class="keywordflow">else</span> <span class="keywordflow">if</span>( childNode.isElement() &amp;&amp; childNode.nodeName() == <span class="stringliteral">"modified"</span> )
<a name="l00352"></a>00352         {
<a name="l00353"></a>00353           val = childNode.firstChild().toText();
<a name="l00354"></a>00354 
<a name="l00355"></a>00355           <span class="comment">//split value based on spaces, should be 6 fields</span>
<a name="l00356"></a>00356           QStringList vals = QStringList::split( QRegExp(<span class="stringliteral">" "</span>), val.nodeValue() );
<a name="l00357"></a>00357           <span class="keywordtype">int</span> i=0;
<a name="l00358"></a>00358           <span class="keywordtype">int</span> intVals[7];
<a name="l00359"></a>00359           QStringList::Iterator it;
<a name="l00360"></a>00360           <span class="keywordflow">for</span> ( it = vals.begin(); it != vals.end(); ++it )
<a name="l00361"></a>00361           {
<a name="l00362"></a>00362             <span class="comment">//sanity check incase more fields are provided than there should be</span>
<a name="l00363"></a>00363             <span class="keywordflow">if</span>(i &gt;6)
<a name="l00364"></a>00364               <span class="keywordflow">break</span>;
<a name="l00365"></a>00365 
<a name="l00366"></a>00366             intVals[i] = QString(*it).toInt();
<a name="l00367"></a>00367             i++;
<a name="l00368"></a>00368           }
<a name="l00369"></a>00369           modified[2].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
<a name="l00370"></a>00370           modified[2].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
<a name="l00371"></a>00371         }
<a name="l00372"></a>00372         <span class="comment">//------------------------------------------------------------</span>
<a name="l00373"></a>00373         childNode = childNode.nextSibling();
<a name="l00374"></a>00374       }
<a name="l00375"></a>00375     }
<a name="l00376"></a>00376     <span class="comment">//------------------------------------------------------------</span>
<a name="l00377"></a>00377     <span class="comment">//------------------------------------------------------------</span>
<a name="l00378"></a>00378     <span class="comment">//Handle md5 info as specified in 1.0a and 1.0a2 xml format</span>
<a name="l00379"></a>00379     <span class="comment">//image md5</span>
<a name="l00380"></a>00380     <span class="keywordflow">else</span> <span class="keywordflow">if</span>( node.isElement() &amp;&amp; node.nodeName() == <span class="stringliteral">"imageMD5"</span> )
<a name="l00381"></a>00381     {
<a name="l00382"></a>00382       val = node.firstChild().toText();
<a name="l00383"></a>00383       <span class="keywordflow">if</span>(!val.isNull())
<a name="l00384"></a>00384         <a class="code" href="classPhoto.html#a3f68b264dc2e072e651331b9de6aed0" title="MD5 checksums, used to determine if image/thumbnail have been changed.">imageChecksum</a> = val.nodeValue();
<a name="l00385"></a>00385     }
<a name="l00386"></a>00386     <span class="comment">//------------------------------------------------------------</span>
<a name="l00387"></a>00387     <span class="comment">//slideshow md5</span>
<a name="l00388"></a>00388     <span class="keywordflow">else</span> <span class="keywordflow">if</span>( node.isElement() &amp;&amp; node.nodeName() == <span class="stringliteral">"slideMD5"</span> )
<a name="l00389"></a>00389     {
<a name="l00390"></a>00390       val = node.firstChild().toText();
<a name="l00391"></a>00391       <span class="keywordflow">if</span>(!val.isNull())
<a name="l00392"></a>00392         <a class="code" href="classPhoto.html#8cb3aa1eaaf8f0f14d626b475b21f465">slideshowChecksum</a> = val.nodeValue();
<a name="l00393"></a>00393     }
<a name="l00394"></a>00394     <span class="comment">//------------------------------------------------------------</span>
<a name="l00395"></a>00395     <span class="comment">//thumbnail md5</span>
<a name="l00396"></a>00396     <span class="keywordflow">else</span> <span class="keywordflow">if</span>( node.isElement() &amp;&amp; node.nodeName() == <span class="stringliteral">"thumbMD5"</span> )
<a name="l00397"></a>00397     {
<a name="l00398"></a>00398       val = node.firstChild().toText();
<a name="l00399"></a>00399       <span class="keywordflow">if</span>(!val.isNull())
<a name="l00400"></a>00400         <a class="code" href="classPhoto.html#4c418b827ae16ec1e96a6f1d0f1c84dd">thumbnailChecksum</a> = val.nodeValue();
<a name="l00401"></a>00401     }
<a name="l00402"></a>00402     <span class="comment">//------------------------------------------------------------</span>
<a name="l00403"></a>00403     <span class="comment">//------------------------------------------------------------</span>
<a name="l00404"></a>00404     <span class="comment">//advance to next node</span>
<a name="l00405"></a>00405     node = node.nextSibling();
<a name="l00406"></a>00406     <span class="comment">//------------------------------------------------------------</span>
<a name="l00407"></a>00407   }
<a name="l00408"></a>00408 
<a name="l00409"></a>00409   <span class="comment">//return modification dates read in</span>
<a name="l00410"></a>00410   <span class="keywordflow">return</span> modified;
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412 <span class="comment">//==============================================</span>
<a name="l00413"></a><a class="code" href="classPhoto.html#32cb80c04e59656420094311ad6d9c20">00413</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#32cb80c04e59656420094311ad6d9c20" title="Exports photo to xml.">Photo::exportToXML</a>(QTextStream&amp; stream)
<a name="l00414"></a>00414 {
<a name="l00415"></a>00415   QFileInfo info;
<a name="l00416"></a>00416 
<a name="l00417"></a>00417   <span class="comment">//write photo information</span>
<a name="l00418"></a>00418   stream &lt;&lt; <span class="stringliteral">"    &lt;photo&gt;\n"</span>;
<a name="l00419"></a>00419   <span class="comment">//-----</span>
<a name="l00420"></a>00420   stream &lt;&lt; <span class="stringliteral">"      &lt;description&gt;"</span> &lt;&lt; <a class="code" href="xmlTools_8cpp.html#fd193066f6b4f77436cd0f17146a1e39" title="Fix strings before exporting to XML such that &amp;amp; becomes &amp;amp;, etc...">fixXMLString</a>(<a class="code" href="classPhoto.html#6fe05dc549b7caf2ee3232476d41e760" title="Photo description.">description</a>) &lt;&lt; <span class="stringliteral">"&lt;/description&gt;\n"</span>;
<a name="l00421"></a>00421   <span class="comment">//-----</span>
<a name="l00422"></a>00422   <span class="comment">//full image</span>
<a name="l00423"></a>00423   info.setFile( <a class="code" href="classPhoto.html#5ebb6fccddd609df5d407498957e1089" title="Gets the image filename.">getImageFilename</a>() );
<a name="l00424"></a>00424   QDateTime modified = info.lastModified();
<a name="l00425"></a>00425   stream &lt;&lt; <span class="stringliteral">"      &lt;image&gt;\n"</span>;
<a name="l00426"></a>00426   stream &lt;&lt; <span class="stringliteral">"        &lt;md5&gt;"</span> &lt;&lt; <a class="code" href="xmlTools_8cpp.html#fd193066f6b4f77436cd0f17146a1e39" title="Fix strings before exporting to XML such that &amp;amp; becomes &amp;amp;, etc...">fixXMLString</a>(<a class="code" href="classPhoto.html#a3f68b264dc2e072e651331b9de6aed0" title="MD5 checksums, used to determine if image/thumbnail have been changed.">imageChecksum</a>) &lt;&lt; <span class="stringliteral">"&lt;/md5&gt;\n"</span>;
<a name="l00427"></a>00427   stream &lt;&lt; <span class="stringliteral">"        &lt;modified&gt;"</span>;
<a name="l00428"></a>00428   stream &lt;&lt; modified.date().year() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00429"></a>00429   stream &lt;&lt; modified.date().month() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00430"></a>00430   stream &lt;&lt; modified.date().day() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00431"></a>00431   stream &lt;&lt; modified.time().hour() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00432"></a>00432   stream &lt;&lt; modified.time().minute() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00433"></a>00433   stream &lt;&lt; modified.time().second() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00434"></a>00434   stream &lt;&lt; modified.time().msec() &lt;&lt; <span class="stringliteral">"&lt;/modified&gt;\n"</span>;
<a name="l00435"></a>00435   stream &lt;&lt; <span class="stringliteral">"      &lt;/image&gt;\n"</span>;
<a name="l00436"></a>00436   <span class="comment">//-----</span>
<a name="l00437"></a>00437   <span class="comment">//slidehow image</span>
<a name="l00438"></a>00438   info.setFile( <a class="code" href="classPhoto.html#d16ff6833a7ddc4340d7c296e2eeac99" title="Gets the slideshow filename.">getSlideshowFilename</a>() );
<a name="l00439"></a>00439   modified = info.lastModified();
<a name="l00440"></a>00440   stream &lt;&lt; <span class="stringliteral">"      &lt;slideshow&gt;\n"</span>;
<a name="l00441"></a>00441   stream &lt;&lt; <span class="stringliteral">"        &lt;md5&gt;"</span> &lt;&lt; <a class="code" href="xmlTools_8cpp.html#fd193066f6b4f77436cd0f17146a1e39" title="Fix strings before exporting to XML such that &amp;amp; becomes &amp;amp;, etc...">fixXMLString</a>(<a class="code" href="classPhoto.html#8cb3aa1eaaf8f0f14d626b475b21f465">slideshowChecksum</a>) &lt;&lt; <span class="stringliteral">"&lt;/md5&gt;\n"</span>;
<a name="l00442"></a>00442   stream &lt;&lt; <span class="stringliteral">"        &lt;modified&gt;"</span>;
<a name="l00443"></a>00443   stream &lt;&lt; modified.date().year() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00444"></a>00444   stream &lt;&lt; modified.date().month() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00445"></a>00445   stream &lt;&lt; modified.date().day() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00446"></a>00446   stream &lt;&lt; modified.time().hour() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00447"></a>00447   stream &lt;&lt; modified.time().minute() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00448"></a>00448   stream &lt;&lt; modified.time().second() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00449"></a>00449   stream &lt;&lt; modified.time().msec() &lt;&lt; <span class="stringliteral">"&lt;/modified&gt;\n"</span>;
<a name="l00450"></a>00450   stream &lt;&lt; <span class="stringliteral">"      &lt;/slideshow&gt;\n"</span>;
<a name="l00451"></a>00451   <span class="comment">//-----</span>
<a name="l00452"></a>00452   <span class="comment">//thumbnail image</span>
<a name="l00453"></a>00453   info.setFile( <a class="code" href="classPhoto.html#937a069696ef937d5ddd030b16946ded" title="Gets the thumbnail filename.">getThumbnailFilename</a>() );
<a name="l00454"></a>00454   modified = info.lastModified();
<a name="l00455"></a>00455   stream &lt;&lt; <span class="stringliteral">"      &lt;thumb&gt;\n"</span>;
<a name="l00456"></a>00456   stream &lt;&lt; <span class="stringliteral">"        &lt;md5&gt;"</span> &lt;&lt; <a class="code" href="xmlTools_8cpp.html#fd193066f6b4f77436cd0f17146a1e39" title="Fix strings before exporting to XML such that &amp;amp; becomes &amp;amp;, etc...">fixXMLString</a>(<a class="code" href="classPhoto.html#4c418b827ae16ec1e96a6f1d0f1c84dd">thumbnailChecksum</a>) &lt;&lt; <span class="stringliteral">"&lt;/md5&gt;\n"</span>;
<a name="l00457"></a>00457   stream &lt;&lt; <span class="stringliteral">"        &lt;modified&gt;"</span>;
<a name="l00458"></a>00458   stream &lt;&lt; modified.date().year() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00459"></a>00459   stream &lt;&lt; modified.date().month() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00460"></a>00460   stream &lt;&lt; modified.date().day() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00461"></a>00461   stream &lt;&lt; modified.time().hour() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00462"></a>00462   stream &lt;&lt; modified.time().minute() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00463"></a>00463   stream &lt;&lt; modified.time().second() &lt;&lt; <span class="stringliteral">" "</span>;
<a name="l00464"></a>00464   stream &lt;&lt; modified.time().msec() &lt;&lt; <span class="stringliteral">"&lt;/modified&gt;\n"</span>;
<a name="l00465"></a>00465   stream &lt;&lt; <span class="stringliteral">"      &lt;/thumb&gt;\n"</span>;
<a name="l00466"></a>00466   <span class="comment">//-----</span>
<a name="l00467"></a>00467   stream &lt;&lt; <span class="stringliteral">"    &lt;/photo&gt;\n"</span>;
<a name="l00468"></a>00468 }
<a name="l00469"></a>00469 <span class="comment">//==============================================</span>
<a name="l00470"></a><a class="code" href="classPhoto.html#39ddcbbd8582b87b505f83826f03597c">00470</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#39ddcbbd8582b87b505f83826f03597c" title="Rotates image clockwise 90 degrees.">Photo::rotate90</a>()         { <a class="code" href="classPhoto.html#37663feecba1823f08b177fd6c9fdf9d" title="Apply transformation.">applyTransformation</a>( <a class="code" href="imageTools_8h.html#d6b8916a355278afb7cd35f14afc9288685062467b0c1a3164556335b467c886">ROTATE_90</a> );  }
<a name="l00471"></a><a class="code" href="classPhoto.html#0150c65533eb7ef04412ab7aed2b3c7b">00471</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#0150c65533eb7ef04412ab7aed2b3c7b" title="Rotates image clockwise 270 degrees.">Photo::rotate270</a>()        { <a class="code" href="classPhoto.html#37663feecba1823f08b177fd6c9fdf9d" title="Apply transformation.">applyTransformation</a>( <a class="code" href="imageTools_8h.html#d6b8916a355278afb7cd35f14afc9288554e734d2a23790b248c5ce39816c18f">ROTATE_270</a> ); }
<a name="l00472"></a><a class="code" href="classPhoto.html#bb2cdbd79d85cc30ffc22af5eaf9796c">00472</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#bb2cdbd79d85cc30ffc22af5eaf9796c" title="Flips image about horizontal axis.">Photo::flipHorizontally</a>() { <a class="code" href="classPhoto.html#37663feecba1823f08b177fd6c9fdf9d" title="Apply transformation.">applyTransformation</a>( <a class="code" href="imageTools_8h.html#d6b8916a355278afb7cd35f14afc9288a02c13f8f08154ca2e58c488c922fbe5">FLIP_H</a> );     }
<a name="l00473"></a><a class="code" href="classPhoto.html#8db049b5515cd7364742905ead2e60a5">00473</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#8db049b5515cd7364742905ead2e60a5" title="Flips image about vertical axis.">Photo::flipVertically</a>()   { <a class="code" href="classPhoto.html#37663feecba1823f08b177fd6c9fdf9d" title="Apply transformation.">applyTransformation</a>( <a class="code" href="imageTools_8h.html#d6b8916a355278afb7cd35f14afc9288127171d15d7e5849705973e163393c71">FLIP_V</a> );     }
<a name="l00474"></a>00474 <span class="comment">//==============================================</span>
<a name="l00475"></a><a class="code" href="classPhoto.html#37663feecba1823f08b177fd6c9fdf9d">00475</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#37663feecba1823f08b177fd6c9fdf9d" title="Apply transformation.">Photo::applyTransformation</a>(<a class="code" href="imageTools_8h.html#d6b8916a355278afb7cd35f14afc9288">TRANSFORM_CODE</a> transformation)
<a name="l00476"></a>00476 {  
<a name="l00477"></a>00477   <span class="comment">//backup old filename</span>
<a name="l00478"></a>00478   QString oldName = <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>;
<a name="l00479"></a>00479    
<a name="l00480"></a>00480   <span class="comment">//if the image did not previously need saving, </span>
<a name="l00481"></a>00481   <span class="comment">//reset filenames to point to temporary location and</span>
<a name="l00482"></a>00482   <span class="comment">//immediately perform transformation</span>
<a name="l00483"></a>00483   <span class="keywordflow">if</span>(!<a class="code" href="classPhoto.html#c53f4bdf11a948daef3c1a300668d331" title="Unsaved modifications?">needsSaving</a>)
<a name="l00484"></a>00484   {
<a name="l00485"></a>00485     <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a> = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#a7000c4e580d93ccb7a3fdbc84e49952" title="Returns the temporary directory for use when modifying and adding new images.">getTmpDir</a>() + QString(<span class="stringliteral">"/%1_%2.jpg"</span>)
<a name="l00486"></a>00486                                                                 .arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>)
<a name="l00487"></a>00487                                                                 .arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00488"></a>00488     <a class="code" href="classPhoto.html#cfe4c2b45cf6b5b5a24cbbc85ea609ed">slideshowLocation</a> = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#a7000c4e580d93ccb7a3fdbc84e49952" title="Returns the temporary directory for use when modifying and adding new images.">getTmpDir</a>() + QString(<span class="stringliteral">"/%1_%2_slideshow.jpg"</span>)
<a name="l00489"></a>00489                                                                 .arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>)
<a name="l00490"></a>00490                                                                 .arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00491"></a>00491     <a class="code" href="classPhoto.html#875ec0737b03198d51dc2e47380dd213">thumbnailLocation</a> = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#a7000c4e580d93ccb7a3fdbc84e49952" title="Returns the temporary directory for use when modifying and adding new images.">getTmpDir</a>() + QString(<span class="stringliteral">"/%1_%2_thumb.jpg"</span>)
<a name="l00492"></a>00492                                                                 .arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>)
<a name="l00493"></a>00493                                                                 .arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00494"></a>00494     <a class="code" href="imageTools_8cpp.html#c697bfb4e95bd96d949a4a61f0ce006e" title="Apply image transformation on image.">transformImage</a>( oldName, <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>, transformation );
<a name="l00495"></a>00495   }
<a name="l00496"></a>00496   <span class="keywordflow">else</span>
<a name="l00497"></a>00497   {
<a name="l00498"></a>00498     <span class="comment">//images that need saving already exist in the temporary directory</span>
<a name="l00499"></a>00499     <span class="comment">//this poses two problems:</span>
<a name="l00500"></a>00500     <span class="comment">//1.) fast jpeg transformations cannot be done in place, so we'll employ an</span>
<a name="l00501"></a>00501     <span class="comment">//    intermediate image</span>
<a name="l00502"></a>00502     QString intermediateName = QString(<span class="stringliteral">"%1_intermdiate.jpg"</span>).arg(oldName);
<a name="l00503"></a>00503     <a class="code" href="imageTools_8cpp.html#c697bfb4e95bd96d949a4a61f0ce006e" title="Apply image transformation on image.">transformImage</a>( oldName, intermediateName, transformation );    
<a name="l00504"></a>00504     
<a name="l00505"></a>00505     <span class="comment">//2.) If the photo has never been saved and an orig file in the temporary</span>
<a name="l00506"></a>00506     <span class="comment">//    directory does not exist then the current file is the original version. we</span>
<a name="l00507"></a>00507     <span class="comment">//    must make sure that this original photo is maintained using an orig file so</span>
<a name="l00508"></a>00508     <span class="comment">//    in the future users can revert the photo to it's original form.</span>
<a name="l00509"></a>00509     QString origName = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#a7000c4e580d93ccb7a3fdbc84e49952" title="Returns the temporary directory for use when modifying and adding new images.">getTmpDir</a>() + QString(<span class="stringliteral">"/0_%1_orig.jpg"</span>)
<a name="l00510"></a>00510       .arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);      
<a name="l00511"></a>00511     QDir tmpDir;
<a name="l00512"></a>00512     <span class="keywordflow">if</span>( !<a class="code" href="classPhoto.html#6626ec8af77a3804f1127ab85295e9e8" title="Returns if the image has ever been saved to a permanant location.">getEverSaved</a>() &amp;&amp; !tmpDir.exists(origName) )
<a name="l00513"></a>00513     {
<a name="l00514"></a>00514       <a class="code" href="fileTools_8cpp.html#303fab00942c01cb4872793ee0abe508">moveFile</a>( oldName, origName );
<a name="l00515"></a>00515       <a class="code" href="fileTools_8cpp.html#303fab00942c01cb4872793ee0abe508">moveFile</a>( intermediateName, <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a> );
<a name="l00516"></a>00516     }
<a name="l00517"></a>00517     <span class="keywordflow">else</span>
<a name="l00518"></a>00518     {
<a name="l00519"></a>00519       <a class="code" href="fileTools_8cpp.html#303fab00942c01cb4872793ee0abe508">moveFile</a>( intermediateName, <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a> );
<a name="l00520"></a>00520     }
<a name="l00521"></a>00521   }
<a name="l00522"></a>00522   
<a name="l00523"></a>00523   <span class="comment">//image now modified from original form so orig file needs to be kept</span>
<a name="l00524"></a>00524   <a class="code" href="classPhoto.html#b0cffd8b36cb5a5b18d4543dfe69046b" title="Has the photo recently been reverted to it&amp;#39;s original form? If so during the...">recentlyReverted</a> = <span class="keyword">false</span>;
<a name="l00525"></a>00525   
<a name="l00526"></a>00526   <span class="comment">//construct smaller iamges</span>
<a name="l00527"></a>00527   <a class="code" href="classPhoto.html#f4d602874536f89799f828abd2a34848" title="Construct thumbnail and slideshow images, load up thumbnail image, and set photo...">constructSmallerImages</a>();
<a name="l00528"></a>00528 }
<a name="l00529"></a>00529 <span class="comment">//==============================================</span>
<a name="l00530"></a><a class="code" href="classPhoto.html#25ceab66d0421b4305c0475372140d81">00530</a> <span class="keywordtype">bool</span> <a class="code" href="classPhoto.html#25ceab66d0421b4305c0475372140d81" title="Returns if the image needs to be saved to its permament location.">Photo::getNeedsSavingVal</a>()               { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#c53f4bdf11a948daef3c1a300668d331" title="Unsaved modifications?">needsSaving</a>; }
<a name="l00531"></a><a class="code" href="classPhoto.html#869d215db9d16aad336e2823927c3e84">00531</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#869d215db9d16aad336e2823927c3e84" title="Sets if the image needs to be saved to its permanent location.">Photo::setNeedsSavingVal</a>(<span class="keywordtype">bool</span> val)       { <a class="code" href="classPhoto.html#c53f4bdf11a948daef3c1a300668d331" title="Unsaved modifications?">needsSaving</a> = val; }
<a name="l00532"></a>00532 <span class="comment">//==============================================</span>
<a name="l00533"></a><a class="code" href="classPhoto.html#6626ec8af77a3804f1127ab85295e9e8">00533</a> <span class="keywordtype">bool</span> <a class="code" href="classPhoto.html#6626ec8af77a3804f1127ab85295e9e8" title="Returns if the image has ever been saved to a permanant location.">Photo::getEverSaved</a>()                    { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#441a3e1ea66da5e86fa02ecf7d41c09d" title="Has the photo ever been saved?">everSaved</a>; }
<a name="l00534"></a><a class="code" href="classPhoto.html#60408934b0cb03ad0ad359ab1b5393a3">00534</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#60408934b0cb03ad0ad359ab1b5393a3" title="sets everSaved">Photo::setEverSaved</a>(<span class="keywordtype">bool</span> val)            { <a class="code" href="classPhoto.html#441a3e1ea66da5e86fa02ecf7d41c09d" title="Has the photo ever been saved?">everSaved</a> = val; }
<a name="l00535"></a>00535 <span class="comment">//==============================================</span>
<a name="l00536"></a><a class="code" href="classPhoto.html#cf93c6065bb708320e7c675068e0b3d0">00536</a> <span class="keywordtype">bool</span> <a class="code" href="classPhoto.html#cf93c6065bb708320e7c675068e0b3d0" title="can photo be reverted to a differnt original form">Photo::revertPossible</a>()
<a name="l00537"></a>00537 {
<a name="l00538"></a>00538   <span class="comment">//if photo not recently reverted and orig and current filenames differ</span>
<a name="l00539"></a>00539   QString newName = <a class="code" href="classPhoto.html#5ebb6fccddd609df5d407498957e1089" title="Gets the image filename.">getImageFilename</a>();
<a name="l00540"></a>00540   QString origName = <a class="code" href="classPhoto.html#6a4cd6dfc1b78fa3b1c1661a59f71162" title="orig filename">originalImageFilename</a>();
<a name="l00541"></a>00541   
<a name="l00542"></a>00542   <span class="keywordflow">return</span> ( !<a class="code" href="classPhoto.html#b0cffd8b36cb5a5b18d4543dfe69046b" title="Has the photo recently been reverted to it&amp;#39;s original form? If so during the...">recentlyReverted</a> &amp;&amp;
<a name="l00543"></a>00543            origName.compare( newName ) !=0 );
<a name="l00544"></a>00544 }
<a name="l00545"></a>00545 <span class="comment">//==============================================</span>
<a name="l00546"></a><a class="code" href="classPhoto.html#03dbeca8e03ab6e7d37d5b015e173bd3">00546</a> <span class="keywordtype">bool</span> <a class="code" href="classPhoto.html#03dbeca8e03ab6e7d37d5b015e173bd3" title="was the photo recently reverted? if so ignore the presence of orig files on disk">Photo::getRecentlyReverted</a>()
<a name="l00547"></a>00547 {
<a name="l00548"></a>00548   <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#b0cffd8b36cb5a5b18d4543dfe69046b" title="Has the photo recently been reverted to it&amp;#39;s original form? If so during the...">recentlyReverted</a>;
<a name="l00549"></a>00549 }
<a name="l00550"></a>00550 <span class="comment">//==============================================</span>
<a name="l00551"></a><a class="code" href="classPhoto.html#313c0cdae1171955581fb976609014bd">00551</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#313c0cdae1171955581fb976609014bd" title="reset the recently reverted value to val">Photo::setRecentlyReverted</a>(<span class="keywordtype">bool</span> val)
<a name="l00552"></a>00552 {
<a name="l00553"></a>00553   <a class="code" href="classPhoto.html#b0cffd8b36cb5a5b18d4543dfe69046b" title="Has the photo recently been reverted to it&amp;#39;s original form? If so during the...">recentlyReverted</a> = val;
<a name="l00554"></a>00554 }
<a name="l00555"></a>00555 <span class="comment">//==============================================</span>
<a name="l00556"></a><a class="code" href="classPhoto.html#e50ed3a18f16735fcdade8f6f3f35488">00556</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#e50ed3a18f16735fcdade8f6f3f35488" title="revert photo to original form">Photo::revertPhoto</a>()
<a name="l00557"></a>00557 {
<a name="l00558"></a>00558   <span class="comment">//ignore if revert is not possible</span>
<a name="l00559"></a>00559   <span class="keywordflow">if</span>(!<a class="code" href="classPhoto.html#cf93c6065bb708320e7c675068e0b3d0" title="can photo be reverted to a differnt original form">revertPossible</a>())
<a name="l00560"></a>00560     <span class="keywordflow">return</span>;
<a name="l00561"></a>00561   
<a name="l00562"></a>00562   <span class="comment">//set image to reverted form</span>
<a name="l00563"></a>00563   QString origName = <a class="code" href="classPhoto.html#6a4cd6dfc1b78fa3b1c1661a59f71162" title="orig filename">originalImageFilename</a>();
<a name="l00564"></a>00564   <a class="code" href="classPhoto.html#29e2aae62991d904c3cb763ec838d9bd" title="Setup photo using preexisting full size, slideshow, and thumbnail images.">setImage</a>( origName );
<a name="l00565"></a>00565   
<a name="l00566"></a>00566   <span class="comment">//recently reverted, orig file should be</span>
<a name="l00567"></a>00567   <span class="comment">//removed during next save since it's redundant</span>
<a name="l00568"></a>00568   <a class="code" href="classPhoto.html#b0cffd8b36cb5a5b18d4543dfe69046b" title="Has the photo recently been reverted to it&amp;#39;s original form? If so during the...">recentlyReverted</a> = <span class="keyword">true</span>;
<a name="l00569"></a>00569 }
<a name="l00570"></a>00570 <span class="comment">//==============================================</span>
<a name="l00571"></a><a class="code" href="classPhoto.html#6a4cd6dfc1b78fa3b1c1661a59f71162">00571</a> QString <a class="code" href="classPhoto.html#6a4cd6dfc1b78fa3b1c1661a59f71162" title="orig filename">Photo::originalImageFilename</a>()
<a name="l00572"></a>00572 {
<a name="l00573"></a>00573   <span class="comment">//determining the an images original filename is tricky</span>
<a name="l00574"></a>00574   <span class="comment">//if the photo has never been saved check for presence of an _orig file,</span>
<a name="l00575"></a>00575   <span class="comment">//otherwise use the current filename since the photo has not yet been modified</span>
<a name="l00576"></a>00576   <span class="keywordflow">if</span>( !<a class="code" href="classPhoto.html#6626ec8af77a3804f1127ab85295e9e8" title="Returns if the image has ever been saved to a permanant location.">getEverSaved</a>() )
<a name="l00577"></a>00577   {
<a name="l00578"></a>00578     QString tempOrigLocation = <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>;
<a name="l00579"></a>00579     tempOrigLocation.truncate( <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>.length() - 4 );
<a name="l00580"></a>00580     tempOrigLocation = tempOrigLocation + <span class="stringliteral">"_orig.jpg"</span>;
<a name="l00581"></a>00581     
<a name="l00582"></a>00582     QDir tmpDir;
<a name="l00583"></a>00583     <span class="keywordflow">if</span>(tmpDir.exists( tempOrigLocation ) )
<a name="l00584"></a>00584       <span class="keywordflow">return</span> tempOrigLocation;
<a name="l00585"></a>00585     <span class="keywordflow">else</span>
<a name="l00586"></a>00586       <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#ae2a02758b56abaa759057e7ee21f9b5" title="Filenames.">imageLocation</a>;
<a name="l00587"></a>00587   }
<a name="l00588"></a>00588   <span class="comment">//if the photo was previously saved, it's original form could either be:</span>
<a name="l00589"></a>00589   <span class="comment">//1.) the permanant storage location + _orig</span>
<a name="l00590"></a>00590   <span class="comment">//2.) the permanant storage location</span>
<a name="l00591"></a>00591   <span class="keywordflow">else</span>
<a name="l00592"></a>00592   {
<a name="l00593"></a>00593     QString storedOrigLocation = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#d00fd15f7683622ffc3d2cef1fe3f9ca" title="Returns the current save location of all images.">getSaveLocation</a>() +  
<a name="l00594"></a>00594       QString(<span class="stringliteral">"/img/%1/%2_orig.jpg"</span>).arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>).arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);
<a name="l00595"></a>00595    
<a name="l00596"></a>00596     QString lastSavedLocation = <a class="code" href="classPhoto.html#1274dccc0e1deef5dcb25b45a4bda5d1" title="Subalbum photo is in.">subalbum</a>-&gt;<a class="code" href="classSubalbum.html#b42d5716bb7253d290302bd1d735d578" title="returns the album pointer">getAlbum</a>()-&gt;<a class="code" href="classAlbum.html#d00fd15f7683622ffc3d2cef1fe3f9ca" title="Returns the current save location of all images.">getSaveLocation</a>() +  
<a name="l00597"></a>00597       QString(<span class="stringliteral">"/img/%1/%2.jpg"</span>).arg(<a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>).arg(<a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>);    
<a name="l00598"></a>00598     
<a name="l00599"></a>00599     QDir tmpDir;
<a name="l00600"></a>00600     <span class="keywordflow">if</span>(tmpDir.exists( storedOrigLocation ) )
<a name="l00601"></a>00601       <span class="keywordflow">return</span> storedOrigLocation;
<a name="l00602"></a>00602     <span class="keywordflow">else</span>
<a name="l00603"></a>00603       <span class="keywordflow">return</span> lastSavedLocation;
<a name="l00604"></a>00604   }
<a name="l00605"></a>00605 }
<a name="l00606"></a>00606 <span class="comment">//==============================================</span>
<a name="l00607"></a><a class="code" href="classPhoto.html#9c95d4244d694b03981ca4fce6f9e95f">00607</a> <span class="keywordtype">int</span> <a class="code" href="classPhoto.html#9c95d4244d694b03981ca4fce6f9e95f" title="Returns initial photo number.">Photo::getInitialPhotoNumber</a>()            { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a>; }
<a name="l00608"></a><a class="code" href="classPhoto.html#8d404398640e4db5545f6a81af5b8e46">00608</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#8d404398640e4db5545f6a81af5b8e46" title="Sets initial photo number.">Photo::setInitialPhotoNumber</a>(<span class="keywordtype">int</span> val)    { <a class="code" href="classPhoto.html#c12f1ae514759507c64feba1a918ac36">initialPhotoNumber</a> = val; }
<a name="l00609"></a>00609 
<a name="l00610"></a><a class="code" href="classPhoto.html#8801fb425f8dea9372fd95b875043186">00610</a> <span class="keywordtype">int</span> <a class="code" href="classPhoto.html#8801fb425f8dea9372fd95b875043186" title="Returns initial subalbum number.">Photo::getInitialSubalbumNumber</a>()         { <span class="keywordflow">return</span> <a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a>; }
<a name="l00611"></a><a class="code" href="classPhoto.html#5e68573a73d1b2315db2c3cc2b53b2f1">00611</a> <span class="keywordtype">void</span> <a class="code" href="classPhoto.html#5e68573a73d1b2315db2c3cc2b53b2f1" title="Sets initial subalbum number.">Photo::setInitialSubalbumNumber</a>(<span class="keywordtype">int</span> val) { <a class="code" href="classPhoto.html#aa2e2bea26ea53212d76ec17dc4e04bc">initialSubalbumNumber</a> = val; }
<a name="l00612"></a>00612 <span class="comment">//==============================================</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 23 02:34:26 2009 for AlbumShaper by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>