|
AlbumShaper
1.0a3
|
An album contains Subalbums. More...
#include <album.h>

Public Member Functions | |
| Album (QString tmpDir, bool createSubalbum=true) | |
| Sets default information and create temporary directory as necessary. | |
| ~Album () | |
| Frees Subalbums. | |
| void | setName (QString val) |
| Sets the album name. | |
| QString | getName () |
| Gets the album name. | |
| void | setDescription (QString val) |
| Sets the album description. | |
| QString | getDescription () |
| Gets the album description. | |
| void | setAuthor (QString val) |
| Sets the album author. | |
| QString | getAuthor () |
| Gets the album author. | |
| void | setRepresentativeImages (QString imageFilename) |
| Sets the representative image. | |
| QPixmap * | getRepresentativeImage (int size) |
| Returns the representative image. | |
| Subalbum * | getFirstSubalbum () |
| Returns a pointer to the first Subalbum. | |
| Subalbum * | getLastSubalbum () |
| Returns a pointer to the last Subalbum. | |
| void | appendSubalbum (Subalbum *val) |
| Appends subalbum to end of linked list. | |
| void | removeSubalbum (Subalbum *val) |
| Removes a subalbum. | |
| int | getModificationYear () |
| Returns the last modified year. | |
| int | getModificationMonth () |
| Returns the last modified month. | |
| int | getModificationDay () |
| Returns the last modified day. | |
| int | getCreationYear () |
| Returns the creation year. | |
| int | getCreationMonth () |
| Returns the creation month. | |
| int | getCreationDay () |
| Returnst he creation day. | |
| void | updateCreationDate () |
| Updates the creation date to today's date. | |
| void | updateModificationDate () |
| Updates the modification date to today's date. | |
| int | importFromDisk (StatusWidget *status, QString fileName, bool disableCheckPhotoMods) |
| Imports album from XML format, returning int indicates success or not. | |
| int | exportToDisk (StatusWidget *status, QString dirName, QString themeName) |
| Exports album in XML and HTML format, along with resized images. | |
| int | exportToDisk (StatusWidget *status, bool forceSave=false) |
| Exports album in XML and HTML format, along with resized images, saves all files to the last saved directory, if none set returns. | |
| int | exportCompressedWebAlbum (StatusWidget *status, QString exportLocation, QString exportMessage) |
| Export a compressed web album (excludes full size images and xml data) | |
| int | exportLargeImages (StatusWidget *status, QString exportPath, QString exportMessage) |
| Export fullsize images (excludes slideshow and thumbnail images, album and collection iamges, and html or xml files) | |
| bool | prevSave () |
| Returns true if album previously saved to disk. | |
| bool | albumModified () |
| Returns true if album has been modified since the last save operation. | |
| void | setModified (bool val=true) |
| Sets the album as modified. | |
| void | syncSubalbumList (SubalbumPreviewWidget *item) |
| Syncs subalbum ordering with front end gui ordering. | |
| QString | getSaveLocation () |
| Returns the current save location of all images. | |
| int | getNumPhotos () |
| Returns the number of photos. | |
| int | getNumSubalbums () |
| Returns number of subalbums. | |
| QString | getTheme () |
| Returns currently selected theme. | |
| QString | getTmpDir () |
| Returns the temporary directory for use when modifying and adding new images. | |
| int | getNextUniquePhotoID () |
| Returns the next unique photo id. | |
| QStringList | getThumbnailFilenames () |
| Returns a list of the most up to date thumbnail filesnames. | |
Private Member Functions | |
| int | exportToXML (StatusWidget *status, QString exportPath) |
| Exports album to XML. | |
| void | exportTopLevelImages () |
| Exports top level images. | |
| void | exportSubalbumImages (StatusWidget *status, bool forceSave) |
| Exports subalbum images. | |
| void | removeStagnantOrigFiles (StatusWidget *status) |
| Removes any _orig images for photos which have been recently reverted to their original form (and hence we can reduce disk usage but removing these effective duplicates) | |
| void | reorderSubalbumImages (StatusWidget *status) |
| Checks if images need to be moved and does so if necessary. | |
| void | removeStagnantImages () |
| Removes old stagnant images caused when photos are removed from album or moved from one subalbum to another. | |
| void | exportThemeResources (QString theme) |
| Removes previously saved resources, copies over new resources. | |
Private Attributes | |
| QString | name |
| Short name for album. | |
| QString | description |
| Longer description of album. | |
| QString | author |
| Album Creator. | |
| QPixmap * | smallRepresentativeImage |
| Representative images. | |
| QPixmap * | largeRepresentativeImage |
| Subalbum * | firstSubalbum |
| Pointer to first Subalbum. | |
| Subalbum * | lastSubalbum |
| Pointer to last Subalbum. | |
| int | modificationYear |
| Last modification year. | |
| int | modificationMonth |
| Last modification month. | |
| int | modificationDay |
| Last modification day. | |
| int | creationYear |
| Creation year. | |
| int | creationMonth |
| Creation month. | |
| int | creationDay |
| Creation day. | |
| int | numSubalbums |
| Number of subalbums. | |
| int | numLoadedSubalbums |
| Number of loaded subalbums. | |
| bool | savedToDisk |
| Set if album was loaded/has been saved to disk. | |
| QString | saveLocation |
| Directory album saved to. | |
| QString | oldSaveLocation |
| QString | theme |
| Theme to save album with. | |
| bool | modified |
| Modification status of the album. | |
| QString | tmpDir |
| Temporary directory for placing modified or new images before saving takes place. | |
| int | nextUniqueID |
| Next Unique ID for new photos. | |
An album contains Subalbums.
Specific contents:
| Album::Album | ( | QString | tmpDir, |
| bool | createSubalbum = true |
||
| ) |
Sets default information and create temporary directory as necessary.
Sets default information.
Definition at line 41 of file album.cpp.
References appendSubalbum(), author, description, firstSubalbum, getTmpDir(), largeRepresentativeImage, lastSubalbum, modified, name, nextUniqueID, numLoadedSubalbums, numSubalbums, savedToDisk, saveLocation, smallRepresentativeImage, theme, tmpDir, updateCreationDate(), and updateModificationDate().
{
//set strings to default values
name = "";
description ="";
author = "";
theme = "Slick";
this->tmpDir = tmpDir;
//by default no representative image
smallRepresentativeImage = NULL;
largeRepresentativeImage = NULL;
//no Subalbums by default
firstSubalbum = NULL;
lastSubalbum = NULL;
//set the creation/modification date to today
updateCreationDate();
updateModificationDate();
//no subalbums
numSubalbums = 0;
numLoadedSubalbums = 0;
//not previously saved by default
savedToDisk = false;
//set default save location (where images are placed before saving) to the tmp directory
saveLocation = getTmpDir();
if(createSubalbum)
{
Subalbum* s = new Subalbum( this, 1 );
appendSubalbum( s );
}
//no interesting modifications yet
modified = false;
nextUniqueID = 0;
}
| Album::~Album | ( | ) |
Frees Subalbums.
Definition at line 84 of file album.cpp.
References firstSubalbum, Subalbum::getNext(), largeRepresentativeImage, smallRepresentativeImage, and tmpDir.
{
//delete representative image
delete smallRepresentativeImage;
delete largeRepresentativeImage;
//delete subalbums
Subalbum* current = firstSubalbum;
Subalbum* temp;
while(current != NULL)
{
temp = current->getNext();
delete current;
current = temp;
}
//remove all old tmp dir contents and directory itself
if(!tmpDir.isNull())
{
QDir oldTmpDir(tmpDir);
QString tmpDirName = oldTmpDir.dirName();
QStringList strLst = oldTmpDir.entryList();
QStringList::iterator it;
for(it = strLst.begin(); it != strLst.end(); it++)
{
oldTmpDir.remove(tmpDir + "/" + *it);
}
oldTmpDir.cdUp();
oldTmpDir.rmdir( tmpDirName );
}
}
| bool Album::albumModified | ( | ) |
Returns true if album has been modified since the last save operation.
Definition at line 139 of file album.cpp.
References modified.
Referenced by Window::closeEvent(), TitleWidget::newAlbum(), TitleWidget::proceedWithLoad(), and TitleWidget::revertToSaved().
{ return modified; }
| void Album::appendSubalbum | ( | Subalbum * | val | ) |
Appends subalbum to end of linked list.
Definition at line 234 of file album.cpp.
References firstSubalbum, lastSubalbum, modified, numSubalbums, Subalbum::setNext(), and Subalbum::setPrev().
Referenced by Album(), SubalbumsWidget::createAction(), and importFromDisk().
{
//if passed a null pointer bail!
if( val == NULL) return;
//empty list - stick on front
if(firstSubalbum == NULL)
{
firstSubalbum = val;
lastSubalbum = val;
}
//else - append to end
else
{
lastSubalbum->setNext( val );
val->setPrev( lastSubalbum );
lastSubalbum = val;
}
numSubalbums++;
modified = true;
}
| int Album::exportCompressedWebAlbum | ( | StatusWidget * | status, |
| QString | exportLocation, | ||
| QString | exportMessage | ||
| ) |
Export a compressed web album (excludes full size images and xml data)
Definition at line 616 of file album.cpp.
References ALBUM_EXPORTED, copyFile(), exportToXML(), firstSubalbum, Subalbum::getFirst(), Subalbum::getNext(), Photo::getNext(), getNumPhotos(), Subalbum::getRepresentativeImage(), getRepresentativeImage(), Photo::getSlideshowFilename(), Photo::getThumbnailFilename(), LARGE, theme, THEMES_PATH, transformXMLtoHTML(), and StatusWidget::updateProgress().
Referenced by TitleWidget::exportSmallWebGallery().
{
//------------------------------------------
//copy all images
QDir localDir(exportLocation);
localDir.mkdir("img");
localDir.setPath(exportLocation + "/img");
//copy album image
if(getRepresentativeImage(LARGE) != NULL)
{ getRepresentativeImage(LARGE)->save(exportLocation + "/img/album.jpg", "JPEG", 95); }
else
{ localDir.remove(exportLocation + "/img/album.jpg"); }
int numPhotos = getNumPhotos();
int photosLeft = numPhotos;
int updateInverval = numPhotos / 50;
int updateCount = 0;
//iterate over each collection
Subalbum* curCollection = firstSubalbum;
int collectionNum=1;
while(curCollection != NULL)
{
QString collectionDir = QString("%1").arg( collectionNum );
localDir.mkdir( collectionDir );
//copy collection image
QString collectionThumbFilename = QString(exportLocation + "/img/%1_thumb.jpg" ).arg(collectionNum);
if(curCollection->getRepresentativeImage(LARGE) != NULL )
{ curCollection->getRepresentativeImage(LARGE)->save( collectionThumbFilename, "JPEG", 95); }
else
{ localDir.remove( collectionThumbFilename ); }
//copy each photo
Photo* curPhoto = curCollection->getFirst();
int photoNum = 1;
while(curPhoto != NULL)
{
//update status message
status->updateProgress( numPhotos - photosLeft, exportMessage.arg( photosLeft ) );
//make sure events are processed every 2% of the photos that are processes
updateCount++;
if(updateCount > updateInverval)
{
updateCount = 0;
qApp->processEvents();
}
//copy files
QString newFilePath = QDir::convertSeparators( exportLocation + "/img/" +
collectionDir + "/" +
QString("%1").arg(photoNum) );
copyFile( curPhoto->getSlideshowFilename(), newFilePath + "_slideshow.jpg" );
copyFile( curPhoto->getThumbnailFilename(), newFilePath + "_thumb.jpg" );
curPhoto = curPhoto->getNext();
photoNum++;
photosLeft--;
}
curCollection = curCollection->getNext();
collectionNum++;
}
//------------------------------------------
//copy theme resources
QStringList fileList;
QStringList::Iterator file;
//create HTML and misc resources directories
localDir.setPath(exportLocation);
localDir.mkdir("resources");
//remove all files in these directories from previous saves with other themes
localDir.setPath(exportLocation + "/resources");
fileList = localDir.entryList( QDir::Files );
for ( file = fileList.begin(); file != fileList.end(); ++file )
{ localDir.remove( exportLocation + "/resources/" + *file ); }
//copy files over from theme's directory
localDir.setPath(THEMES_PATH + theme + "/resources");
fileList = localDir.entryList( QDir::Files );
for ( file = fileList.begin(); file != fileList.end(); ++file )
{ copyFile( THEMES_PATH + theme + "/resources/" + *file, exportLocation + "/resources/" + *file); }
//------------------------------------------
//export xml file
exportToXML(status, exportLocation);
//------------------------------------------
//remove previous html/htm files
localDir.setPath(exportLocation);
fileList = localDir.entryList( QDir::Files );
for ( file = fileList.begin(); file != fileList.end(); ++file )
{
if( (*file).endsWith(".html") || (*file).endsWith(".htm") )
localDir.remove( exportLocation + "/" + *file );
}
//------------------------------------------
//construct html files
transformXMLtoHTML( exportLocation, theme, true );
//------------------------------------------
//remove xml file
localDir.remove( exportLocation + "/Album.xml" );
//------------------------------------------
return ALBUM_EXPORTED;
}
| int Album::exportLargeImages | ( | StatusWidget * | status, |
| QString | exportPath, | ||
| QString | exportMessage | ||
| ) |
Export fullsize images (excludes slideshow and thumbnail images, album and collection iamges, and html or xml files)
Definition at line 726 of file album.cpp.
References ALBUM_EXPORTED, copyFile(), Subalbum::getFirst(), getFirstSubalbum(), Photo::getImageFilename(), Subalbum::getNext(), Photo::getNext(), Subalbum::getNumPhotos(), getNumPhotos(), getNumSubalbums(), and StatusWidget::updateProgress().
Referenced by TitleWidget::exportLargeImages().
{
//determine number of digits collecion # requires
uint collectionDigits = (uint) (1 + log( (double) getNumSubalbums() ) / log( 10.0 ) );
//determine number of digits photo # requires, this
//involves walking through the album and finding the collection with the most phots first
int mostPhotos = 0;
Subalbum* curCollection = getFirstSubalbum();
while(curCollection != NULL )
{
mostPhotos = QMAX( mostPhotos, curCollection->getNumPhotos() );
curCollection = curCollection->getNext();
}
uint photoDigits = (uint) ( 1 + log( (double) mostPhotos ) / log( 10.0 ) );
//------------
//copy files
int numPhotos = getNumPhotos();
int photosLeft = numPhotos;
int collectionNum = 1;
curCollection = getFirstSubalbum();
int updateInverval = numPhotos / 50;
int updateCount = 0;
while(curCollection != NULL )
{
//construct collection string
QString collectionString = QString("%1").arg(collectionNum);
while(collectionString.length() < collectionDigits)
{ collectionString = "0" + collectionString; }
//copy all photos in collection
int photoNum = 1;
Photo* curPhoto = curCollection->getFirst();
while(curPhoto != NULL)
{
//update status message
status->updateProgress( numPhotos - photosLeft, exportMessage.arg( photosLeft ) );
//make sure events are processed every 2% of the photos that are processes
updateCount++;
if(updateCount > updateInverval)
{
updateCount = 0;
qApp->processEvents();
}
//construct photo string
QString photoString = QString("%1").arg(photoNum);
while(photoString.length() < photoDigits)
{ photoString = "0" + photoString; }
//construct new photo path
QString newFilePath = QDir::convertSeparators( exportPath + "/" + collectionString +
"_" + photoString + ".jpg" );
//copy file
copyFile( curPhoto->getImageFilename(), newFilePath );
//move on to next file
photosLeft--;
curPhoto = curPhoto->getNext();
photoNum++;
} //while photo
//move on to next collection
curCollection = curCollection->getNext();
collectionNum++;
}// while collection
//------------
return ALBUM_EXPORTED;
}
| void Album::exportSubalbumImages | ( | StatusWidget * | status, |
| bool | forceSave | ||
| ) | [private] |
Exports subalbum images.
Before we move the file we must be sure to preserve the photos original format. if the photo was not recently reverted (if it was then we're saving out the original form so no need to backup) and the file has previously been saved and an orig file does not exist, we better backup the previously saved version quick
If a photo has never been saved before, make sure to also move over any orig file if one exists. The presence of such a file indicates a photo was modified before it was ever saved, but the original form has been preseved and should be backed up at this time to allow a user to revert to the photos original form in the future.
ok, now it's safe to move over currrent version of the photo
----
----
Definition at line 889 of file album.cpp.
References copyFile(), firstSubalbum, Photo::getEverSaved(), Subalbum::getFirst(), Photo::getImageFilename(), Photo::getInitialPhotoNumber(), Photo::getInitialSubalbumNumber(), getMD5(), Photo::getNeedsSavingVal(), Subalbum::getNext(), Photo::getNext(), Photo::getRecentlyReverted(), Photo::getSlideshowFilename(), Photo::getThumbnailFilename(), getTmpDir(), StatusWidget::incrementProgress(), moveFile(), oldSaveLocation, saveLocation, Photo::setEverSaved(), Photo::setImageChecksum(), Photo::setImageFilename(), Photo::setNeedsSavingVal(), Photo::setSlideshowChecksum(), Photo::setSlideshowFilename(), Photo::setThumbnailChecksum(), Photo::setThumbnailFilename(), and tmpDir.
Referenced by exportToDisk().
{
//iterate over all subalbums
int subalbumNumber=0;
Subalbum* currentSubalbum = firstSubalbum;
while(currentSubalbum != NULL)
{
subalbumNumber++;
//iterate over all photos in this subalbum
int photoNumber=0;
Photo* currentPhoto = currentSubalbum->getFirst();
while(currentPhoto != NULL)
{
photoNumber++;
//---------------------------------------
//if the current photo does not need to be saved then move on
if( !forceSave && !currentPhoto->getNeedsSavingVal() )
{
currentPhoto = currentPhoto->getNext();
status->incrementProgress();
qApp->processEvents();
continue;
}
//---------------------------------------
//get initial photo # and subalbum #, used for saving
int initPhotoNumber = currentPhoto->getInitialPhotoNumber();
int initSubalbumNumber = currentPhoto->getInitialSubalbumNumber();
//---------------------------------------
//export thumbnail image
QString oldName = currentPhoto->getThumbnailFilename();
QString newName = QString(saveLocation + "/img/%1/%2_thumb.jpg" )
.arg(initSubalbumNumber).arg(initPhotoNumber);
//if file has been modified move from current location to final location
if( currentPhoto->getNeedsSavingVal() ) { moveFile( oldName, newName ); }
//If file has not been modified we must be doing a save-as and saving has been forced. In this case
//COPY file from current location to final location, DON'T delete previous copy!!!
else { copyFile(oldName, newName); }
//compute and store md5 for slideshow image
std::ifstream thumbnailFile( QFile::encodeName(newName) );
if(thumbnailFile.is_open())
{
currentPhoto->setThumbnailChecksum( getMD5(thumbnailFile) );
thumbnailFile.close();
}
//---------------------------------------
//export slideshow image
oldName = currentPhoto->getSlideshowFilename();
newName = QString(saveLocation + "/img/%1/%2_slideshow.jpg" )
.arg(initSubalbumNumber).arg(initPhotoNumber);
//if file has been modified move from current location to final location
if( currentPhoto->getNeedsSavingVal() ) { moveFile( oldName, newName ); }
//If file has not been modified we must be doing a save-as and saving has been forced. In this case
//COPY file from current location to final location, DON'T delete previous copy!!!
else { copyFile(oldName, newName); }
//compute and store md5 for slideshow image
std::ifstream slideshowFile( QFile::encodeName(newName) );
if(slideshowFile.is_open())
{
currentPhoto->setSlideshowChecksum( getMD5(slideshowFile) );
slideshowFile.close();
}
//---------------------------------------
//export full size image
oldName = currentPhoto->getImageFilename();
newName = QString(saveLocation + "/img/%1/%2.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
//if file has been modified move from current location to final location
if( currentPhoto->getNeedsSavingVal() )
{
QString tempOrigName = getTmpDir() + QString("/%1_%2_orig.jpg")
.arg(initSubalbumNumber).arg(initPhotoNumber);
QString finalOrigName = QString(saveLocation + "/img/%1/%2_orig.jpg" )
.arg(initSubalbumNumber).arg(initPhotoNumber);
QDir tmpDir;
if( !currentPhoto->getRecentlyReverted() &&
tmpDir.exists(newName) &&
!tmpDir.exists(finalOrigName) )
{
moveFile( newName, finalOrigName );
}
//if photo previously saved, there is no orig file, but the photo
//is modified and we're doing a force save than make sure to copy
//over the original as well even though it's not an orig file
else if ( currentPhoto->getEverSaved() &&
currentPhoto->getNeedsSavingVal() &&
forceSave &&
saveLocation.compare( oldSaveLocation ) != 0 )
{
QString storedOrigLocation = oldSaveLocation +
QString("/img/%1/%2_orig.jpg").arg(currentPhoto->getInitialSubalbumNumber())
.arg(currentPhoto->getInitialPhotoNumber());
QString storedLocation = oldSaveLocation +
QString("/img/%1/%2.jpg").arg(currentPhoto->getInitialSubalbumNumber())
.arg(currentPhoto->getInitialPhotoNumber());
if( tmpDir.exists(storedOrigLocation) )
copyFile( storedOrigLocation, finalOrigName );
else if( tmpDir.exists(storedLocation) )
copyFile( storedLocation, finalOrigName );
}
else if( !currentPhoto->getRecentlyReverted() &&
!tmpDir.exists(newName) &&
tmpDir.exists(tempOrigName) )
{
moveFile( tempOrigName, finalOrigName );
}
moveFile( oldName, newName );
}
//If file does not need to be saved a force save is taking place. This occurs when a user chooses
//save as and copies an entire album to a different location so all files must be copied. Make
//sure to copy over the original form of the photo as well if this file exists
else
{
//copy current image
copyFile( oldName, newName );
//if orig file exists copy it too
QDir tmpDir;
QString tempOrigName = getTmpDir() + QString("/%1_%2_orig.jpg")
.arg(initSubalbumNumber).arg(initPhotoNumber);
QString curOrigName = currentPhoto->getImageFilename();
curOrigName.truncate( curOrigName.length() - 4 );
curOrigName = curOrigName + "_orig.jpg";
QString finalOrigName = QString(saveLocation + "/img/%1/%2_orig.jpg" )
.arg(initSubalbumNumber).arg(initPhotoNumber);
//if the photo was recently reverted ignore the presence of orig files
if( !currentPhoto->getRecentlyReverted() )
{
//if the photo was never previously saved and an orig file
//exists in the tmp directory make sure to copy it over
if( !currentPhoto->getEverSaved() &&
tmpDir.exists( tempOrigName ) )
{
copyFile( tempOrigName, finalOrigName );
}
//if the photo was previously saved and an orig file exists
//in the previous save location make sure to copy it over
else if( currentPhoto->getEverSaved() &&
tmpDir.exists( curOrigName ) )
{
copyFile( curOrigName, finalOrigName );
}
}
}
//---------------------------------------
//compute and store md5 for image
std::ifstream imageFile( QFile::encodeName(newName) );
if(imageFile.is_open())
{
currentPhoto->setImageChecksum( getMD5(imageFile) );
imageFile.close();
}
//---------------------------------------
//set new storage locations of files
currentPhoto->setImageFilename
( QString(saveLocation + "/img/%1/%2.jpg").arg(initSubalbumNumber).arg(initPhotoNumber) );
currentPhoto->setSlideshowFilename
( QString(saveLocation + "/img/%1/%2_slideshow.jpg").arg(initSubalbumNumber).arg(initPhotoNumber) );
currentPhoto->setThumbnailFilename
( QString(saveLocation + "/img/%1/%2_thumb.jpg").arg(initSubalbumNumber).arg(initPhotoNumber) );
//---------------------------------------
//set image as not needing saving and as being saved
currentPhoto->setNeedsSavingVal(false);
currentPhoto->setEverSaved(true);
//---------------------------------------
//update progress bar
status->incrementProgress();
qApp->processEvents();
//---------------------------------------
//move on to next photo in subalbum
currentPhoto = currentPhoto->getNext();
//---------------------------------------
}
//---------------------------------------
//move on to next subalbum
currentSubalbum = currentSubalbum->getNext();
}
}
| void Album::exportThemeResources | ( | QString | theme | ) | [private] |
Removes previously saved resources, copies over new resources.
Definition at line 1322 of file album.cpp.
References copyFile(), saveLocation, and THEMES_PATH.
Referenced by exportToDisk().
{
QStringList fileList;
QStringList::Iterator file;
QDir localDir;
//remove any "resources" directories created by 1.0* versions of Album Shaper
localDir.setPath( saveLocation + "/resources" );
fileList = localDir.entryList();
for(file = fileList.begin(); file != fileList.end(); file++)
{
localDir.remove(saveLocation + "/resources/" + *file);
}
localDir.cdUp();
localDir.rmdir( "resources" );
//create HTML and misc resources directories
localDir.setPath(saveLocation);
localDir.mkdir("resources");
// localDir.mkdir("misc_resources");
//remove all files in these directories from previous saves with other themes
localDir.setPath(saveLocation + "/resources");
fileList = localDir.entryList( QDir::Files );
for ( file = fileList.begin(); file != fileList.end(); ++file )
{ localDir.remove( saveLocation + "/resources/" + *file ); }
//--
/*
localDir.setPath(saveLocation + "/misc_resources");
fileList = localDir.entryList( QDir::Files );
for ( file = fileList.begin(); file != fileList.end(); ++file )
{ localDir.remove( saveLocation + "/misc_resources/" + *file ); }
*/
//copy files over from theme's directory
localDir.setPath(THEMES_PATH + theme + "/resources");
fileList = localDir.entryList( QDir::Files );
for ( file = fileList.begin(); file != fileList.end(); ++file )
{ copyFile( THEMES_PATH + theme + "/resources/" + *file, saveLocation + "/resources/" + *file); }
//--
/*
localDir.setPath(THEMES_PATH + theme + "/misc_resources");
fileList = localDir.entryList( QDir::Files );
for ( file = fileList.begin(); file != fileList.end(); ++file )
{ copyFile( THEMES_PATH + theme + "/misc_resources/" + *file, saveLocation + "/misc_resources/" + *file); }
*/
}
| int Album::exportToDisk | ( | StatusWidget * | status, |
| QString | dirName, | ||
| QString | themeName | ||
| ) |
Exports album in XML and HTML format, along with resized images.
Definition at line 452 of file album.cpp.
References ALBUM_EXPORTED, nextUniqueID, oldSaveLocation, saveLocation, theme, and tmpDir.
Referenced by TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum().
{
//check to see if save location has actually changed, if not don't force save images
//this occurs when user blindly selects the same old spot, or is just changing the theme used by default
bool forceSave = true;
if(saveLocation == dirName)
forceSave = false;
//backup theme and save location, if save fails revert to previous values
oldSaveLocation = saveLocation;
QString oldTheme = theme;
//attempt to save album
saveLocation = dirName;
theme = themeName;
int result = exportToDisk(status, forceSave);
//if album saving failed revert save location and theme
if(result != ALBUM_EXPORTED)
{
saveLocation = oldSaveLocation;
theme = oldTheme;
}
//else update tmp save dir
else
{
//remove all old tmp dir contents and directory itself
QDir oldTmpDir(tmpDir);
QString tmpDirName = oldTmpDir.dirName();
QStringList strLst = oldTmpDir.entryList();
QStringList::iterator it;
for(it = strLst.begin(); it != strLst.end(); it++)
{
oldTmpDir.remove( tmpDir + "/" + *it);
}
oldTmpDir.cdUp();
oldTmpDir.rmdir( tmpDirName );
//create and set new temp dir location
QDir saveDir( saveLocation );
if(!saveDir.exists( "tmp" ))
saveDir.mkdir( "tmp" );
tmpDir = saveLocation + "/tmp";
//reset unique id counter
nextUniqueID = 0;
}
//return result
return result;
}
| int Album::exportToDisk | ( | StatusWidget * | status, |
| bool | forceSave = false |
||
| ) |
Exports album in XML and HTML format, along with resized images, saves all files to the last saved directory, if none set returns.
Definition at line 506 of file album.cpp.
References ALBUM_EXPORTED, exportSubalbumImages(), exportThemeResources(), exportTopLevelImages(), exportToXML(), firstSubalbum, Subalbum::getNext(), Subalbum::getNumPhotos(), getTmpDir(), modified, removeStagnantImages(), removeStagnantOrigFiles(), reorderSubalbumImages(), savedToDisk, saveLocation, StatusWidget::setStatus(), Subalbum::setSubalbumNumber(), StatusWidget::showProgressBar(), theme, and transformXMLtoHTML().
{
//------------------------------------------
//create subdirs
QDir localDir(saveLocation);
//img dirs
localDir.mkdir("img");
//subalbum dirs
localDir.setPath(saveLocation + "/img");
//make a temporary 0 directory for copying new images, they'll be moved to their final
//location during the reordering step
localDir.mkdir( "0" );
//iterate over each subalbum and create its image directory
Subalbum* current = firstSubalbum;
int collectionNum = 0;
while(current != NULL)
{
collectionNum++;
QString dirName = QString("%1") .arg( collectionNum );
localDir.mkdir(dirName);
current = current->getNext();
}
//------------------------------------------
//checks worked, go ahead with export
//count number of photos
int totalPhotos=0;
current = firstSubalbum;
while(current != NULL)
{
totalPhotos+=current->getNumPhotos();
current = current->getNext();
}
//setup progress bar
status->showProgressBar( StatusWidget::tr("Saving:"), 4*totalPhotos );
qApp->processEvents();
//copy over theme resources
exportThemeResources( theme );
//export album cover image, subalbum thumbnails
exportTopLevelImages();
//export subalbum images (thumbnail, slideshow, and full versions of all images)
exportSubalbumImages(status, forceSave);
//remove any _orig images for photos which have been reverted to their original form
removeStagnantOrigFiles(status);
//apply reordering to all images
reorderSubalbumImages(status);
//reset subalbum numbers to current ordering
current = firstSubalbum;
int n=0;
while(current !=NULL)
{
n++;
current->setSubalbumNumber(n);
current = current->getNext();
}
//remove collection 0 directory
QDir rootDir(saveLocation + "/img/");
rootDir.rmdir( "0" );
//remove old images that nolonger belong
removeStagnantImages();
//remove previous html/htm files
localDir.setPath(saveLocation);
QStringList list = localDir.entryList( QDir::Files );
QStringList::Iterator file;
for ( file = list.begin(); file != list.end(); ++file )
{
if( (*file).endsWith(".html") || (*file).endsWith(".htm") )
localDir.remove( saveLocation + "/" + *file );
}
//export xml structure of album
int result = exportToXML(status, saveLocation);
if(result != ALBUM_EXPORTED) { return result; }
//export various html pages using selected theme
transformXMLtoHTML( saveLocation, theme, false );
//------------------------------------------
//remove files from temp folder
QDir tmpDirHandle( getTmpDir() );
QStringList strLst = tmpDirHandle.entryList();
QStringList::iterator it;
for(it = strLst.begin(); it != strLst.end(); it++)
{
tmpDirHandle.remove( getTmpDir() + "/" + *it);
}
//------------------------------------------
savedToDisk = true;
//just saved so no modifications since last save
modified = false;
//hide progress bar
status->setStatus( qApp->translate("Album", "Album saved.") );
//------------------------------------------
return ALBUM_EXPORTED;
}
| void Album::exportTopLevelImages | ( | ) | [private] |
Exports top level images.
Definition at line 853 of file album.cpp.
References firstSubalbum, Subalbum::getNext(), Subalbum::getRepresentativeImage(), getRepresentativeImage(), LARGE, and saveLocation.
Referenced by exportToDisk().
{
//if image set export it
if(getRepresentativeImage(LARGE) != NULL)
{
getRepresentativeImage(LARGE)->save(saveLocation + "/img/album.jpg", "JPEG", 95);
}
//else make sure any previously set images are removed
else
{
QDir rootDir(saveLocation + "/img/");
rootDir.remove(saveLocation + "/img/album.jpg");
}
//export subalbum thumbs
int n=0;
Subalbum* current = firstSubalbum;
while(current != NULL)
{
n++;
//if subalbum has representative image export it
if(current->getRepresentativeImage(LARGE) != NULL )
{
QString fileName = QString(saveLocation + "/img/%1_thumb.jpg" ).arg(n);
current->getRepresentativeImage(LARGE)->save(fileName, "JPEG", 95);
}
//otherwise make sure anyprevious set images are removed
else
{
QDir rootDir(saveLocation + "/img/");
rootDir.remove( saveLocation + QString("/img/%1_thumb.jpg").arg(n) );
}
current = current->getNext();
}
}
| int Album::exportToXML | ( | StatusWidget * | status, |
| QString | exportPath | ||
| ) | [private] |
Exports album to XML.
Definition at line 801 of file album.cpp.
References ALBUM_ERROR_OPEN_FILE, ALBUM_EXPORTED, author, creationDay, creationMonth, creationYear, description, Subalbum::exportToXML(), firstSubalbum, fixXMLString(), Subalbum::getNext(), getRepresentativeImage(), LARGE, modificationDay, modificationMonth, modificationYear, name, SLIDESHOW_HEIGHT, SLIDESHOW_WIDTH, theme, THUMBNAIL_HEIGHT, THUMBNAIL_WIDTH, and updateModificationDate().
Referenced by exportCompressedWebAlbum(), and exportToDisk().
{
//update modification date
updateModificationDate();
//create/open xml file
QFile file( exportPath + "/Album.xml" );
if(file.open(IO_WriteOnly))
{
//-----
QTextStream stream;
stream.setDevice( &file );
stream.setEncoding( QTextStream::UnicodeUTF8 );
//write album information
stream << "<?xml version=\"1.0\"?>\n";
stream << "<album version=\"1.1\">\n";
stream << " <name>" << fixXMLString(name) << "</name>\n";
stream << " <description>" << fixXMLString(description) << "</description>\n";
stream << " <author>" << fixXMLString(author) << "</author>\n";
stream << " <created>" << creationYear << " " << creationMonth << " " << creationDay << "</created>\n";
stream << " <modified>" << modificationYear << " " << modificationMonth << " " << modificationDay << "</modified>\n";
stream << " <theme>" << theme << "</theme>\n";
stream << " <thumbnailDimensions>" << THUMBNAIL_WIDTH << " " << THUMBNAIL_HEIGHT << "</thumbnailDimensions>\n";
stream << " <slideshowDimensions>" << SLIDESHOW_WIDTH << " " << SLIDESHOW_HEIGHT << "</slideshowDimensions>\n";
//if album has a represenatative image save it's path
if(getRepresentativeImage(LARGE) != NULL )
{
stream << " <thumb path=\"img/album.jpg\"/>\n";
}
//write subalbums
Subalbum* current = firstSubalbum;
while(current != NULL)
{
current->exportToXML(status, stream);
current = current->getNext();
}
//end album
stream << "</album>\n";
file.close();
return ALBUM_EXPORTED;
}
else
{
return ALBUM_ERROR_OPEN_FILE;
}
}
| QString Album::getAuthor | ( | ) |
Gets the album author.
Definition at line 126 of file album.cpp.
References author.
Referenced by TitleWidget::updateAlbumAnnotations().
{ return QString(author); }
| int Album::getCreationDay | ( | ) |
Returnst he creation day.
Definition at line 122 of file album.cpp.
References creationDay.
Referenced by AlbumStatistics::AlbumStatistics().
{ return creationDay; }
| int Album::getCreationMonth | ( | ) |
Returns the creation month.
Definition at line 121 of file album.cpp.
References creationMonth.
Referenced by AlbumStatistics::AlbumStatistics().
{ return creationMonth; }
| int Album::getCreationYear | ( | ) |
Returns the creation year.
Definition at line 120 of file album.cpp.
References creationYear.
Referenced by AlbumStatistics::AlbumStatistics().
{ return creationYear; }
| QString Album::getDescription | ( | ) |
Gets the album description.
Definition at line 125 of file album.cpp.
References description.
Referenced by TitleWidget::updateAlbumAnnotations().
{ return QString(description); }
| Subalbum * Album::getFirstSubalbum | ( | ) |
Returns a pointer to the first Subalbum.
Definition at line 135 of file album.cpp.
References firstSubalbum.
Referenced by SlideshowWidget::advanceCollection(), AlbumStatistics::AlbumStatistics(), SlideshowWidget::beginSlideshow(), exportLargeImages(), TitleWidget::loadAlbum(), SubalbumsWidget::refreshCollectionsList(), and SlideshowWidget::showCoverPage().
{ return firstSubalbum; }
| Subalbum * Album::getLastSubalbum | ( | ) |
Returns a pointer to the last Subalbum.
Definition at line 136 of file album.cpp.
References lastSubalbum.
Referenced by SlideshowWidget::backupCollection().
{ return lastSubalbum; }
| int Album::getModificationDay | ( | ) |
Returns the last modified day.
Definition at line 118 of file album.cpp.
References modificationDay.
Referenced by AlbumStatistics::AlbumStatistics().
{ return modificationDay; }
| int Album::getModificationMonth | ( | ) |
Returns the last modified month.
Definition at line 117 of file album.cpp.
References modificationMonth.
Referenced by AlbumStatistics::AlbumStatistics().
{ return modificationMonth; }
| int Album::getModificationYear | ( | ) |
Returns the last modified year.
Definition at line 116 of file album.cpp.
References modificationYear.
Referenced by AlbumStatistics::AlbumStatistics().
{ return modificationYear; }
| QString Album::getName | ( | ) |
Gets the album name.
Definition at line 124 of file album.cpp.
References name.
Referenced by AlbumStatistics::AlbumStatistics(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), TitleWidget::saveAlbum(), TitleWidget::saveAsAlbum(), and TitleWidget::updateAlbumAnnotations().
{ return QString(name); }
| int Album::getNextUniquePhotoID | ( | ) |
Returns the next unique photo id.
Definition at line 1420 of file album.cpp.
References nextUniqueID.
Referenced by Subalbum::addPhoto().
{
nextUniqueID++;
return nextUniqueID;
}
| int Album::getNumPhotos | ( | ) |
Returns the number of photos.
Definition at line 146 of file album.cpp.
References firstSubalbum, Subalbum::getNext(), and Subalbum::getNumPhotos().
Referenced by AlbumStatistics::AlbumStatistics(), exportCompressedWebAlbum(), exportLargeImages(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum().
{
//compute number of photos and size on disk
int numPhotos = 0;
Subalbum* curr = firstSubalbum;
while(curr != NULL)
{
numPhotos+= curr->getNumPhotos();
curr = curr->getNext();
}
return numPhotos;
}
| int Album::getNumSubalbums | ( | ) |
Returns number of subalbums.
Definition at line 144 of file album.cpp.
References numSubalbums.
Referenced by AlbumStatistics::AlbumStatistics(), SlideshowWidget::backupCollection(), SubalbumsWidget::createAction(), exportLargeImages(), and SlideshowWidget::paintOverlaidControls().
{ return numSubalbums; }
| QPixmap * Album::getRepresentativeImage | ( | int | size | ) |
Returns the representative image.
Definition at line 128 of file album.cpp.
References LARGE, largeRepresentativeImage, SMALL, and smallRepresentativeImage.
Referenced by AlbumStatistics::AlbumStatistics(), exportCompressedWebAlbum(), exportTopLevelImages(), exportToXML(), TitleWidget::setAlbumImage(), and TitleWidget::updateAlbumAnnotations().
{
if(size == SMALL) return smallRepresentativeImage;
else if(size == LARGE) return largeRepresentativeImage;
else return NULL;
}
| QString Album::getSaveLocation | ( | ) |
Returns the current save location of all images.
Definition at line 141 of file album.cpp.
References saveLocation.
Referenced by SlideshowWidget::beginSlideshow(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), Photo::originalImageFilename(), TitleWidget::revertToSaved(), TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum().
{ return saveLocation; }
| QString Album::getTheme | ( | ) |
Returns currently selected theme.
Definition at line 143 of file album.cpp.
References theme.
Referenced by SlideshowWidget::beginSlideshow(), and TitleWidget::saveAsAlbum().
{ return theme; }
| QStringList Album::getThumbnailFilenames | ( | ) |
Returns a list of the most up to date thumbnail filesnames.
Definition at line 1426 of file album.cpp.
References firstSubalbum, Subalbum::getFirst(), Subalbum::getNext(), Photo::getNext(), and Photo::getThumbnailFilename().
Referenced by MosaicOptionsDialog::determineFilesList().
{
//iterate over all collections
QStringList thumbnailList;
Subalbum* currCollection = firstSubalbum;
while(currCollection != NULL)
{
//iterate over all photos
Photo* currPhoto = currCollection->getFirst();
while( currPhoto != NULL )
{
thumbnailList.append( currPhoto->getThumbnailFilename() );
currPhoto = currPhoto->getNext();
}
currCollection = currCollection->getNext();
}
return thumbnailList;
}
| QString Album::getTmpDir | ( | ) |
Returns the temporary directory for use when modifying and adding new images.
Definition at line 142 of file album.cpp.
References tmpDir.
Referenced by Album(), Photo::applyTransformation(), exportSubalbumImages(), exportToDisk(), TitleWidget::loadAlbum(), TitleWidget::newAlbum(), Photo::setImage(), and TitleWidget::TitleWidget().
{ return tmpDir; }
| int Album::importFromDisk | ( | StatusWidget * | status, |
| QString | fileName, | ||
| bool | disableCheckPhotoMods | ||
| ) |
Imports album from XML format, returning int indicates success or not.
Definition at line 295 of file album.cpp.
References ALBUM_LOADED, ALBUM_READ_ERROR, ALBUM_XML_ERROR, appendSubalbum(), author, creationDay, creationMonth, creationYear, description, Subalbum::importFromDisk(), name, numLoadedSubalbums, numSubalbums, savedToDisk, saveLocation, setRepresentativeImages(), StatusWidget::setStatus(), StatusWidget::showProgressBar(), theme, and updateXML().
Referenced by TitleWidget::loadAlbum().
{
//update file
updateXML( QFileInfo(fileName).dirPath(TRUE) );
//open file
QFile albumFile( fileName );
//unable to open xml file? alert user
if( !albumFile.open( IO_ReadOnly ) )
return ALBUM_READ_ERROR;
//parse dom
QDomDocument albumDom;
if( !albumDom.setContent( &albumFile ) )
return ALBUM_XML_ERROR;
//close file
albumFile.close();
//get main directory all other files and subdirectories are in
QString rootDir = QFileInfo(albumFile).dirPath(TRUE);
saveLocation = rootDir + "/img";
//if representative image exists load
QImage repImage(rootDir + "/img/album.jpg");
if(!repImage.isNull())
{
setRepresentativeImages( rootDir + "/img/album.jpg");
}
//count number of photos in album, needed for showing loading progress
int numPhotos = 0;
QDomElement root = albumDom.documentElement();
QDomNode node = root.firstChild();
while( !node.isNull() )
{
if( node.isElement() && node.nodeName() == "subalbum" )
{
QDomNode childNode = node.firstChild();
while( !childNode.isNull() )
{
if( childNode.isElement() && childNode.nodeName() == "photo" )
numPhotos++;
childNode = childNode.nextSibling();
}
}
node = node.nextSibling();
}
//setup progress bar
status->showProgressBar( StatusWidget::tr("Loading:"), numPhotos );
qApp->processEvents();
int subalbumNum = 0;
//get root node and start parsing DOM
root = albumDom.documentElement();
node = root.firstChild();
QDomText val;
while( !node.isNull() )
{
//------------------------------------------------------------
//album name
if( node.isElement() && node.nodeName() == "name" )
{
val = node.firstChild().toText();
if(!val.isNull())
name = val.nodeValue();
name.replace("\\"","\"");
}
//------------------------------------------------------------
//album description
else if( node.isElement() && node.nodeName() == "description" )
{
val = node.firstChild().toText();
if(!val.isNull())
description = val.nodeValue();
description.replace("\\"","\"");
}
//------------------------------------------------------------
//album author
else if( node.isElement() && node.nodeName() == "author" )
{
val = node.firstChild().toText();
if(!val.isNull())
author = val.nodeValue();
author.replace("\\"","\"");
}
//------------------------------------------------------------
//album theme
else if( node.isElement() && node.nodeName() == "theme" )
{
val = node.firstChild().toText();
if(!val.isNull())
theme = val.nodeValue();
theme.replace("\\"","\"");
}
//------------------------------------------------------------
//album creation date
else if( node.isElement() && node.nodeName() == "created" )
{
val = node.firstChild().toText();
//split value based on spaces, should be 7 fields
QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() );
int i=0;
int intVals[3];
QStringList::Iterator it;
for ( it = vals.begin(); it != vals.end(); ++it )
{
intVals[i] = QString(*it).toInt();
i++;
//only read first 3 entires, year/month/day, don't overwrite
//buffer on addition entries if xml messed up
if(i > 2)
break;
}
creationYear = intVals[0];
creationMonth = intVals[1];
creationDay = intVals[2];
}
//------------------------------------------------------------
//subalbum
else if( node.isElement() && node.nodeName() == "subalbum" )
{
//increase counter
subalbumNum++;
//create new subalbum
Subalbum* salbum = new Subalbum(this, numSubalbums+1);
//populate it
salbum->importFromDisk( &node, subalbumNum, status, (rootDir + "/"), disableCheckPhotoMods );
//append it to list of subalbums
appendSubalbum(salbum);
}
//------------------------------------------------------------
//advance to next node
node = node.nextSibling();
//------------------------------------------------------------
}
//reset number of loaded subalbums
numLoadedSubalbums = numSubalbums;
//hide progress bar
status->setStatus( qApp->translate("Album", "Album loaded.") );
//save load directory name and loaded/saved bit
saveLocation = rootDir;
savedToDisk = true;
return ALBUM_LOADED;
}
| bool Album::prevSave | ( | ) |
Returns true if album previously saved to disk.
Definition at line 138 of file album.cpp.
References savedToDisk.
Referenced by TitleWidget::exportLargeImages(), and TitleWidget::exportSmallWebGallery().
{ return savedToDisk; }
| void Album::removeStagnantImages | ( | ) | [private] |
Removes old stagnant images caused when photos are removed from album or moved from one subalbum to another.
Definition at line 1244 of file album.cpp.
References firstSubalbum, Subalbum::getNext(), Subalbum::getNumPhotos(), numLoadedSubalbums, numSubalbums, Subalbum::resetNumLoadedPhotos(), and saveLocation.
Referenced by exportToDisk().
{
QDir rootDir(saveLocation + "/img/");
//iterate over each collection
int subalbumNumber=0;
Subalbum* currentSubalbum = firstSubalbum;
while(currentSubalbum != NULL)
{
subalbumNumber++;
//remove all photos who are numbered greater
//than the number of photos in the subalbum
int photoNum = currentSubalbum->getNumPhotos()+1;
while(true)
{
QString imageString = QString(saveLocation + "/img/%1/%2.jpg").arg(subalbumNumber).arg(photoNum);
QString origString = QString(saveLocation + "/img/%1/%2_orig.jpg").arg(subalbumNumber).arg(photoNum);
QString slideshowString = QString(saveLocation + "/img/%1/%2_slideshow.jpg").arg(subalbumNumber).arg(photoNum);
QString thumbString = QString(saveLocation + "/img/%1/%2_thumb.jpg").arg(subalbumNumber).arg(photoNum);
//if none of the possible images exist then assume
//no more stagnant images exist in this collection
//
if( !rootDir.exists(imageString) && !rootDir.exists(origString) &&
!rootDir.exists(slideshowString) && !rootDir.exists(thumbString) )
break;
//else delete photos and move on
else
{
rootDir.remove( imageString );
rootDir.remove( origString );
rootDir.remove( slideshowString );
rootDir.remove( thumbString );
photoNum++;
}
}
//reset number of loaded photos since old photos removed now
currentSubalbum->resetNumLoadedPhotos();
//move on to next collection
currentSubalbum = currentSubalbum->getNext();
}
//---------------------------------
//remove stagnant collections and all their contents
subalbumNumber = numSubalbums+1;
while(true)
{
//check to see if the directory exists, if not we are done
QString imageDirString = QString(saveLocation + "/img/%1/").arg(subalbumNumber);
if( !rootDir.exists(imageDirString) )
break;
//get filelist for directory
QDir imageDir( imageDirString );
QStringList list = imageDir.entryList( QDir::Files );
//remove each file in directory
QStringList::Iterator file;
for ( file = list.begin(); file != list.end(); ++file )
{ rootDir.remove( QString(saveLocation + "/img/%1/" + *file).arg(subalbumNumber) ); }
//remove directory
rootDir.rmdir( QString("%1").arg(subalbumNumber) );
//remove thumbnail image
rootDir.remove( QString(saveLocation + "/img/%1_thumb.jpg").arg(subalbumNumber) );
//move on to next subalbum
subalbumNumber++;
}
//reset number of loaded subalbums since stagnant directories removed now
numLoadedSubalbums = numSubalbums;
//---------------------------------
}
| void Album::removeStagnantOrigFiles | ( | StatusWidget * | status | ) | [private] |
Removes any _orig images for photos which have been recently reverted to their original form (and hence we can reduce disk usage but removing these effective duplicates)
Definition at line 1093 of file album.cpp.
References firstSubalbum, Subalbum::getFirst(), Photo::getImageFilename(), Subalbum::getNext(), Photo::getNext(), Photo::getRecentlyReverted(), StatusWidget::incrementProgress(), Photo::originalImageFilename(), Photo::setRecentlyReverted(), and tmpDir.
Referenced by exportToDisk().
{
QDir tmpDir;
//iterate over all collections
Subalbum* currentSubalbum = firstSubalbum;
while(currentSubalbum != NULL)
{
//iterate over all photos in this subalbum
Photo* currentPhoto = currentSubalbum->getFirst();
while(currentPhoto != NULL)
{
//if photo recently reverted and orig file is not the current filename remove orig file
//the orig and current name will match up if a previously saved (but not modified) photo
//is modified, reverted, then saved out again
if(currentPhoto->getRecentlyReverted() &&
currentPhoto->getImageFilename().compare( currentPhoto->originalImageFilename() ) != 0 )
{
tmpDir.remove( currentPhoto->originalImageFilename() );
currentPhoto->setRecentlyReverted( false );
}
//move on to next photo
currentPhoto = currentPhoto->getNext();
status->incrementProgress();
qApp->processEvents();
}
//move on to next subalbum
currentSubalbum = currentSubalbum->getNext();
}
}
| void Album::removeSubalbum | ( | Subalbum * | val | ) |
Removes a subalbum.
Definition at line 257 of file album.cpp.
References firstSubalbum, Subalbum::getNext(), Subalbum::getPrev(), lastSubalbum, modified, numSubalbums, Subalbum::setNext(), and Subalbum::setPrev().
Referenced by SubalbumsWidget::deleteAction().
{
//if passed a null pointer bail!
if( val == NULL) return;
//reset head and tail pointers if necessary
if( val == firstSubalbum ) firstSubalbum = val->getNext();
if( val == lastSubalbum ) lastSubalbum = val->getPrev();
//split out
if( val->getPrev() != NULL ) val->getPrev()->setNext( val->getNext() );
if( val->getNext() != NULL ) val->getNext()->setPrev( val->getPrev() );
//delete object
delete val;
val = NULL;
numSubalbums--;
modified = true;
}
| void Album::reorderSubalbumImages | ( | StatusWidget * | status | ) | [private] |
Checks if images need to be moved and does so if necessary.
Definition at line 1126 of file album.cpp.
References firstSubalbum, Subalbum::getFirst(), Photo::getInitialPhotoNumber(), Photo::getInitialSubalbumNumber(), Subalbum::getNext(), Photo::getNext(), StatusWidget::incrementProgress(), moveFile(), saveLocation, Photo::setImageFilename(), Photo::setInitialPhotoNumber(), Photo::setInitialSubalbumNumber(), Photo::setSlideshowFilename(), Photo::setThumbnailFilename(), and tmpDir.
Referenced by exportToDisk().
{
//--------------------------------------------------------
//--------------------------------------------------------
//first pass over all photos, those whose initial and current numbers don't match up
//rename slightly so we don't overwrte them the second time around
//--------------------------------------------------------
//--------------------------------------------------------
//iterate over all subalbums
QDir tmpDir;
int subalbumNumber=0;
Subalbum* currentSubalbum = firstSubalbum;
while(currentSubalbum != NULL)
{
subalbumNumber++;
//iterate over all photos in this subalbum
int photoNumber=0;
Photo* currentPhoto = currentSubalbum->getFirst();
while(currentPhoto != NULL)
{
photoNumber++;
int initPhotoNumber = currentPhoto->getInitialPhotoNumber();
int initSubalbumNumber = currentPhoto->getInitialSubalbumNumber();
//if photo has moved rename full image, orig image (if it exists), slideshow image, and thumbnail images
if( initPhotoNumber != photoNumber || initSubalbumNumber != subalbumNumber)
{
QString oldName = QString(saveLocation + "/img/%1/%2.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
QString newName = QString(saveLocation + "/img/%1/%2_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
moveFile( oldName, newName );
//-----
oldName = QString(saveLocation + "/img/%1/%2_orig.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
newName = QString(saveLocation + "/img/%1/%2_orig_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
if(tmpDir.exists(oldName) ) { moveFile( oldName, newName ); }
//-----
oldName = QString(saveLocation + "/img/%1/%2_slideshow.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
newName = QString(saveLocation + "/img/%1/%2_slideshow_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
moveFile( oldName, newName );
//-----
oldName = QString(saveLocation + "/img/%1/%2_thumb.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
newName = QString(saveLocation + "/img/%1/%2_thumb_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
moveFile( oldName, newName );
}
//move on to next photo
currentPhoto = currentPhoto->getNext();
status->incrementProgress();
qApp->processEvents();
}
//move on to next subalbum
currentSubalbum = currentSubalbum->getNext();
}
//--------------------------------------------------------
//--------------------------------------------------------
//second pass over all photos, those whose initial and current numbers don't match up
//rename to their final names and reset initial photo and subalbum numbers
//--------------------------------------------------------
//--------------------------------------------------------
//iterate over all subalbums
subalbumNumber=0;
currentSubalbum = firstSubalbum;
while(currentSubalbum != NULL)
{
subalbumNumber++;
//iterate over all photos in this subalbum
int photoNumber=0;
Photo* currentPhoto = currentSubalbum->getFirst();
while(currentPhoto != NULL)
{
photoNumber++;
int initPhotoNumber = currentPhoto->getInitialPhotoNumber();
int initSubalbumNumber = currentPhoto->getInitialSubalbumNumber();
//if the current photo has moved rename full image, slideshow image, and thumbnail image to their final names
if( initPhotoNumber != photoNumber || initSubalbumNumber != subalbumNumber)
{
QString oldName = QString(saveLocation + "/img/%1/%2_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
QString newName = QString(saveLocation + "/img/%1/%2.jpg" ).arg(subalbumNumber).arg(photoNumber);
moveFile( oldName, newName );
//-----
oldName = QString(saveLocation + "/img/%1/%2_orig_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
newName = QString(saveLocation + "/img/%1/%2_orig.jpg" ).arg(subalbumNumber).arg(photoNumber);
if(tmpDir.exists(oldName) ) { moveFile( oldName, newName ); }
//-----
oldName = QString(saveLocation + "/img/%1/%2_slideshow_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
newName = QString(saveLocation + "/img/%1/%2_slideshow.jpg" ).arg(subalbumNumber).arg(photoNumber);
moveFile( oldName, newName );
//-----
oldName = QString(saveLocation + "/img/%1/%2_thumb_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber);
newName = QString(saveLocation + "/img/%1/%2_thumb.jpg" ).arg(subalbumNumber).arg(photoNumber);
moveFile( oldName, newName );
//---------------------------------------
//reset initial photo and subalbum numbers, and filenames
currentPhoto->setInitialPhotoNumber(photoNumber);
currentPhoto->setInitialSubalbumNumber(subalbumNumber);
currentPhoto->setImageFilename( QString(saveLocation + "/img/%1/%2.jpg").
arg(subalbumNumber).arg(photoNumber) );
currentPhoto->setSlideshowFilename( QString(saveLocation + "/img/%1/%2_slideshow.jpg").
arg(subalbumNumber).arg(photoNumber) );
currentPhoto->setThumbnailFilename( QString(saveLocation + "/img/%1/%2_thumb.jpg").
arg(subalbumNumber).arg(photoNumber) );
}
//move on to next photo
currentPhoto = currentPhoto->getNext();
status->incrementProgress();
qApp->processEvents();
}
//move on to next subalbum
currentSubalbum = currentSubalbum->getNext();
}
}
| void Album::setAuthor | ( | QString | val | ) |
| void Album::setDescription | ( | QString | val | ) |
Sets the album description.
Definition at line 168 of file album.cpp.
References description, and modified.
Referenced by TitleWidget::storeAnnotations().
{
if(description != val)
{
description = val;
modified = true;
}
}
| void Album::setModified | ( | bool | val = true | ) |
Sets the album as modified.
Definition at line 1418 of file album.cpp.
References modified.
Referenced by Subalbum::addPhoto(), Subalbum::lazyAddPhoto(), TitleWidget::loadAlbum(), TitleWidget::newAlbum(), Subalbum::photoMoved(), Subalbum::removePhoto(), Subalbum::setDescription(), Subalbum::setModified(), Subalbum::setName(), Subalbum::setNext(), Subalbum::setPrev(), and Subalbum::setRepresentativeImage().
{ modified = val; }
| void Album::setName | ( | QString | val | ) |
| void Album::setRepresentativeImages | ( | QString | imageFilename | ) |
Sets the representative image.
Definition at line 186 of file album.cpp.
References calcScaledImageDimensions(), getImageSize(), largeRepresentativeImage, modified, REP_IMAGE_HEIGHT, scaleImage(), and smallRepresentativeImage.
Referenced by importFromDisk(), TitleWidget::setAlbumImage(), and TitleWidget::unsetAlbumImage().
{
//delete representative images
delete smallRepresentativeImage;
delete largeRepresentativeImage;
//if being set to null, set back to defaults
if(imageFilename.isNull())
{
smallRepresentativeImage = NULL;
largeRepresentativeImage = NULL;
}
else
{
//compute representative image sizes
int imageWidth, imageHeight;
getImageSize( imageFilename, imageWidth, imageHeight );
int smallRepWidth = 0;
int smallRepHeight = 0;
int largeRepWidth = 0;
int largeRepHeight = 0;
calcScaledImageDimensions( imageWidth, imageHeight,
107, REP_IMAGE_HEIGHT,
smallRepWidth, smallRepHeight);
calcScaledImageDimensions( imageWidth, imageHeight,
500, 320,
largeRepWidth, largeRepHeight);
//create various representative images
//copy and scale small version
QImage thumbnailSmall;
scaleImage( imageFilename, thumbnailSmall, smallRepWidth, smallRepHeight );
smallRepresentativeImage = new QPixmap( thumbnailSmall.width(), thumbnailSmall.height() );
smallRepresentativeImage->convertFromImage( thumbnailSmall );
//copy and scale large version
QImage thumbnailLarge;
scaleImage( imageFilename, thumbnailLarge, largeRepWidth, largeRepHeight );
largeRepresentativeImage = new QPixmap( thumbnailLarge.width(), thumbnailLarge.height() );
largeRepresentativeImage->convertFromImage( thumbnailLarge );
}
//set modified
modified = true;
}
| void Album::syncSubalbumList | ( | SubalbumPreviewWidget * | item | ) |
Syncs subalbum ordering with front end gui ordering.
Definition at line 1369 of file album.cpp.
References firstSubalbum, Subalbum::getNext(), SubalbumPreviewWidget::getSubalbum(), lastSubalbum, Subalbum::setNext(), and Subalbum::setPrev().
Referenced by SubalbumsWidget::reorder().
{
//check to see if any changes actually took place
bool change = false;
Subalbum* tmp = firstSubalbum;
SubalbumPreviewWidget* tmp2 = item;
while( tmp2 != NULL)
{
//pointers do not match up
if(tmp != tmp2->getSubalbum() )
{
change = true;
break;
}
tmp = tmp->getNext();
tmp2 = (SubalbumPreviewWidget*)tmp2->nextItem();
}
//if no change then quit
if(!change)
return;
//base case, no items
if(item == NULL)
{
firstSubalbum = NULL;
lastSubalbum = NULL;
return;
}
//set first and last pointers
firstSubalbum = item->getSubalbum();
firstSubalbum->setNext(NULL);
firstSubalbum->setPrev(NULL);
lastSubalbum = firstSubalbum;
//set all next pointers
while(item->nextItem() != NULL)
{
item->getSubalbum()->setNext( ((SubalbumPreviewWidget*)item->nextItem())->getSubalbum() );
item->getSubalbum()->getNext()->setPrev( item->getSubalbum() );
item = (SubalbumPreviewWidget*)item->nextItem();
lastSubalbum = item->getSubalbum();
lastSubalbum->setNext(NULL);
}
}
| void Album::updateCreationDate | ( | ) |
Updates the creation date to today's date.
Definition at line 277 of file album.cpp.
References creationDay, creationMonth, and creationYear.
Referenced by Album().
{
//set creation date to today
QDate date = QDate::currentDate();
creationYear = date.year();
creationMonth = date.month();
creationDay = date.day();
}
| void Album::updateModificationDate | ( | ) |
Updates the modification date to today's date.
Definition at line 286 of file album.cpp.
References modificationDay, modificationMonth, and modificationYear.
Referenced by Album(), and exportToXML().
{
//set last modification date to today
QDate date = QDate::currentDate();
modificationYear = date.year();
modificationMonth = date.month();
modificationDay = date.day();
}
QString Album::author [private] |
Album Creator.
Definition at line 203 of file album.h.
Referenced by Album(), exportToXML(), getAuthor(), importFromDisk(), and setAuthor().
int Album::creationDay [private] |
Creation day.
Definition at line 231 of file album.h.
Referenced by exportToXML(), getCreationDay(), importFromDisk(), and updateCreationDate().
int Album::creationMonth [private] |
Creation month.
Definition at line 228 of file album.h.
Referenced by exportToXML(), getCreationMonth(), importFromDisk(), and updateCreationDate().
int Album::creationYear [private] |
Creation year.
Definition at line 225 of file album.h.
Referenced by exportToXML(), getCreationYear(), importFromDisk(), and updateCreationDate().
QString Album::description [private] |
Longer description of album.
Definition at line 200 of file album.h.
Referenced by Album(), exportToXML(), getDescription(), importFromDisk(), and setDescription().
Subalbum* Album::firstSubalbum [private] |
Pointer to first Subalbum.
Definition at line 210 of file album.h.
Referenced by Album(), appendSubalbum(), exportCompressedWebAlbum(), exportSubalbumImages(), exportToDisk(), exportTopLevelImages(), exportToXML(), getFirstSubalbum(), getNumPhotos(), getThumbnailFilenames(), removeStagnantImages(), removeStagnantOrigFiles(), removeSubalbum(), reorderSubalbumImages(), syncSubalbumList(), and ~Album().
QPixmap* Album::largeRepresentativeImage [private] |
Definition at line 207 of file album.h.
Referenced by Album(), getRepresentativeImage(), setRepresentativeImages(), and ~Album().
Subalbum* Album::lastSubalbum [private] |
Pointer to last Subalbum.
Definition at line 213 of file album.h.
Referenced by Album(), appendSubalbum(), getLastSubalbum(), removeSubalbum(), and syncSubalbumList().
int Album::modificationDay [private] |
Last modification day.
Definition at line 222 of file album.h.
Referenced by exportToXML(), getModificationDay(), and updateModificationDate().
int Album::modificationMonth [private] |
Last modification month.
Definition at line 219 of file album.h.
Referenced by exportToXML(), getModificationMonth(), and updateModificationDate().
int Album::modificationYear [private] |
Last modification year.
Definition at line 216 of file album.h.
Referenced by exportToXML(), getModificationYear(), and updateModificationDate().
bool Album::modified [private] |
Modification status of the album.
Definition at line 252 of file album.h.
Referenced by Album(), albumModified(), appendSubalbum(), exportToDisk(), removeSubalbum(), setAuthor(), setDescription(), setModified(), setName(), and setRepresentativeImages().
QString Album::name [private] |
Short name for album.
Definition at line 197 of file album.h.
Referenced by Album(), exportToXML(), getName(), importFromDisk(), and setName().
int Album::nextUniqueID [private] |
Next Unique ID for new photos.
This counter is used to gerneate unique filenames before photos are saved. After saving we reset this counter to avoid wrap-around.
Definition at line 260 of file album.h.
Referenced by Album(), exportToDisk(), and getNextUniquePhotoID().
int Album::numLoadedSubalbums [private] |
Number of loaded subalbums.
Definition at line 237 of file album.h.
Referenced by Album(), importFromDisk(), and removeStagnantImages().
int Album::numSubalbums [private] |
Number of subalbums.
Definition at line 234 of file album.h.
Referenced by Album(), appendSubalbum(), getNumSubalbums(), importFromDisk(), removeStagnantImages(), and removeSubalbum().
QString Album::oldSaveLocation [private] |
Definition at line 246 of file album.h.
Referenced by exportSubalbumImages(), and exportToDisk().
bool Album::savedToDisk [private] |
Set if album was loaded/has been saved to disk.
Definition at line 240 of file album.h.
Referenced by Album(), exportToDisk(), importFromDisk(), and prevSave().
QString Album::saveLocation [private] |
Directory album saved to.
Definition at line 243 of file album.h.
Referenced by Album(), exportSubalbumImages(), exportThemeResources(), exportToDisk(), exportTopLevelImages(), getSaveLocation(), importFromDisk(), removeStagnantImages(), and reorderSubalbumImages().
QPixmap* Album::smallRepresentativeImage [private] |
Representative images.
Definition at line 206 of file album.h.
Referenced by Album(), getRepresentativeImage(), setRepresentativeImages(), and ~Album().
QString Album::theme [private] |
Theme to save album with.
Definition at line 249 of file album.h.
Referenced by Album(), exportCompressedWebAlbum(), exportToDisk(), exportToXML(), getTheme(), and importFromDisk().
QString Album::tmpDir [private] |
Temporary directory for placing modified or new images before saving takes place.
Definition at line 255 of file album.h.
Referenced by Album(), exportSubalbumImages(), exportToDisk(), getTmpDir(), removeStagnantOrigFiles(), reorderSubalbumImages(), and ~Album().
1.7.5.1