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

bool Subalbum::addPhoto ( QString  fileName,
bool  replaceDescription = false,
Photo newPhoto = NULL 

Adds a new photo to the Subalbum and appends it to the end, returns TRUE if successful

Definition at line 197 of file subalbum.cpp.

References albm, firstPhoto, getLast(), Album::getNextUniquePhotoID(), lastPhoto, numPhotos, Photo::setDescription(), Photo::setImage(), Album::setModified(), Photo::setNext(), and Photo::setPrev().

Referenced by importFromDisk().

  //create new photo if necessary
  if(newPhoto == NULL)
    newPhoto = new Photo(this, getLast(), numPhotos);

  //replace description with filename if instructed
  //(aka /home/bob/happy.jpg -> happy)
    //get filename
    QString desc(fileName);

    //remove path
    desc = desc.section( QRegExp("/"), -1);

    //remove extension if it exists
    int extensionIndex = desc.findRev( '.' );
    if(extensionIndex > 0 )

    //convert _'s to spaces
    desc = desc.replace('_', ' ');

    //set photos description
    newPhoto->setDescription( desc );

  //attempt to set image
  if(!newPhoto->setImage(fileName, albm->getNextUniquePhotoID() ))
    delete newPhoto;
    return false;

  //if this is the first photo set as the head
  if(firstPhoto == NULL)
    firstPhoto = newPhoto;
    lastPhoto = newPhoto;
  //else append to end of list
    newPhoto->setPrev( lastPhoto );
    lastPhoto = newPhoto;

  return true;

Generated by  Doxygen 1.6.0   Back to index