Logo Search packages:      
Sourcecode: albumshaper version File versions  Download package

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 exportSubalbumImages(), exportThemeResources(), exportTopLevelImages(), exportToXML(), firstSubalbum, Subalbum::getNext(), Subalbum::getNumPhotos(), getTmpDir(), modified, removeStagnantImages(), removeStagnantOrigFiles(), reorderSubalbumImages(), savedToDisk, saveLocation, Subalbum::setSubalbumNumber(), and theme.

{
  //------------------------------------------
  //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;
}


Generated by  Doxygen 1.6.0   Back to index