14 #include <q3textstream.h> 17 #include <qfileinfo.h> 29 #include "../config.h" 88 QImage TslideshowImage, TthumbnailImage;
106 QString slideshowName,
107 QString thumbnailName)
145 QImage tempImage(imageName);
146 if( tempImage.isNull() ) {
return false; }
175 tempOrigLocation = tempOrigLocation +
"_orig.jpg";
178 if(!tmpDir.exists( tempOrigLocation ) )
242 QDateTime* modified =
new QDateTime[3];
244 QDomNode node = root->firstChild();
246 while( !node.isNull() )
250 if( node.isElement() && node.nodeName() ==
"description" )
252 val = node.firstChild().toText();
259 else if( node.isElement() && node.nodeName() ==
"image" )
261 QDomNode childNode = node.firstChild();
262 while( !childNode.isNull() )
265 if( childNode.isElement() && childNode.nodeName() ==
"md5" )
267 val = childNode.firstChild().toText();
272 else if( childNode.isElement() && childNode.nodeName() ==
"modified" )
274 val = childNode.firstChild().toText();
277 QStringList vals = QStringList::split( QRegExp(
" "), val.nodeValue() );
280 QStringList::Iterator it;
281 for ( it = vals.begin(); it != vals.end(); ++it )
287 intVals[i] = QString(*it).toInt();
290 modified[0].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
291 modified[0].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
294 childNode = childNode.nextSibling();
299 else if( node.isElement() && node.nodeName() ==
"slideshow" )
301 QDomNode childNode = node.firstChild();
302 while( !childNode.isNull() )
305 if( childNode.isElement() && childNode.nodeName() ==
"md5" )
307 val = childNode.firstChild().toText();
312 else if( childNode.isElement() && childNode.nodeName() ==
"modified" )
314 val = childNode.firstChild().toText();
317 QStringList vals = QStringList::split( QRegExp(
" "), val.nodeValue() );
320 QStringList::Iterator it;
321 for ( it = vals.begin(); it != vals.end(); ++it )
327 intVals[i] = QString(*it).toInt();
330 modified[1].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
331 modified[1].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
334 childNode = childNode.nextSibling();
339 else if( node.isElement() && node.nodeName() ==
"thumb" )
341 QDomNode childNode = node.firstChild();
342 while( !childNode.isNull() )
345 if( childNode.isElement() && childNode.nodeName() ==
"md5" )
347 val = childNode.firstChild().toText();
352 else if( childNode.isElement() && childNode.nodeName() ==
"modified" )
354 val = childNode.firstChild().toText();
357 QStringList vals = QStringList::split( QRegExp(
" "), val.nodeValue() );
360 QStringList::Iterator it;
361 for ( it = vals.begin(); it != vals.end(); ++it )
367 intVals[i] = QString(*it).toInt();
370 modified[2].setDate( QDate(intVals[0], intVals[1], intVals[2]) );
371 modified[2].setTime( QTime(intVals[3], intVals[4], intVals[5], intVals[6]) );
374 childNode = childNode.nextSibling();
381 else if( node.isElement() && node.nodeName() ==
"imageMD5" )
383 val = node.firstChild().toText();
389 else if( node.isElement() && node.nodeName() ==
"slideMD5" )
391 val = node.firstChild().toText();
397 else if( node.isElement() && node.nodeName() ==
"thumbMD5" )
399 val = node.firstChild().toText();
406 node = node.nextSibling();
419 stream <<
" <photo>\n";
425 QDateTime modified = info.lastModified();
426 stream <<
" <image>\n";
428 stream <<
" <modified>";
429 stream << modified.date().year() <<
" ";
430 stream << modified.date().month() <<
" ";
431 stream << modified.date().day() <<
" ";
432 stream << modified.time().hour() <<
" ";
433 stream << modified.time().minute() <<
" ";
434 stream << modified.time().second() <<
" ";
435 stream << modified.time().msec() <<
"</modified>\n";
436 stream <<
" </image>\n";
440 modified = info.lastModified();
441 stream <<
" <slideshow>\n";
443 stream <<
" <modified>";
444 stream << modified.date().year() <<
" ";
445 stream << modified.date().month() <<
" ";
446 stream << modified.date().day() <<
" ";
447 stream << modified.time().hour() <<
" ";
448 stream << modified.time().minute() <<
" ";
449 stream << modified.time().second() <<
" ";
450 stream << modified.time().msec() <<
"</modified>\n";
451 stream <<
" </slideshow>\n";
455 modified = info.lastModified();
456 stream <<
" <thumb>\n";
458 stream <<
" <modified>";
459 stream << modified.date().year() <<
" ";
460 stream << modified.date().month() <<
" ";
461 stream << modified.date().day() <<
" ";
462 stream << modified.time().hour() <<
" ";
463 stream << modified.time().minute() <<
" ";
464 stream << modified.time().second() <<
" ";
465 stream << modified.time().msec() <<
"</modified>\n";
466 stream <<
" </thumb>\n";
468 stream <<
" </photo>\n";
503 QString intermediateName = QString(
"%1_intermdiate.jpg").arg(oldName);
544 origName.compare( newName ) !=0 );
581 tempOrigLocation = tempOrigLocation +
"_orig.jpg";
584 if(tmpDir.exists( tempOrigLocation ) )
585 return tempOrigLocation;
601 if(tmpDir.exists( storedOrigLocation ) )
602 return storedOrigLocation;
604 return lastSavedLocation;
QString getSlideshowChecksum()
Get thumbanil checksum.
QString getImageFilename()
Gets the image filename.
QString originalImageFilename()
orig filename
int initialSubalbumNumber
QString slideshowLocation
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
void revertPhoto()
revert photo to original form
QString imageChecksum
MD5 checksums, used to determine if image/thumbnail have been changed.
QString description
Photo description.
void setInitialSubalbumNumber(int val)
Sets initial subalbum number.
QString getSaveLocation()
Returns the current save location of all images.
void setImageFilename(QString val)
Sets the image filename.
QString getThumbnailFilename()
Gets the thumbnail filename.
void rotate270()
Rotates image clockwise 270 degrees.
bool everSaved
Has the photo ever been saved?
bool getRecentlyReverted()
was the photo recently reverted? if so ignore the presence of orig files on disk
Subalbum * subalbum
Subalbum photo is in.
void exportToXML(Q3TextStream &stream)
Exports photo to xml.
Photo * getNext()
Returns next photo pointer.
Album * getAlbum()
returns the album pointer
bool recentlyReverted
Has the photo recently been reverted to it's original form? If so during the next save the orig file ...
void setRecentlyReverted(bool val)
reset the recently reverted value to val
QString slideshowChecksum
bool setImage(QString imageName, QString slideshowName, QString thumbnailName)
Setup photo using preexisting full size, slideshow, and thumbnail images.
int getInitialSubalbumNumber()
Returns initial subalbum number.
A subalbum contains photos.
void setImageChecksum(QString val)
Update image checksum.
int getInitialPhotoNumber()
Returns initial photo number.
void setDescription(QString val)
Sets the description.
QString thumbnailChecksum
void setSlideshowChecksum(QString val)
Update slideshow checksum.
QImage * getThumbnailImage()
Gets thumbnail image.
void rotate90()
Rotates image clockwise 90 degrees.
void setEverSaved(bool val)
sets everSaved
Photo(Subalbum *subalbum, Photo *prev, int photoNumber)
Sets default information.
void setThumbnailFilename(QString val)
Sets the thumbnail filename.
bool needsSaving
Unsaved modifications?
void setNeedsSavingVal(bool val)
Sets if the image needs to be saved to its permanent location.
QString thumbnailLocation
bool getEverSaved()
Returns if the image has ever been saved to a permanant location.
void setThumbnailChecksum(QString val)
Update thumbnail checksum.
void setSlideshowFilename(QString val)
Sets the slideshow filename.
QDateTime * importFromDisk(QDomNode *root)
Builds photo from XML DOM node, returns date modified info from xml.
bool getNeedsSavingVal()
Returns if the image needs to be saved to its permament location.
QString getSlideshowFilename()
Gets the slideshow filename.
Photo * prev
Pointer to prev photo.
QString getTmpDir()
Returns the temporary directory for use when modifying and adding new images.
Photo * next
Pointer to next photo.
QString imageLocation
Filenames.
QImage * thumbnailImage
Thumbnail Image.
int getSubalbumNumber()
Returns subalbum number.
QString getDescription()
Gets the description.
void applyTransformation(TRANSFORM_CODE transformation)
Apply transformation.
void flipVertically()
Flips image about vertical axis.
void setNext(Photo *val)
Sets next photo pointer.
bool constructSmallerImages()
Construct thumbnail and slideshow images, load up thumbnail image, and set photo has being modified...
void setInitialPhotoNumber(int val)
Sets initial photo number.
Photo * getPrev()
Returns the previous photo pointer.
QString getImageChecksum()
Get image checksum.
QString getThumbnailChecksum()
Get thumbanil checksum.
void setPrev(Photo *val)
Sets prev photo pointer.
void flipHorizontally()
Flips image about horizontal axis.
bool revertPossible()
can photo be reverted to a differnt original form