#include <album.h>
Collaboration diagram for Album:
Specific contents:
Definition at line 49 of file 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. | |
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 | 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. |
|
Sets default information and create temporary directory as necessary.
Definition at line 40 of file album.cpp. References appendSubalbum(), author, description, firstSubalbum, getTmpDir(), largeRepresentativeImage, lastSubalbum, modified, name, nextUniqueID, numLoadedSubalbums, numSubalbums, savedToDisk, saveLocation, smallRepresentativeImage, theme, updateCreationDate(), and updateModificationDate(). 00041 { 00042 //set strings to default values 00043 name = ""; 00044 description =""; 00045 author = ""; 00046 theme = "Slick"; 00047 this->tmpDir = tmpDir; 00048 00049 //by default no representative image 00050 smallRepresentativeImage = NULL; 00051 largeRepresentativeImage = NULL; 00052 00053 //no Subalbums by default 00054 firstSubalbum = NULL; 00055 lastSubalbum = NULL; 00056 00057 //set the creation/modification date to today 00058 updateCreationDate(); 00059 updateModificationDate(); 00060 00061 //no subalbums 00062 numSubalbums = 0; 00063 numLoadedSubalbums = 0; 00064 00065 //not previously saved by default 00066 savedToDisk = false; 00067 00068 //set default save location (where images are placed before saving) to the tmp directory 00069 saveLocation = getTmpDir(); 00070 00071 if(createSubalbum) 00072 { 00073 Subalbum* s = new Subalbum( this, 1 ); 00074 appendSubalbum( s ); 00075 } 00076 00077 //no interesting modifications yet 00078 modified = false; 00079 00080 nextUniqueID = 0; 00081 }
|
|
Frees Subalbums.
Definition at line 83 of file album.cpp. References Subalbum::getNext(), and tmpDir. 00084 { 00085 //delete representative image 00086 delete smallRepresentativeImage; 00087 delete largeRepresentativeImage; 00088 00089 //delete subalbums 00090 Subalbum* current = firstSubalbum; 00091 Subalbum* temp; 00092 while(current != NULL) 00093 { 00094 temp = current->getNext(); 00095 delete current; 00096 current = temp; 00097 } 00098 00099 //remove all old tmp dir contents and directory itself 00100 if(!tmpDir.isNull()) 00101 { 00102 QDir oldTmpDir(tmpDir); 00103 QString tmpDirName = oldTmpDir.dirName(); 00104 QStringList strLst = oldTmpDir.entryList(); 00105 QStringList::iterator it; 00106 for(it = strLst.begin(); it != strLst.end(); it++) 00107 { 00108 oldTmpDir.remove(tmpDir + "/" + *it); 00109 } 00110 oldTmpDir.cdUp(); 00111 oldTmpDir.rmdir( tmpDirName ); 00112 } 00113 }
|
|
Returns true if album has been modified since the last save operation.
Definition at line 138 of file album.cpp. Referenced by Window::closeEvent(), TitleWidget::newAlbum(), TitleWidget::proceedWithLoad(), and TitleWidget::revertToSaved(). 00138 { return modified; }
|
|
Appends subalbum to end of linked list.
Definition at line 233 of file album.cpp. References firstSubalbum, lastSubalbum, modified, numSubalbums, Subalbum::setNext(), and Subalbum::setPrev(). Referenced by Album(), SubalbumsWidget::createAction(), and importFromDisk(). 00234 { 00235 //if passed a null pointer bail! 00236 if( val == NULL) return; 00237 00238 //empty list - stick on front 00239 if(firstSubalbum == NULL) 00240 { 00241 firstSubalbum = val; 00242 lastSubalbum = val; 00243 } 00244 //else - append to end 00245 else 00246 { 00247 lastSubalbum->setNext( val ); 00248 val->setPrev( lastSubalbum ); 00249 lastSubalbum = val; 00250 } 00251 00252 numSubalbums++; 00253 modified = true; 00254 }
|
|
Export a compressed web album (excludes full size images and xml data).
Definition at line 615 of file album.cpp. References copyFile(), exportToXML(), Subalbum::getFirst(), Subalbum::getNext(), Photo::getNext(), getNumPhotos(), Subalbum::getRepresentativeImage(), getRepresentativeImage(), Photo::getSlideshowFilename(), Photo::getThumbnailFilename(), LARGE, status, theme, THEMES_PATH, transformXMLtoHTML(), and StatusWidget::updateProgress(). Referenced by TitleWidget::exportSmallWebGallery(). 00618 { 00619 //------------------------------------------ 00620 //copy all images 00621 QDir localDir(exportLocation); 00622 localDir.mkdir("img"); 00623 localDir.setPath(exportLocation + "/img"); 00624 00625 //copy album image 00626 if(getRepresentativeImage(LARGE) != NULL) 00627 { getRepresentativeImage(LARGE)->save(exportLocation + "/img/album.jpg", "JPEG", 95); } 00628 else 00629 { localDir.remove(exportLocation + "/img/album.jpg"); } 00630 00631 int numPhotos = getNumPhotos(); 00632 int photosLeft = numPhotos; 00633 int updateInverval = numPhotos / 50; 00634 int updateCount = 0; 00635 00636 //iterate over each collection 00637 Subalbum* curCollection = firstSubalbum; 00638 int collectionNum=1; 00639 while(curCollection != NULL) 00640 { 00641 QString collectionDir = QString("%1").arg( collectionNum ); 00642 localDir.mkdir( collectionDir ); 00643 00644 //copy collection image 00645 QString collectionThumbFilename = QString(exportLocation + "/img/%1_thumb.jpg" ).arg(collectionNum); 00646 if(curCollection->getRepresentativeImage(LARGE) != NULL ) 00647 { curCollection->getRepresentativeImage(LARGE)->save( collectionThumbFilename, "JPEG", 95); } 00648 else 00649 { localDir.remove( collectionThumbFilename ); } 00650 00651 //copy each photo 00652 Photo* curPhoto = curCollection->getFirst(); 00653 int photoNum = 1; 00654 while(curPhoto != NULL) 00655 { 00656 //update status message 00657 status->updateProgress( numPhotos - photosLeft, exportMessage.arg( photosLeft ) ); 00658 00659 //make sure events are processed every 2% of the photos that are processes 00660 updateCount++; 00661 if(updateCount > updateInverval) 00662 { 00663 updateCount = 0; 00664 qApp->processEvents(); 00665 } 00666 00667 //copy files 00668 QString newFilePath = QDir::convertSeparators( exportLocation + "/img/" + 00669 collectionDir + "/" + 00670 QString("%1").arg(photoNum) ); 00671 00672 copyFile( curPhoto->getSlideshowFilename(), newFilePath + "_slideshow.jpg" ); 00673 copyFile( curPhoto->getThumbnailFilename(), newFilePath + "_thumb.jpg" ); 00674 00675 curPhoto = curPhoto->getNext(); 00676 photoNum++; 00677 photosLeft--; 00678 } 00679 00680 curCollection = curCollection->getNext(); 00681 collectionNum++; 00682 } 00683 //------------------------------------------ 00684 //copy theme resources 00685 QStringList fileList; 00686 QStringList::Iterator file; 00687 00688 //create HTML and misc resources directories 00689 localDir.setPath(exportLocation); 00690 localDir.mkdir("resources"); 00691 00692 //remove all files in these directories from previous saves with other themes 00693 localDir.setPath(exportLocation + "/resources"); 00694 fileList = localDir.entryList( QDir::Files ); 00695 for ( file = fileList.begin(); file != fileList.end(); ++file ) 00696 { localDir.remove( exportLocation + "/resources/" + *file ); } 00697 00698 //copy files over from theme's directory 00699 localDir.setPath(THEMES_PATH + theme + "/resources"); 00700 fileList = localDir.entryList( QDir::Files ); 00701 for ( file = fileList.begin(); file != fileList.end(); ++file ) 00702 { copyFile( THEMES_PATH + theme + "/resources/" + *file, exportLocation + "/resources/" + *file); } 00703 //------------------------------------------ 00704 //export xml file 00705 exportToXML(status, exportLocation); 00706 //------------------------------------------ 00707 //remove previous html/htm files 00708 localDir.setPath(exportLocation); 00709 fileList = localDir.entryList( QDir::Files ); 00710 for ( file = fileList.begin(); file != fileList.end(); ++file ) 00711 { 00712 if( (*file).endsWith(".html") || (*file).endsWith(".htm") ) 00713 localDir.remove( exportLocation + "/" + *file ); 00714 } 00715 //------------------------------------------ 00716 //construct html files 00717 transformXMLtoHTML( exportLocation, theme, true ); 00718 //------------------------------------------ 00719 //remove xml file 00720 localDir.remove( exportLocation + "/Album.xml" ); 00721 //------------------------------------------ 00722 return ALBUM_EXPORTED; 00723 }
|
|
Export fullsize images (excludes slideshow and thumbnail images, album and collection iamges, and html or xml files).
Definition at line 725 of file album.cpp. References copyFile(), Subalbum::getFirst(), getFirstSubalbum(), Photo::getImageFilename(), Photo::getNext(), Subalbum::getNext(), getNumPhotos(), Subalbum::getNumPhotos(), getNumSubalbums(), status, and StatusWidget::updateProgress(). Referenced by TitleWidget::exportLargeImages(). 00726 { 00727 //determine number of digits collecion # requires 00728 uint collectionDigits = (uint) (1 + log( (double) getNumSubalbums() ) / log( 10.0 ) ); 00729 00730 //determine number of digits photo # requires, this 00731 //involves walking through the album and finding the collection with the most phots first 00732 int mostPhotos = 0; 00733 Subalbum* curCollection = getFirstSubalbum(); 00734 while(curCollection != NULL ) 00735 { 00736 mostPhotos = QMAX( mostPhotos, curCollection->getNumPhotos() ); 00737 curCollection = curCollection->getNext(); 00738 } 00739 uint photoDigits = (uint) ( 1 + log( (double) mostPhotos ) / log( 10.0 ) ); 00740 //------------ 00741 //copy files 00742 int numPhotos = getNumPhotos(); 00743 int photosLeft = numPhotos; 00744 00745 int collectionNum = 1; 00746 curCollection = getFirstSubalbum(); 00747 00748 int updateInverval = numPhotos / 50; 00749 int updateCount = 0; 00750 00751 while(curCollection != NULL ) 00752 { 00753 //construct collection string 00754 QString collectionString = QString("%1").arg(collectionNum); 00755 while(collectionString.length() < collectionDigits) 00756 { collectionString = "0" + collectionString; } 00757 00758 //copy all photos in collection 00759 int photoNum = 1; 00760 Photo* curPhoto = curCollection->getFirst(); 00761 while(curPhoto != NULL) 00762 { 00763 //update status message 00764 status->updateProgress( numPhotos - photosLeft, exportMessage.arg( photosLeft ) ); 00765 00766 //make sure events are processed every 2% of the photos that are processes 00767 updateCount++; 00768 if(updateCount > updateInverval) 00769 { 00770 updateCount = 0; 00771 qApp->processEvents(); 00772 } 00773 00774 //construct photo string 00775 QString photoString = QString("%1").arg(photoNum); 00776 while(photoString.length() < photoDigits) 00777 { photoString = "0" + photoString; } 00778 00779 //construct new photo path 00780 QString newFilePath = QDir::convertSeparators( exportPath + "/" + collectionString + 00781 "_" + photoString + ".jpg" ); 00782 //copy file 00783 copyFile( curPhoto->getImageFilename(), newFilePath ); 00784 00785 //move on to next file 00786 photosLeft--; 00787 curPhoto = curPhoto->getNext(); 00788 photoNum++; 00789 00790 } //while photo 00791 00792 //move on to next collection 00793 curCollection = curCollection->getNext(); 00794 collectionNum++; 00795 }// while collection 00796 //------------ 00797 return ALBUM_EXPORTED; 00798 }
|
|
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 888 of file album.cpp. References copyFile(), 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(), saveLocation, Photo::setEverSaved(), Photo::setImageChecksum(), Photo::setImageFilename(), Photo::setNeedsSavingVal(), Photo::setSlideshowChecksum(), Photo::setSlideshowFilename(), Photo::setThumbnailChecksum(), Photo::setThumbnailFilename(), and status. Referenced by exportToDisk(). 00889 { 00890 //iterate over all subalbums 00891 int subalbumNumber=0; 00892 Subalbum* currentSubalbum = firstSubalbum; 00893 while(currentSubalbum != NULL) 00894 { 00895 subalbumNumber++; 00896 00897 //iterate over all photos in this subalbum 00898 int photoNumber=0; 00899 Photo* currentPhoto = currentSubalbum->getFirst(); 00900 while(currentPhoto != NULL) 00901 { 00902 photoNumber++; 00903 //--------------------------------------- 00904 //if the current photo does not need to be saved then move on 00905 if( !forceSave && !currentPhoto->getNeedsSavingVal() ) 00906 { 00907 currentPhoto = currentPhoto->getNext(); 00908 status->incrementProgress(); 00909 qApp->processEvents(); 00910 continue; 00911 } 00912 //--------------------------------------- 00913 //get initial photo # and subalbum #, used for saving 00914 int initPhotoNumber = currentPhoto->getInitialPhotoNumber(); 00915 int initSubalbumNumber = currentPhoto->getInitialSubalbumNumber(); 00916 //--------------------------------------- 00917 //export thumbnail image 00918 QString oldName = currentPhoto->getThumbnailFilename(); 00919 QString newName = QString(saveLocation + "/img/%1/%2_thumb.jpg" ) 00920 .arg(initSubalbumNumber).arg(initPhotoNumber); 00921 00922 //if file has been modified move from current location to final location 00923 if( currentPhoto->getNeedsSavingVal() ) { moveFile( oldName, newName ); } 00924 //If file has not been modified we must be doing a save-as and saving has been forced. In this case 00925 //COPY file from current location to final location, DON'T delete previous copy!!! 00926 else { copyFile(oldName, newName); } 00927 00928 //compute and store md5 for slideshow image 00929 std::ifstream thumbnailFile( QFile::encodeName(newName) ); 00930 if(thumbnailFile.is_open()) 00931 { 00932 currentPhoto->setThumbnailChecksum( getMD5(thumbnailFile) ); 00933 thumbnailFile.close(); 00934 } 00935 //--------------------------------------- 00936 //export slideshow image 00937 oldName = currentPhoto->getSlideshowFilename(); 00938 newName = QString(saveLocation + "/img/%1/%2_slideshow.jpg" ) 00939 .arg(initSubalbumNumber).arg(initPhotoNumber); 00940 00941 //if file has been modified move from current location to final location 00942 if( currentPhoto->getNeedsSavingVal() ) { moveFile( oldName, newName ); } 00943 //If file has not been modified we must be doing a save-as and saving has been forced. In this case 00944 //COPY file from current location to final location, DON'T delete previous copy!!! 00945 else { copyFile(oldName, newName); } 00946 00947 //compute and store md5 for slideshow image 00948 std::ifstream slideshowFile( QFile::encodeName(newName) ); 00949 if(slideshowFile.is_open()) 00950 { 00951 currentPhoto->setSlideshowChecksum( getMD5(slideshowFile) ); 00952 slideshowFile.close(); 00953 } 00954 //--------------------------------------- 00955 //export full size image 00956 oldName = currentPhoto->getImageFilename(); 00957 newName = QString(saveLocation + "/img/%1/%2.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 00958 00959 //if file has been modified move from current location to final location 00960 if( currentPhoto->getNeedsSavingVal() ) 00961 { 00962 QString tempOrigName = getTmpDir() + QString("/%1_%2_orig.jpg") 00963 .arg(initSubalbumNumber).arg(initPhotoNumber); 00964 00965 QString finalOrigName = QString(saveLocation + "/img/%1/%2_orig.jpg" ) 00966 .arg(initSubalbumNumber).arg(initPhotoNumber); 00967 00973 QDir tmpDir; 00974 if( !currentPhoto->getRecentlyReverted() && 00975 tmpDir.exists(newName) && 00976 !tmpDir.exists(finalOrigName) ) 00977 { 00978 moveFile( newName, finalOrigName ); 00979 } 00984 else if( !currentPhoto->getRecentlyReverted() && 00985 !tmpDir.exists(newName) && 00986 tmpDir.exists(tempOrigName) ) 00987 { 00988 moveFile( tempOrigName, finalOrigName ); 00989 } 00990 00992 moveFile( oldName, newName ); 00993 } 00994 //If file does not need to be saved a force save is taking place. This occurs when a user chooses 00995 //save as and copies an entire album to a different location so all files must be copied. Make 00996 //sure to copy over the original form of the photo as well if this file exists 00997 else 00998 { 00999 //copy current image 01000 copyFile( oldName, newName ); 01001 01003 //if orig file exists copy it too 01004 QDir tmpDir; 01005 01006 QString tempOrigName = getTmpDir() + QString("/%1_%2_orig.jpg") 01007 .arg(initSubalbumNumber).arg(initPhotoNumber); 01008 01009 QString curOrigName = currentPhoto->getImageFilename(); 01010 curOrigName.truncate( curOrigName.length() - 4 ); 01011 curOrigName = curOrigName + "_orig.jpg"; 01012 01013 QString finalOrigName = QString(saveLocation + "/img/%1/%2_orig.jpg" ) 01014 .arg(initSubalbumNumber).arg(initPhotoNumber); 01015 01016 //if the photo was recently reverted ignore the presence of orig files 01017 if( !currentPhoto->getRecentlyReverted() ) 01018 { 01019 //if the photo was never previously saved and an orig file 01020 //exists in the tmp directory make sure to copy it over 01021 if( !currentPhoto->getEverSaved() && 01022 tmpDir.exists( tempOrigName ) ) 01023 { 01024 copyFile( tempOrigName, finalOrigName ); 01025 } 01026 //if the photo was previously saved and an orig file exists 01027 //in the previous save location make sure to copy it over 01028 else if( currentPhoto->getEverSaved() && 01029 tmpDir.exists( curOrigName ) ) 01030 { 01031 copyFile( curOrigName, finalOrigName ); 01032 } 01033 } 01035 } 01036 //--------------------------------------- 01037 //compute and store md5 for image 01038 std::ifstream imageFile( QFile::encodeName(newName) ); 01039 if(imageFile.is_open()) 01040 { 01041 currentPhoto->setImageChecksum( getMD5(imageFile) ); 01042 imageFile.close(); 01043 } 01044 //--------------------------------------- 01045 //set new storage locations of files 01046 currentPhoto->setImageFilename 01047 ( QString(saveLocation + "/img/%1/%2.jpg").arg(initSubalbumNumber).arg(initPhotoNumber) ); 01048 01049 currentPhoto->setSlideshowFilename 01050 ( QString(saveLocation + "/img/%1/%2_slideshow.jpg").arg(initSubalbumNumber).arg(initPhotoNumber) ); 01051 01052 currentPhoto->setThumbnailFilename 01053 ( QString(saveLocation + "/img/%1/%2_thumb.jpg").arg(initSubalbumNumber).arg(initPhotoNumber) ); 01054 //--------------------------------------- 01055 //set image as not needing saving and as being saved 01056 currentPhoto->setNeedsSavingVal(false); 01057 currentPhoto->setEverSaved(true); 01058 //--------------------------------------- 01059 //update progress bar 01060 status->incrementProgress(); 01061 qApp->processEvents(); 01062 //--------------------------------------- 01063 //move on to next photo in subalbum 01064 currentPhoto = currentPhoto->getNext(); 01065 //--------------------------------------- 01066 } 01067 //--------------------------------------- 01068 //move on to next subalbum 01069 currentSubalbum = currentSubalbum->getNext(); 01070 } 01071 }
|
|
Removes previously saved resources, copies over new resources.
Definition at line 1299 of file album.cpp. References copyFile(), saveLocation, and THEMES_PATH. Referenced by exportToDisk(). 01300 { 01301 QStringList fileList; 01302 QStringList::Iterator file; 01303 QDir localDir; 01304 01305 //remove any "resources" directories created by 1.0* versions of Album Shaper 01306 localDir.setPath( saveLocation + "/resources" ); 01307 fileList = localDir.entryList(); 01308 for(file = fileList.begin(); file != fileList.end(); file++) 01309 { 01310 localDir.remove(saveLocation + "/resources/" + *file); 01311 } 01312 localDir.cdUp(); 01313 localDir.rmdir( "resources" ); 01314 01315 //create HTML and misc resources directories 01316 localDir.setPath(saveLocation); 01317 localDir.mkdir("resources"); 01318 // localDir.mkdir("misc_resources"); 01319 01320 //remove all files in these directories from previous saves with other themes 01321 localDir.setPath(saveLocation + "/resources"); 01322 fileList = localDir.entryList( QDir::Files ); 01323 for ( file = fileList.begin(); file != fileList.end(); ++file ) 01324 { localDir.remove( saveLocation + "/resources/" + *file ); } 01325 //-- 01326 /* 01327 localDir.setPath(saveLocation + "/misc_resources"); 01328 fileList = localDir.entryList( QDir::Files ); 01329 for ( file = fileList.begin(); file != fileList.end(); ++file ) 01330 { localDir.remove( saveLocation + "/misc_resources/" + *file ); } 01331 */ 01332 //copy files over from theme's directory 01333 localDir.setPath(THEMES_PATH + theme + "/resources"); 01334 fileList = localDir.entryList( QDir::Files ); 01335 for ( file = fileList.begin(); file != fileList.end(); ++file ) 01336 { copyFile( THEMES_PATH + theme + "/resources/" + *file, saveLocation + "/resources/" + *file); } 01337 //-- 01338 /* 01339 localDir.setPath(THEMES_PATH + theme + "/misc_resources"); 01340 fileList = localDir.entryList( QDir::Files ); 01341 for ( file = fileList.begin(); file != fileList.end(); ++file ) 01342 { copyFile( THEMES_PATH + theme + "/misc_resources/" + *file, saveLocation + "/misc_resources/" + *file); } 01343 */ 01344 }
|
|
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 505 of file album.cpp. References exportSubalbumImages(), exportThemeResources(), exportTopLevelImages(), exportToXML(), Subalbum::getNext(), Subalbum::getNumPhotos(), getTmpDir(), modified, removeStagnantImages(), removeStagnantOrigFiles(), reorderSubalbumImages(), savedToDisk, saveLocation, StatusWidget::setStatus(), Subalbum::setSubalbumNumber(), StatusWidget::showProgressBar(), status, theme, and transformXMLtoHTML(). 00506 { 00507 //------------------------------------------ 00508 //create subdirs 00509 QDir localDir(saveLocation); 00510 //img dirs 00511 localDir.mkdir("img"); 00512 //subalbum dirs 00513 localDir.setPath(saveLocation + "/img"); 00514 00515 //make a temporary 0 directory for copying new images, they'll be moved to their final 00516 //location during the reordering step 00517 localDir.mkdir( "0" ); 00518 00519 //iterate over each subalbum and create its image directory 00520 Subalbum* current = firstSubalbum; 00521 int collectionNum = 0; 00522 while(current != NULL) 00523 { 00524 collectionNum++; 00525 QString dirName = QString("%1") .arg( collectionNum ); 00526 localDir.mkdir(dirName); 00527 current = current->getNext(); 00528 } 00529 //------------------------------------------ 00530 //checks worked, go ahead with export 00531 00532 //count number of photos 00533 int totalPhotos=0; 00534 current = firstSubalbum; 00535 while(current != NULL) 00536 { 00537 totalPhotos+=current->getNumPhotos(); 00538 current = current->getNext(); 00539 } 00540 00541 //setup progress bar 00542 status->showProgressBar( StatusWidget::tr("Saving:"), 4*totalPhotos ); 00543 qApp->processEvents(); 00544 00545 //copy over theme resources 00546 exportThemeResources( theme ); 00547 00548 //export album cover image, subalbum thumbnails 00549 exportTopLevelImages(); 00550 00551 //export subalbum images (thumbnail, slideshow, and full versions of all images) 00552 exportSubalbumImages(status, forceSave); 00553 00554 //remove any _orig images for photos which have been reverted to their original form 00555 removeStagnantOrigFiles(status); 00556 00557 //apply reordering to all images 00558 reorderSubalbumImages(status); 00559 00560 //reset subalbum numbers to current ordering 00561 current = firstSubalbum; 00562 int n=0; 00563 while(current !=NULL) 00564 { 00565 n++; 00566 current->setSubalbumNumber(n); 00567 current = current->getNext(); 00568 } 00569 00570 //remove collection 0 directory 00571 QDir rootDir(saveLocation + "/img/"); 00572 rootDir.rmdir( "0" ); 00573 00574 //remove old images that nolonger belong 00575 removeStagnantImages(); 00576 00577 //remove previous html/htm files 00578 localDir.setPath(saveLocation); 00579 QStringList list = localDir.entryList( QDir::Files ); 00580 QStringList::Iterator file; 00581 for ( file = list.begin(); file != list.end(); ++file ) 00582 { 00583 if( (*file).endsWith(".html") || (*file).endsWith(".htm") ) 00584 localDir.remove( saveLocation + "/" + *file ); 00585 } 00586 00587 //export xml structure of album 00588 int result = exportToXML(status, saveLocation); 00589 if(result != ALBUM_EXPORTED) { return result; } 00590 00591 //export various html pages using selected theme 00592 transformXMLtoHTML( saveLocation, theme, false ); 00593 00594 //------------------------------------------ 00595 //remove files from temp folder 00596 QDir tmpDirHandle( getTmpDir() ); 00597 QStringList strLst = tmpDirHandle.entryList(); 00598 QStringList::iterator it; 00599 for(it = strLst.begin(); it != strLst.end(); it++) 00600 { 00601 tmpDirHandle.remove( getTmpDir() + "/" + *it); 00602 } 00603 //------------------------------------------ 00604 savedToDisk = true; 00605 00606 //just saved so no modifications since last save 00607 modified = false; 00608 00609 //hide progress bar 00610 status->setStatus( "Album saved." ); 00611 //------------------------------------------ 00612 return ALBUM_EXPORTED; 00613 }
|
|
Exports album in XML and HTML format, along with resized images.
Definition at line 451 of file album.cpp. References nextUniqueID, saveLocation, status, theme, and tmpDir. Referenced by TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum(). 00452 { 00453 //check to see if save location has actually changed, if not don't force save images 00454 //this occurs when user blindly selects the same old spot, or is just changing the theme used by default 00455 bool forceSave = true; 00456 00457 if(saveLocation == dirName) 00458 forceSave = false; 00459 00460 //backup theme and save location, if save fails revert to previous values 00461 QString oldSaveLocation = saveLocation; 00462 QString oldTheme = theme; 00463 00464 //attempt to save album 00465 saveLocation = dirName; 00466 theme = themeName; 00467 int result = exportToDisk(status, forceSave); 00468 00469 //if album saving failed revert save location and theme 00470 if(result != ALBUM_EXPORTED) 00471 { 00472 saveLocation = oldSaveLocation; 00473 theme = oldTheme; 00474 } 00475 //else update tmp save dir 00476 else 00477 { 00478 //remove all old tmp dir contents and directory itself 00479 QDir oldTmpDir(tmpDir); 00480 QString tmpDirName = oldTmpDir.dirName(); 00481 QStringList strLst = oldTmpDir.entryList(); 00482 QStringList::iterator it; 00483 for(it = strLst.begin(); it != strLst.end(); it++) 00484 { 00485 oldTmpDir.remove( tmpDir + "/" + *it); 00486 } 00487 00488 oldTmpDir.cdUp(); 00489 oldTmpDir.rmdir( tmpDirName ); 00490 00491 //create and set new temp dir location 00492 QDir saveDir( saveLocation ); 00493 if(!saveDir.exists( "tmp" )) 00494 saveDir.mkdir( "tmp" ); 00495 tmpDir = saveLocation + "/tmp"; 00496 00497 //reset unique id counter 00498 nextUniqueID = 0; 00499 } 00500 00501 //return result 00502 return result; 00503 }
|
|
Exports top level images.
Definition at line 852 of file album.cpp. References Subalbum::getNext(), Subalbum::getRepresentativeImage(), getRepresentativeImage(), LARGE, and saveLocation. Referenced by exportToDisk(). 00853 { 00854 //if image set export it 00855 if(getRepresentativeImage(LARGE) != NULL) 00856 { 00857 getRepresentativeImage(LARGE)->save(saveLocation + "/img/album.jpg", "JPEG", 95); 00858 } 00859 //else make sure any previously set images are removed 00860 else 00861 { 00862 QDir rootDir(saveLocation + "/img/"); 00863 rootDir.remove(saveLocation + "/img/album.jpg"); 00864 } 00865 00866 //export subalbum thumbs 00867 int n=0; 00868 Subalbum* current = firstSubalbum; 00869 while(current != NULL) 00870 { 00871 n++; 00872 //if subalbum has representative image export it 00873 if(current->getRepresentativeImage(LARGE) != NULL ) 00874 { 00875 QString fileName = QString(saveLocation + "/img/%1_thumb.jpg" ).arg(n); 00876 current->getRepresentativeImage(LARGE)->save(fileName, "JPEG", 95); 00877 } 00878 //otherwise make sure anyprevious set images are removed 00879 else 00880 { 00881 QDir rootDir(saveLocation + "/img/"); 00882 rootDir.remove( saveLocation + QString("/img/%1_thumb.jpg").arg(n) ); 00883 } 00884 current = current->getNext(); 00885 } 00886 }
|
|
Exports album to XML.
Definition at line 800 of file album.cpp. References author, creationDay, creationMonth, creationYear, description, Subalbum::exportToXML(), fixXMLString(), Subalbum::getNext(), getRepresentativeImage(), LARGE, modificationDay, modificationMonth, modificationYear, name, SLIDESHOW_HEIGHT, SLIDESHOW_WIDTH, status, theme, THUMBNAIL_HEIGHT, THUMBNAIL_WIDTH, and updateModificationDate(). Referenced by exportCompressedWebAlbum(), and exportToDisk(). 00801 { 00802 //update modification date 00803 updateModificationDate(); 00804 00805 //create/open xml file 00806 QFile file( exportPath + "/Album.xml" ); 00807 if(file.open(IO_WriteOnly)) 00808 { 00809 //----- 00810 QTextStream stream; 00811 stream.setDevice( &file ); 00812 stream.setEncoding( QTextStream::UnicodeUTF8 ); 00813 00814 //write album information 00815 stream << "<?xml version=\"1.0\"?>\n"; 00816 stream << "<album version=\"1.1\">\n"; 00817 stream << " <name>" << fixXMLString(name) << "</name>\n"; 00818 stream << " <description>" << fixXMLString(description) << "</description>\n"; 00819 stream << " <author>" << fixXMLString(author) << "</author>\n"; 00820 stream << " <created>" << creationYear << " " << creationMonth << " " << creationDay << "</created>\n"; 00821 stream << " <modified>" << modificationYear << " " << modificationMonth << " " << modificationDay << "</modified>\n"; 00822 stream << " <theme>" << theme << "</theme>\n"; 00823 stream << " <thumbnailDimensions>" << THUMBNAIL_WIDTH << " " << THUMBNAIL_HEIGHT << "</thumbnailDimensions>\n"; 00824 stream << " <slideshowDimensions>" << SLIDESHOW_WIDTH << " " << SLIDESHOW_HEIGHT << "</slideshowDimensions>\n"; 00825 00826 //if album has a represenatative image save it's path 00827 if(getRepresentativeImage(LARGE) != NULL ) 00828 { 00829 stream << " <thumb path=\"img/album.jpg\"/>\n"; 00830 } 00831 00832 //write subalbums 00833 Subalbum* current = firstSubalbum; 00834 while(current != NULL) 00835 { 00836 current->exportToXML(status, stream); 00837 current = current->getNext(); 00838 } 00839 00840 //end album 00841 stream << "</album>\n"; 00842 file.close(); 00843 00844 return ALBUM_EXPORTED; 00845 } 00846 else 00847 { 00848 return ALBUM_ERROR_OPEN_FILE; 00849 } 00850 }
|
|
Gets the album author.
Definition at line 125 of file album.cpp. References author. Referenced by TitleWidget::updateAlbumAnnotations(). 00125 { return QString(author); }
|
|
Returnst he creation day.
Definition at line 121 of file album.cpp. Referenced by AlbumStatistics::AlbumStatistics(). 00121 { return creationDay; }
|
|
Returns the creation month.
Definition at line 120 of file album.cpp. Referenced by AlbumStatistics::AlbumStatistics(). 00120 { return creationMonth; }
|
|
Returns the creation year.
Definition at line 119 of file album.cpp. Referenced by AlbumStatistics::AlbumStatistics(). 00119 { return creationYear; }
|
|
Gets the album description.
Definition at line 124 of file album.cpp. References description. Referenced by TitleWidget::updateAlbumAnnotations(). 00124 { return QString(description); }
|
|
Returns a pointer to the first Subalbum.
Definition at line 134 of file album.cpp. Referenced by SlideshowWidget::advanceCollection(), AlbumStatistics::AlbumStatistics(), SlideshowWidget::beginSlideshow(), exportLargeImages(), TitleWidget::loadAlbum(), SubalbumsWidget::refreshCollectionsList(), and SlideshowWidget::showCoverPage(). 00134 { return firstSubalbum; }
|
|
Returns a pointer to the last Subalbum.
Definition at line 135 of file album.cpp. Referenced by SlideshowWidget::backupCollection(). 00135 { return lastSubalbum; }
|
|
Returns the last modified day.
Definition at line 117 of file album.cpp. Referenced by AlbumStatistics::AlbumStatistics(). 00117 { return modificationDay; }
|
|
Returns the last modified month.
Definition at line 116 of file album.cpp. Referenced by AlbumStatistics::AlbumStatistics(). 00116 { return modificationMonth; }
|
|
Returns the last modified year.
Definition at line 115 of file album.cpp. Referenced by AlbumStatistics::AlbumStatistics(). 00115 { return modificationYear; }
|
|
Gets the album name.
Definition at line 123 of file album.cpp. References name. Referenced by AlbumStatistics::AlbumStatistics(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), TitleWidget::saveAlbum(), TitleWidget::saveAsAlbum(), and TitleWidget::updateAlbumAnnotations(). 00123 { return QString(name); }
|
|
Returns the next unique photo id.
Definition at line 1397 of file album.cpp. References nextUniqueID. Referenced by Subalbum::addPhoto(). 01398 { 01399 nextUniqueID++; 01400 return nextUniqueID; 01401 }
|
|
Returns the number of photos.
Definition at line 145 of file album.cpp. References Subalbum::getNext(), and Subalbum::getNumPhotos(). Referenced by AlbumStatistics::AlbumStatistics(), exportCompressedWebAlbum(), TitleWidget::exportLargeImages(), exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum(). 00146 { 00147 //compute number of photos and size on disk 00148 int numPhotos = 0; 00149 Subalbum* curr = firstSubalbum; 00150 while(curr != NULL) 00151 { 00152 numPhotos+= curr->getNumPhotos(); 00153 curr = curr->getNext(); 00154 } 00155 return numPhotos; 00156 }
|
|
Returns number of subalbums.
Definition at line 143 of file album.cpp. Referenced by AlbumStatistics::AlbumStatistics(), SlideshowWidget::backupCollection(), SubalbumsWidget::createAction(), exportLargeImages(), and SlideshowWidget::paintOverlaidControls(). 00143 { return numSubalbums; }
|
|
Returns the representative image.
Definition at line 127 of file album.cpp. Referenced by AlbumStatistics::AlbumStatistics(), exportCompressedWebAlbum(), exportTopLevelImages(), exportToXML(), TitleWidget::setAlbumImage(), and TitleWidget::updateAlbumAnnotations(). 00128 { 00129 if(size == SMALL) return smallRepresentativeImage; 00130 else if(size == LARGE) return largeRepresentativeImage; 00131 else return NULL; 00132 }
|
|
Returns the current save location of all images.
Definition at line 140 of file album.cpp. Referenced by SlideshowWidget::beginSlideshow(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), Photo::originalImageFilename(), TitleWidget::revertToSaved(), TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum(). 00140 { return saveLocation; }
|
|
Returns currently selected theme.
Definition at line 142 of file album.cpp. Referenced by SlideshowWidget::beginSlideshow(), and TitleWidget::saveAsAlbum(). 00142 { return theme; }
|
|
Returns the temporary directory for use when modifying and adding new images.
Definition at line 141 of file album.cpp. Referenced by Album(), Photo::applyTransformation(), exportSubalbumImages(), exportToDisk(), TitleWidget::loadAlbum(), TitleWidget::newAlbum(), Photo::setImage(), and TitleWidget::TitleWidget(). 00141 { return tmpDir; }
|
|
Imports album from XML format, returning int indicates success or not.
Definition at line 294 of file album.cpp. References appendSubalbum(), author, creationDay, creationMonth, creationYear, description, Subalbum::importFromDisk(), name, numLoadedSubalbums, numSubalbums, savedToDisk, saveLocation, setRepresentativeImages(), StatusWidget::setStatus(), StatusWidget::showProgressBar(), status, theme, and updateXML(). Referenced by TitleWidget::loadAlbum(). 00295 { 00296 //update file 00297 updateXML( QFileInfo(fileName).dirPath(TRUE) ); 00298 00299 //open file 00300 QFile albumFile( fileName ); 00301 00302 //unable to open xml file? alert user 00303 if( !albumFile.open( IO_ReadOnly ) ) 00304 return ALBUM_READ_ERROR; 00305 00306 //parse dom 00307 QDomDocument albumDom; 00308 if( !albumDom.setContent( &albumFile ) ) 00309 return ALBUM_XML_ERROR; 00310 00311 //close file 00312 albumFile.close(); 00313 00314 //get main directory all other files and subdirectories are in 00315 QString rootDir = QFileInfo(albumFile).dirPath(TRUE); 00316 saveLocation = rootDir + "/img"; 00317 00318 //if representative image exists load 00319 QImage repImage(rootDir + "/img/album.jpg"); 00320 if(!repImage.isNull()) 00321 { 00322 setRepresentativeImages( rootDir + "/img/album.jpg"); 00323 } 00324 00325 //count number of photos in album, needed for showing loading progress 00326 int numPhotos = 0; 00327 QDomElement root = albumDom.documentElement(); 00328 QDomNode node = root.firstChild(); 00329 while( !node.isNull() ) 00330 { 00331 if( node.isElement() && node.nodeName() == "subalbum" ) 00332 { 00333 QDomNode childNode = node.firstChild(); 00334 while( !childNode.isNull() ) 00335 { 00336 if( childNode.isElement() && childNode.nodeName() == "photo" ) 00337 numPhotos++; 00338 childNode = childNode.nextSibling(); 00339 } 00340 } 00341 node = node.nextSibling(); 00342 } 00343 00344 //setup progress bar 00345 status->showProgressBar( StatusWidget::tr("Loading:"), numPhotos ); 00346 qApp->processEvents(); 00347 00348 int subalbumNum = 0; 00349 00350 //get root node and start parsing DOM 00351 root = albumDom.documentElement(); 00352 node = root.firstChild(); 00353 QDomText val; 00354 while( !node.isNull() ) 00355 { 00356 //------------------------------------------------------------ 00357 //album name 00358 if( node.isElement() && node.nodeName() == "name" ) 00359 { 00360 val = node.firstChild().toText(); 00361 if(!val.isNull()) 00362 name = val.nodeValue(); 00363 name.replace("\\"","\""); 00364 } 00365 //------------------------------------------------------------ 00366 //album description 00367 else if( node.isElement() && node.nodeName() == "description" ) 00368 { 00369 val = node.firstChild().toText(); 00370 if(!val.isNull()) 00371 description = val.nodeValue(); 00372 description.replace("\\"","\""); 00373 } 00374 //------------------------------------------------------------ 00375 //album author 00376 else if( node.isElement() && node.nodeName() == "author" ) 00377 { 00378 val = node.firstChild().toText(); 00379 if(!val.isNull()) 00380 author = val.nodeValue(); 00381 author.replace("\\"","\""); 00382 } 00383 //------------------------------------------------------------ 00384 //album theme 00385 else if( node.isElement() && node.nodeName() == "theme" ) 00386 { 00387 val = node.firstChild().toText(); 00388 if(!val.isNull()) 00389 theme = val.nodeValue(); 00390 theme.replace("\\"","\""); 00391 } 00392 //------------------------------------------------------------ 00393 //album creation date 00394 else if( node.isElement() && node.nodeName() == "created" ) 00395 { 00396 val = node.firstChild().toText(); 00397 00398 //split value based on spaces, should be 7 fields 00399 QStringList vals = QStringList::split( QRegExp(" "), val.nodeValue() ); 00400 int i=0; 00401 int intVals[3]; 00402 QStringList::Iterator it; 00403 for ( it = vals.begin(); it != vals.end(); ++it ) 00404 { 00405 intVals[i] = QString(*it).toInt(); 00406 i++; 00407 //only read first 3 entires, year/month/day, don't overwrite 00408 //buffer on addition entries if xml messed up 00409 if(i > 2) 00410 break; 00411 } 00412 creationYear = intVals[0]; 00413 creationMonth = intVals[1]; 00414 creationDay = intVals[2]; 00415 } 00416 //------------------------------------------------------------ 00417 //subalbum 00418 else if( node.isElement() && node.nodeName() == "subalbum" ) 00419 { 00420 //increase counter 00421 subalbumNum++; 00422 00423 //create new subalbum 00424 Subalbum* salbum = new Subalbum(this, numSubalbums+1); 00425 00426 //populate it 00427 salbum->importFromDisk( &node, subalbumNum, status, (rootDir + "/"), disableCheckPhotoMods ); 00428 00429 //append it to list of subalbums 00430 appendSubalbum(salbum); 00431 } 00432 //------------------------------------------------------------ 00433 //advance to next node 00434 node = node.nextSibling(); 00435 //------------------------------------------------------------ 00436 } 00437 00438 //reset number of loaded subalbums 00439 numLoadedSubalbums = numSubalbums; 00440 00441 //hide progress bar 00442 status->setStatus( "Album loaded." ); 00443 00444 //save load directory name and loaded/saved bit 00445 saveLocation = rootDir; 00446 savedToDisk = true; 00447 00448 return ALBUM_LOADED; 00449 }
|
|
Returns true if album previously saved to disk.
Definition at line 137 of file album.cpp. Referenced by TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum(). 00137 { return savedToDisk; }
|
|
Removes old stagnant images caused when photos are removed from album or moved from one subalbum to another.
Definition at line 1221 of file album.cpp. References Subalbum::getNext(), Subalbum::getNumPhotos(), numLoadedSubalbums, numSubalbums, Subalbum::resetNumLoadedPhotos(), and saveLocation. Referenced by exportToDisk(). 01222 { 01223 QDir rootDir(saveLocation + "/img/"); 01224 01225 //iterate over each collection 01226 int subalbumNumber=0; 01227 Subalbum* currentSubalbum = firstSubalbum; 01228 while(currentSubalbum != NULL) 01229 { 01230 subalbumNumber++; 01231 01232 //remove all photos who are numbered greater 01233 //than the number of photos in the subalbum 01234 int photoNum = currentSubalbum->getNumPhotos()+1; 01235 while(true) 01236 { 01237 QString imageString = QString(saveLocation + "/img/%1/%2.jpg").arg(subalbumNumber).arg(photoNum); 01238 QString origString = QString(saveLocation + "/img/%1/%2_orig.jpg").arg(subalbumNumber).arg(photoNum); 01239 QString slideshowString = QString(saveLocation + "/img/%1/%2_slideshow.jpg").arg(subalbumNumber).arg(photoNum); 01240 QString thumbString = QString(saveLocation + "/img/%1/%2_thumb.jpg").arg(subalbumNumber).arg(photoNum); 01241 01242 //if none of the possible images exist then assume 01243 //no more stagnant images exist in this collection 01244 // 01245 if( !rootDir.exists(imageString) && !rootDir.exists(origString) && 01246 !rootDir.exists(slideshowString) && !rootDir.exists(thumbString) ) 01247 break; 01248 //else delete photos and move on 01249 else 01250 { 01251 rootDir.remove( imageString ); 01252 rootDir.remove( origString ); 01253 rootDir.remove( slideshowString ); 01254 rootDir.remove( thumbString ); 01255 photoNum++; 01256 } 01257 } 01258 01259 //reset number of loaded photos since old photos removed now 01260 currentSubalbum->resetNumLoadedPhotos(); 01261 01262 //move on to next collection 01263 currentSubalbum = currentSubalbum->getNext(); 01264 } 01265 //--------------------------------- 01266 //remove stagnant collections and all their contents 01267 subalbumNumber = numSubalbums+1; 01268 while(true) 01269 { 01270 //check to see if the directory exists, if not we are done 01271 QString imageDirString = QString(saveLocation + "/img/%1/").arg(subalbumNumber); 01272 if( !rootDir.exists(imageDirString) ) 01273 break; 01274 01275 //get filelist for directory 01276 QDir imageDir( imageDirString ); 01277 QStringList list = imageDir.entryList( QDir::Files ); 01278 01279 //remove each file in directory 01280 QStringList::Iterator file; 01281 for ( file = list.begin(); file != list.end(); ++file ) 01282 { rootDir.remove( QString(saveLocation + "/img/%1/" + *file).arg(subalbumNumber) ); } 01283 01284 //remove directory 01285 rootDir.rmdir( QString("%1").arg(subalbumNumber) ); 01286 01287 //remove thumbnail image 01288 rootDir.remove( QString(saveLocation + "/img/%1_thumb.jpg").arg(subalbumNumber) ); 01289 01290 //move on to next subalbum 01291 subalbumNumber++; 01292 } 01293 01294 //reset number of loaded subalbums since stagnant directories removed now 01295 numLoadedSubalbums = numSubalbums; 01296 //--------------------------------- 01297 }
|
|
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 1073 of file album.cpp. References Subalbum::getFirst(), Subalbum::getNext(), Photo::getNext(), Photo::getRecentlyReverted(), StatusWidget::incrementProgress(), Photo::originalImageFilename(), Photo::setRecentlyReverted(), and status. Referenced by exportToDisk(). 01074 { 01075 QDir tmpDir; 01076 01077 //iterate over all collections 01078 Subalbum* currentSubalbum = firstSubalbum; 01079 while(currentSubalbum != NULL) 01080 { 01081 //iterate over all photos in this subalbum 01082 Photo* currentPhoto = currentSubalbum->getFirst(); 01083 while(currentPhoto != NULL) 01084 { 01085 //if photo recently reverted, if so remove orig file 01086 if(currentPhoto->getRecentlyReverted() ) 01087 { 01088 tmpDir.remove( currentPhoto->originalImageFilename() ); 01089 currentPhoto->setRecentlyReverted( false ); 01090 } 01091 01092 //move on to next photo 01093 currentPhoto = currentPhoto->getNext(); 01094 status->incrementProgress(); 01095 qApp->processEvents(); 01096 } 01097 01098 //move on to next subalbum 01099 currentSubalbum = currentSubalbum->getNext(); 01100 } 01101 }
|
|
Removes a subalbum.
Definition at line 256 of file album.cpp. References firstSubalbum, Subalbum::getNext(), Subalbum::getPrev(), lastSubalbum, modified, numSubalbums, Subalbum::setNext(), and Subalbum::setPrev(). Referenced by SubalbumsWidget::deleteAction(). 00257 { 00258 //if passed a null pointer bail! 00259 if( val == NULL) return; 00260 00261 //reset head and tail pointers if necessary 00262 if( val == firstSubalbum ) firstSubalbum = val->getNext(); 00263 if( val == lastSubalbum ) lastSubalbum = val->getPrev(); 00264 00265 //split out 00266 if( val->getPrev() != NULL ) val->getPrev()->setNext( val->getNext() ); 00267 if( val->getNext() != NULL ) val->getNext()->setPrev( val->getPrev() ); 00268 00269 //delete object 00270 delete val; 00271 val = NULL; 00272 numSubalbums--; 00273 modified = true; 00274 }
|
|
Checks if images need to be moved and does so if necessary.
Definition at line 1103 of file album.cpp. References 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 status. Referenced by exportToDisk(). 01104 { 01105 //-------------------------------------------------------- 01106 //-------------------------------------------------------- 01107 //first pass over all photos, those whose initial and current numbers don't match up 01108 //rename slightly so we don't overwrte them the second time around 01109 //-------------------------------------------------------- 01110 //-------------------------------------------------------- 01111 //iterate over all subalbums 01112 QDir tmpDir; 01113 int subalbumNumber=0; 01114 Subalbum* currentSubalbum = firstSubalbum; 01115 while(currentSubalbum != NULL) 01116 { 01117 subalbumNumber++; 01118 01119 //iterate over all photos in this subalbum 01120 int photoNumber=0; 01121 Photo* currentPhoto = currentSubalbum->getFirst(); 01122 while(currentPhoto != NULL) 01123 { 01124 photoNumber++; 01125 int initPhotoNumber = currentPhoto->getInitialPhotoNumber(); 01126 int initSubalbumNumber = currentPhoto->getInitialSubalbumNumber(); 01127 01128 //if photo has moved rename full image, orig image (if it exists), slideshow image, and thumbnail images 01129 if( initPhotoNumber != photoNumber || initSubalbumNumber != subalbumNumber) 01130 { 01131 QString oldName = QString(saveLocation + "/img/%1/%2.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01132 QString newName = QString(saveLocation + "/img/%1/%2_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01133 moveFile( oldName, newName ); 01134 //----- 01135 oldName = QString(saveLocation + "/img/%1/%2_orig.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01136 newName = QString(saveLocation + "/img/%1/%2_orig_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01137 if(tmpDir.exists(oldName) ) { moveFile( oldName, newName ); } 01138 //----- 01139 oldName = QString(saveLocation + "/img/%1/%2_slideshow.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01140 newName = QString(saveLocation + "/img/%1/%2_slideshow_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01141 moveFile( oldName, newName ); 01142 //----- 01143 oldName = QString(saveLocation + "/img/%1/%2_thumb.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01144 newName = QString(saveLocation + "/img/%1/%2_thumb_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01145 moveFile( oldName, newName ); 01146 } 01147 01148 //move on to next photo 01149 currentPhoto = currentPhoto->getNext(); 01150 status->incrementProgress(); 01151 qApp->processEvents(); 01152 } 01153 01154 //move on to next subalbum 01155 currentSubalbum = currentSubalbum->getNext(); 01156 } 01157 01158 //-------------------------------------------------------- 01159 //-------------------------------------------------------- 01160 //second pass over all photos, those whose initial and current numbers don't match up 01161 //rename to their final names and reset initial photo and subalbum numbers 01162 //-------------------------------------------------------- 01163 //-------------------------------------------------------- 01164 //iterate over all subalbums 01165 subalbumNumber=0; 01166 currentSubalbum = firstSubalbum; 01167 while(currentSubalbum != NULL) 01168 { 01169 subalbumNumber++; 01170 01171 //iterate over all photos in this subalbum 01172 int photoNumber=0; 01173 Photo* currentPhoto = currentSubalbum->getFirst(); 01174 while(currentPhoto != NULL) 01175 { 01176 photoNumber++; 01177 int initPhotoNumber = currentPhoto->getInitialPhotoNumber(); 01178 int initSubalbumNumber = currentPhoto->getInitialSubalbumNumber(); 01179 01180 //if the current photo has moved rename full image, slideshow image, and thumbnail image to their final names 01181 if( initPhotoNumber != photoNumber || initSubalbumNumber != subalbumNumber) 01182 { 01183 QString oldName = QString(saveLocation + "/img/%1/%2_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01184 QString newName = QString(saveLocation + "/img/%1/%2.jpg" ).arg(subalbumNumber).arg(photoNumber); 01185 moveFile( oldName, newName ); 01186 //----- 01187 oldName = QString(saveLocation + "/img/%1/%2_orig_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01188 newName = QString(saveLocation + "/img/%1/%2_orig.jpg" ).arg(subalbumNumber).arg(photoNumber); 01189 if(tmpDir.exists(oldName) ) { moveFile( oldName, newName ); } 01190 //----- 01191 oldName = QString(saveLocation + "/img/%1/%2_slideshow_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01192 newName = QString(saveLocation + "/img/%1/%2_slideshow.jpg" ).arg(subalbumNumber).arg(photoNumber); 01193 moveFile( oldName, newName ); 01194 //----- 01195 oldName = QString(saveLocation + "/img/%1/%2_thumb_moved.jpg" ).arg(initSubalbumNumber).arg(initPhotoNumber); 01196 newName = QString(saveLocation + "/img/%1/%2_thumb.jpg" ).arg(subalbumNumber).arg(photoNumber); 01197 moveFile( oldName, newName ); 01198 //--------------------------------------- 01199 //reset initial photo and subalbum numbers, and filenames 01200 currentPhoto->setInitialPhotoNumber(photoNumber); 01201 currentPhoto->setInitialSubalbumNumber(subalbumNumber); 01202 currentPhoto->setImageFilename( QString(saveLocation + "/img/%1/%2.jpg"). 01203 arg(subalbumNumber).arg(photoNumber) ); 01204 currentPhoto->setSlideshowFilename( QString(saveLocation + "/img/%1/%2_slideshow.jpg"). 01205 arg(subalbumNumber).arg(photoNumber) ); 01206 currentPhoto->setThumbnailFilename( QString(saveLocation + "/img/%1/%2_thumb.jpg"). 01207 arg(subalbumNumber).arg(photoNumber) ); 01208 } 01209 01210 //move on to next photo 01211 currentPhoto = currentPhoto->getNext(); 01212 status->incrementProgress(); 01213 qApp->processEvents(); 01214 } 01215 01216 //move on to next subalbum 01217 currentSubalbum = currentSubalbum->getNext(); 01218 } 01219 }
|
|
Sets the album author.
Definition at line 176 of file album.cpp. References author, and modified. Referenced by TitleWidget::storeAnnotations().
|
|
Sets the album description.
Definition at line 167 of file album.cpp. References description, and modified. Referenced by TitleWidget::storeAnnotations(). 00168 { 00169 if(description != val) 00170 { 00171 description = val; 00172 modified = true; 00173 } 00174 }
|
|
Sets the album as modified.
Definition at line 1395 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(). 01395 { modified = val; }
|
|
Sets the album name.
Definition at line 158 of file album.cpp. References modified, and name. Referenced by TitleWidget::storeAnnotations().
|
|
Sets the representative image.
Definition at line 185 of file album.cpp. References calcScaledImageDimensions(), getImageSize(), largeRepresentativeImage, modified, REP_IMAGE_HEIGHT, scaleImage(), and smallRepresentativeImage. Referenced by importFromDisk(), TitleWidget::setAlbumImage(), and TitleWidget::unsetAlbumImage(). 00186 { 00187 //delete representative images 00188 delete smallRepresentativeImage; 00189 delete largeRepresentativeImage; 00190 00191 //if being set to null, set back to defaults 00192 if(imageFilename.isNull()) 00193 { 00194 smallRepresentativeImage = NULL; 00195 largeRepresentativeImage = NULL; 00196 } 00197 else 00198 { 00199 //compute representative image sizes 00200 int imageWidth, imageHeight; 00201 getImageSize( imageFilename, imageWidth, imageHeight ); 00202 00203 int smallRepWidth = 0; 00204 int smallRepHeight = 0; 00205 int largeRepWidth = 0; 00206 int largeRepHeight = 0; 00207 calcScaledImageDimensions( imageWidth, imageHeight, 00208 107, REP_IMAGE_HEIGHT, 00209 smallRepWidth, smallRepHeight); 00210 calcScaledImageDimensions( imageWidth, imageHeight, 00211 500, 320, 00212 largeRepWidth, largeRepHeight); 00213 00214 //create various representative images 00215 00216 //copy and scale small version 00217 QImage thumbnailSmall; 00218 scaleImage( imageFilename, thumbnailSmall, smallRepWidth, smallRepHeight ); 00219 smallRepresentativeImage = new QPixmap( thumbnailSmall.width(), thumbnailSmall.height() ); 00220 smallRepresentativeImage->convertFromImage( thumbnailSmall ); 00221 00222 //copy and scale large version 00223 QImage thumbnailLarge; 00224 scaleImage( imageFilename, thumbnailLarge, largeRepWidth, largeRepHeight ); 00225 largeRepresentativeImage = new QPixmap( thumbnailLarge.width(), thumbnailLarge.height() ); 00226 largeRepresentativeImage->convertFromImage( thumbnailLarge ); 00227 } 00228 00229 //set modified 00230 modified = true; 00231 }
|
|
Syncs subalbum ordering with front end gui ordering.
Definition at line 1346 of file album.cpp. References firstSubalbum, Subalbum::getNext(), SubalbumPreviewWidget::getSubalbum(), lastSubalbum, Subalbum::setNext(), and Subalbum::setPrev(). Referenced by SubalbumsWidget::reorder(). 01347 { 01348 //check to see if any changes actually took place 01349 bool change = false; 01350 Subalbum* tmp = firstSubalbum; 01351 SubalbumPreviewWidget* tmp2 = item; 01352 while( tmp2 != NULL) 01353 { 01354 //pointers do not match up 01355 if(tmp != tmp2->getSubalbum() ) 01356 { 01357 change = true; 01358 break; 01359 } 01360 01361 tmp = tmp->getNext(); 01362 tmp2 = (SubalbumPreviewWidget*)tmp2->nextItem(); 01363 } 01364 01365 //if no change then quit 01366 if(!change) 01367 return; 01368 01369 //base case, no items 01370 if(item == NULL) 01371 { 01372 firstSubalbum = NULL; 01373 lastSubalbum = NULL; 01374 return; 01375 } 01376 01377 //set first and last pointers 01378 firstSubalbum = item->getSubalbum(); 01379 firstSubalbum->setNext(NULL); 01380 firstSubalbum->setPrev(NULL); 01381 lastSubalbum = firstSubalbum; 01382 01383 //set all next pointers 01384 while(item->nextItem() != NULL) 01385 { 01386 item->getSubalbum()->setNext( ((SubalbumPreviewWidget*)item->nextItem())->getSubalbum() ); 01387 item->getSubalbum()->getNext()->setPrev( item->getSubalbum() ); 01388 item = (SubalbumPreviewWidget*)item->nextItem(); 01389 lastSubalbum = item->getSubalbum(); 01390 lastSubalbum->setNext(NULL); 01391 } 01392 01393 }
|
|
Updates the creation date to today's date.
Definition at line 276 of file album.cpp. References creationDay, creationMonth, and creationYear. Referenced by Album(). 00277 { 00278 //set creation date to today 00279 QDate date = QDate::currentDate(); 00280 creationYear = date.year(); 00281 creationMonth = date.month(); 00282 creationDay = date.day(); 00283 }
|
|
Updates the modification date to today's date.
Definition at line 285 of file album.cpp. References modificationDay, modificationMonth, and modificationYear. Referenced by Album(), and exportToXML(). 00286 { 00287 //set last modification date to today 00288 QDate date = QDate::currentDate(); 00289 modificationYear = date.year(); 00290 modificationMonth = date.month(); 00291 modificationDay = date.day(); 00292 }
|
|
Album Creator.
Definition at line 199 of file album.h. Referenced by Album(), exportToXML(), getAuthor(), importFromDisk(), and setAuthor(). |
|
Creation day.
Definition at line 227 of file album.h. Referenced by exportToXML(), importFromDisk(), and updateCreationDate(). |
|
Creation month.
Definition at line 224 of file album.h. Referenced by exportToXML(), importFromDisk(), and updateCreationDate(). |
|
Creation year.
Definition at line 221 of file album.h. Referenced by exportToXML(), importFromDisk(), and updateCreationDate(). |
|
Longer description of album.
Definition at line 196 of file album.h. Referenced by Album(), exportToXML(), getDescription(), importFromDisk(), and setDescription(). |
|
Pointer to first Subalbum.
Definition at line 206 of file album.h. Referenced by Album(), appendSubalbum(), removeSubalbum(), and syncSubalbumList(). |
|
Definition at line 203 of file album.h. Referenced by Album(), and setRepresentativeImages(). |
|
Pointer to last Subalbum.
Definition at line 209 of file album.h. Referenced by Album(), appendSubalbum(), removeSubalbum(), and syncSubalbumList(). |
|
Last modification day.
Definition at line 218 of file album.h. Referenced by exportToXML(), and updateModificationDate(). |
|
Last modification month.
Definition at line 215 of file album.h. Referenced by exportToXML(), and updateModificationDate(). |
|
Last modification year.
Definition at line 212 of file album.h. Referenced by exportToXML(), and updateModificationDate(). |
|
Modification status of the album.
Definition at line 245 of file album.h. Referenced by Album(), appendSubalbum(), exportToDisk(), removeSubalbum(), setAuthor(), setDescription(), setModified(), setName(), and setRepresentativeImages(). |
|
Short name for album.
Definition at line 193 of file album.h. Referenced by Album(), exportToXML(), getName(), importFromDisk(), and setName(). |
|
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 253 of file album.h. Referenced by Album(), exportToDisk(), and getNextUniquePhotoID(). |
|
Number of loaded subalbums.
Definition at line 233 of file album.h. Referenced by Album(), importFromDisk(), and removeStagnantImages(). |
|
Number of subalbums.
Definition at line 230 of file album.h. Referenced by Album(), appendSubalbum(), importFromDisk(), removeStagnantImages(), and removeSubalbum(). |
|
Set if album was loaded/has been saved to disk.
Definition at line 236 of file album.h. Referenced by Album(), exportToDisk(), and importFromDisk(). |
|
Directory album saved to.
Definition at line 239 of file album.h. Referenced by Album(), exportSubalbumImages(), exportThemeResources(), exportToDisk(), exportTopLevelImages(), importFromDisk(), removeStagnantImages(), and reorderSubalbumImages(). |
|
Representative images.
Definition at line 202 of file album.h. Referenced by Album(), and setRepresentativeImages(). |
|
Theme to save album with.
Definition at line 242 of file album.h. Referenced by Album(), exportCompressedWebAlbum(), exportToDisk(), exportToXML(), and importFromDisk(). |
|
Temporary directory for placing modified or new images before saving takes place.
Definition at line 248 of file album.h. Referenced by exportToDisk(), and ~Album(). |