AlbumShaper  1.0a3
Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes
SubalbumWidget Class Reference

Displays subalbum layout. More...

#include <subalbumWidget.h>

Inheritance diagram for SubalbumWidget:
Inheritance graph
[legend]
Collaboration diagram for SubalbumWidget:
Collaboration graph
[legend]

List of all members.

Signals

void selectedPhotoStateChanged ()

Public Member Functions

 SubalbumWidget (Subalbum *salbum, QWidget *parent=0, const char *name=0)
 Creates layout based on backend object.
void setSubalbum (Subalbum *salbum)
 Resets the subalbum this subalbum widget is displaying.
void refreshPhotos ()
 clears and reinserts all photos for the current collection the current selection is cleared
void refreshAllPhotos ()
 refreshes all photos, selections are preserved
void refreshSelectedPhotos ()
 refreshes selected photos, selections are preserved
SubalbumgetSubalbum ()
 returns a pointer to the backend subalbum
PhotogetSelectedPhoto ()
 Returns currently selected photo. If no or multiple photos selected returns NULL.
void setSelectedPhoto (Photo *selection)
 Sets the selected photo to selection and ensures it is visible.
PhotogetFirstSelectedPhoto ()
 Returns first selected photo.
bool anyPhotosSelected ()
 Returns true if any phtos are selected.
bool anySelectedPhotosRevertable ()
 Returns true if any selected photos are revertable.
QIconViewgetPhotos ()
 Returns pointer to icon view.
void updateButtons (bool enable)
 Activates/Deactives remove/rotate buttons.
void stripDescriptionsFromSelectedPhotos ()
 Strip descriptions from selected photos.
void revertSelectedPhotos ()
 Revert selected photos to their original form.

Protected Member Functions

void resizeEvent (QResizeEvent *)

Private Slots

void setWallpaperAction ()
 set desktop wallpaper
void selectionChangedEvent ()
 handles changing selections
void updateButtons ()
 Activates/Deactives remove/rotate buttons depending on if an image is selected.
void addImageAction ()
 Adds an image to the subalbum.
void addImageAction (QStringList fileNames, bool setDescriptions=false)
void removeImageAction ()
 Remove an image from the subalbum.
void rotate90ImageAction ()
 Rotate clockwise selected images.
void rotate270ImageAction ()
 Rotate counter-clockwise selected images.
void reorder ()
void deselectAll ()

Private Attributes

QGridLayout * mainGrid
 Grids widgets are placed in.
QGridLayout * buttonsGrid
QFramethumbnailFrame
 Grid lower buttons are placed in.
QFramebuttonsFrame
PhotosIconViewphotos
 Photos layout.
Subalbumsubalbum
 Pointer to backend subalbum.
QToolButton * addImage
 "Add" button
QToolButton * removeImage
 "Remove" button
QToolButton * rotate90Image
 "Rotate 90" button
QToolButton * rotate270Image
 "Rotate 270" button
QToolButton * setDesktopBtn
 Set desktop wallpaper button.
LayoutWidgetlayout
 Pointer to the parent layout widget.
bool buttonsState
 cached enabled/disabled state of buttons
bool wallpaperButtonState
 cached enabled/distable state of set wallpaper button

Detailed Description

Displays subalbum layout.

Definition at line 35 of file subalbumWidget.h.


Constructor & Destructor Documentation

SubalbumWidget::SubalbumWidget ( Subalbum salbum,
QWidget parent = 0,
const char *  name = 0 
)

Creates layout based on backend object.

Definition at line 49 of file subalbumWidget.cpp.

References addImage, addImageAction(), buttonsFrame, buttonsGrid, deselectAll(), IMAGE_PATH, layout, mainGrid, photos, removeImage, removeImageAction(), reorder(), rotate270Image, rotate270ImageAction(), rotate90Image, rotate90ImageAction(), selectionChangedEvent(), setDesktopBtn, setWallpaperAction(), setWallpaperSupported(), and subalbum.

                                                  :
                               QWidget(parent,name)
{
  setWFlags(WNoAutoErase);

  //store subalbum pointer
  subalbum = salbum;

  //store layout pointer
  layout = (LayoutWidget*)parent;

  //create photo collection
  photos = new PhotosIconView( this );

  //establish a top-down view such that the scrollbar is always placed on the right
  photos->setArrangement( QIconView::LeftToRight );
  photos->setVScrollBarMode( QScrollView::Auto );

  //allow multiple photos to be selected with control and shift keys
  photos->setSelectionMode( QIconView::Extended ) ;

  //set auto-scroll on for drag-n-drop
  photos->setDragAutoScroll(true);
  photos->setAcceptDrops(true);

  //connect selectionChanged signal to update buttons method
  connect( photos, SIGNAL(selectionChanged()),
           this, SLOT( selectionChangedEvent()) );

  //connect rightButtonClicked signal to update buttons method
  connect( photos, SIGNAL(rightButtonClicked(QIconViewItem*, const QPoint&)),
           this, SLOT(selectionChangedEvent()) );
  
  //connect itemhasMoved signal on iconview to reorder slot (phots have been rearranged)
  connect( photos, SIGNAL(itemHasMoved()), SLOT(reorder()) );

  //connect addPhtos signal from iconview to actually add photos from disk (Drop from outside target, ie konqueror)
  connect( photos, SIGNAL(addPhotos(QStringList)), SLOT(addImageAction(QStringList)) );

  //connect keyevent signals from iconview
  connect( photos, SIGNAL(removeSelectedPhotos()), SLOT(removeImageAction()) );
  connect( photos, SIGNAL(rotate90SelectedPhotos()), SLOT(rotate90ImageAction()) );
  connect( photos, SIGNAL(rotate270SelectedPhotos()), SLOT(rotate270ImageAction()) );

  //connect key e press signal to edit slot
  connect( photos, SIGNAL(editSelectedPhoto()), 
           layout, SLOT(editSelectedPhoto()) );
  //connect double click signal to edit slot
  connect( photos, SIGNAL( doubleClicked(QIconViewItem*) ), 
           layout, SLOT(editSelectedPhoto()) );

  //create all buttons
  buttonsFrame = new QFrame(this);
  if(subalbum == NULL) buttonsFrame->hide();

  QFont buttonFont( qApp->font() );
  buttonFont.setBold(true);
  buttonFont.setPointSize( 11 );

  addImage = new QToolButton( buttonsFrame );
  addImage->setTextLabel(tr("Add Photo"));
  addImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/add.png") );
  addImage->setTextPosition(QToolButton::Right);
  addImage->setFont( buttonFont );
  addImage->setUsesTextLabel( true );
  addImage->setEnabled( true );
  QToolTip::add( addImage, tr("Add photos to selected collection") );
  connect( addImage, SIGNAL(clicked()), SLOT(addImageAction()) );

  removeImage = new QToolButton( buttonsFrame );
  removeImage->setTextLabel(tr("Remove Photo"));
  removeImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/remove.png") );
  removeImage->setTextPosition(QToolButton::Right);
  removeImage->setFont( buttonFont );
  removeImage->setUsesTextLabel( true );
  removeImage->setEnabled( true );
  QToolTip::add( removeImage, tr("Remove selected photos from collection") );
  connect( removeImage, SIGNAL(clicked()), SLOT(removeImageAction()) );

  rotate90Image = new QToolButton( buttonsFrame );
  rotate90Image->setTextLabel(tr("Rotate Right") );
  QIconSet rotate90Icon;
  rotate90Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate90.png",
                      QIconSet::Automatic,
                      QIconSet::Normal );
  rotate90Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate90_disabled.png",
                      QIconSet::Automatic,
                      QIconSet::Disabled );
  rotate90Image->setIconSet( rotate90Icon );
  
  rotate90Image->setTextPosition(QToolButton::Right);
  rotate90Image->setFont( buttonFont );
  rotate90Image->setUsesTextLabel( true );
  QToolTip::add( rotate90Image, tr("Rotate selected photos clockwise") );
  connect( rotate90Image, SIGNAL(clicked()), SLOT(rotate90ImageAction()) );

  rotate270Image = new QToolButton( buttonsFrame );
  rotate270Image->setTextLabel(tr("Rotate Left") );
  QIconSet rotate270Icon;
  rotate270Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate270.png",
                          QIconSet::Automatic,
                          QIconSet::Normal );
  rotate270Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate270_disabled.png",
                          QIconSet::Automatic,
                          QIconSet::Disabled );
  rotate270Image->setIconSet( rotate270Icon );

  rotate270Image->setTextPosition(QToolButton::Right);
  rotate270Image->setFont( buttonFont );
  rotate270Image->setUsesTextLabel( true );
  QToolTip::add( rotate270Image, tr("Rotate selected photos counterclockwise") );
  connect( rotate270Image, SIGNAL(clicked()), SLOT(rotate270ImageAction()) );

  //place all items in grid layout
  buttonsGrid = new QGridLayout( buttonsFrame,             1, 7, 0 );
  buttonsGrid->addWidget( addImage,                   0, 1, Qt::AlignLeft );
  buttonsGrid->addWidget( removeImage,                0, 2, Qt::AlignLeft );
  buttonsGrid->addWidget( rotate90Image,              0, 3, Qt::AlignLeft );
  buttonsGrid->addWidget( rotate270Image,             0, 4, Qt::AlignLeft );
  buttonsGrid->setColStretch( 0, 1 );
  buttonsGrid->setColStretch( 6, 1 );

  //If setting the desktop wallpaper is supported on this system then add this button as well
  if( setWallpaperSupported() )
  {
    setDesktopBtn = new QToolButton( buttonsFrame );
    setDesktopBtn->setUsesTextLabel( true );
    setDesktopBtn->setTextLabel(tr("Wallpaper") );
    QIconSet setDesktopIcon;
    setDesktopIcon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/setDesktopWallpaper.png",
                            QIconSet::Automatic,
                            QIconSet::Normal );
    setDesktopIcon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/setDesktopWallpaper_disabled.png",
                            QIconSet::Automatic,
                            QIconSet::Disabled );
    setDesktopBtn->setIconSet( setDesktopIcon );
    
    setDesktopBtn->setTextPosition(QToolButton::Right);
    setDesktopBtn->setFont( buttonFont );
    setDesktopBtn->setUsesTextLabel( true );
    
    QToolTip::add( setDesktopBtn, tr("Set desktop wallpaper to selected photo") );
    connect( setDesktopBtn, SIGNAL( clicked() ), this, SLOT( setWallpaperAction() ) );
    buttonsGrid->addWidget( setDesktopBtn,              0, 5, Qt::AlignLeft );
  }
  else
  { setDesktopBtn = NULL; }

  mainGrid = new QGridLayout( this, 2, 1, 0 );
  mainGrid->addMultiCellWidget( photos, 0, 0, 0, 1 );
  mainGrid->addMultiCellWidget( buttonsFrame, 1, 1, 0, 1 );
  mainGrid->setRowStretch( 0, 1 );

  //set the background of the widget to be light blue
  setPaletteBackgroundColor( QColor(193, 210, 238) );

  //by default no selected images so disable all buttons besides add
  removeImage->setEnabled(false);
  rotate90Image->setEnabled(false);
  rotate270Image->setEnabled(false);
   
  //hook-up keyboard shortcut for deselecting all photos
  //iconview provides select all shortcut for us
  QAccel *keyAccel = new QAccel( this );
  keyAccel->connectItem( keyAccel->insertItem( CTRL + SHIFT + Key_A ),
                         this, SLOT(deselectAll()) );
}

Member Function Documentation

void SubalbumWidget::addImageAction ( ) [private, slot]

Adds an image to the subalbum.

Definition at line 236 of file subalbumWidget.cpp.

References AddPhotosDialog::getFilenames(), Configuration::getString(), Configuration::resetSetting(), and Configuration::setString().

Referenced by SubalbumWidget().

{
  //---------------
  //get file list

  Configuration* config = ((Window*)qApp->mainWidget())->getConfig();
  QString path = config->getString( "loadSave", "addPhotoDir" );
  QDir testPath(path);
  if(!testPath.exists())
  {
    config->resetSetting( "loadSave", "addPhotoDir" );
    path = config->getString( "loadSave", "addPhotoDir" );
  }

  AddPhotosDialog* fileDialog = new AddPhotosDialog( path );
  bool setDescriptions;
  QStringList fileNames = fileDialog->getFilenames( setDescriptions );

   if(!fileNames.empty())
   {
     //store this addPhoto location
     QDir lastDir = QDir( QFileInfo(*fileNames.begin()).dirPath() );
     config->setString( "loadSave", "addPhotoDir", lastDir.path() );
     addImageAction( fileNames, setDescriptions );
  }
}
void SubalbumWidget::addImageAction ( QStringList  fileNames,
bool  setDescriptions = false 
) [private, slot]

Definition at line 263 of file subalbumWidget.cpp.

References Subalbum::addPhoto(), Subalbum::getLast(), Window::getStatus(), LayoutWidget::getSubalbums(), Window::getTitle(), LayoutWidget::getWindow(), layout, photos, TitleWidget::setBusy(), StatusWidget::setStatus(), StatusWidget::showProgressBar(), subalbum, SubalbumsWidget::updateButtons(), updateButtons(), TitleWidget::updateMenus(), and StatusWidget::updateProgress().

{
   if(fileNames.empty())
     return;

  //---------------
  //set busy flag and deactivate menu's/buttons, and selecting photos
  layout->getWindow()->getTitle()->setBusy(true);
  layout->getSubalbums()->updateButtons(false);
  updateButtons(false);
  photos->setSelectionMode( QIconView::NoSelection ) ;

  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
  
  //setup progress bar
  QString statusMessage = tr("Adding %1 photos:");
  
  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(fileNames.count()), fileNames.count() );
  qApp->processEvents();

  //iterate through each file and add to album
  QStringList::iterator it;
  int num=0;
  for(it = fileNames.begin(); it != fileNames.end(); it++ )
  {
    //update status message
    layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(fileNames.count() - num) );

    //if item is a file, add photo
    if(QFileInfo(*it).isFile() && subalbum->addPhoto(*it, setDescriptions))
    {
      PhotoPreviewWidget* p =  new PhotoPreviewWidget( photos, subalbum->getLast() );
      photos->ensureItemVisible(p);
    }
    num++;
    qApp->processEvents();
  }
  photos->arrangeItemsInGrid();

  //remove progress bar
  layout->getWindow()->getStatus()->setStatus( tr("Adding photos complete.") );
  
  //notifty title widget that the album's photo count has possible changed
  layout->getWindow()->getTitle()->updateMenus();

  //unset busy flag and activate menu's/buttons
  layout->getWindow()->getTitle()->setBusy(false);
  layout->getSubalbums()->updateButtons(true);
  updateButtons(true);
  photos->setSelectionMode( QIconView::Extended ) ;
 
  qApp->restoreOverrideCursor();
}
bool SubalbumWidget::anyPhotosSelected ( )

Returns true if any phtos are selected.

Definition at line 653 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::photoStateChangedEvent(), and TitleWidget::removeSelectedPhotoDesc().

{
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    if(current->isSelected())
      return true;
    current = current->nextItem();
  }
  return false;
}
bool SubalbumWidget::anySelectedPhotosRevertable ( )

Returns true if any selected photos are revertable.

Definition at line 665 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::photoStateChangedEvent().

{
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    if(current->isSelected())
    {
      if( ((PhotoPreviewWidget*)current)->getPhoto()->revertPossible() )
        return true;
    }
    current = current->nextItem();
  }
  return false;
}
void SubalbumWidget::deselectAll ( ) [private, slot]

Definition at line 779 of file subalbumWidget.cpp.

References photos.

Referenced by SubalbumWidget().

{
  photos->selectAll(false);
}
Photo * SubalbumWidget::getFirstSelectedPhoto ( )

Returns first selected photo.

Definition at line 612 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::tabChanged().

{
  //determine if one photo is selected
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    //found a selected item!
    if(current->isSelected()) 
    { return ((PhotoPreviewWidget*)current)->getPhoto(); }   
    
    //move to next item
    current = current->nextItem();
  }
  
  //no selected items found
  return NULL;
}
QIconView * SubalbumWidget::getPhotos ( )

Returns pointer to icon view.

Definition at line 685 of file subalbumWidget.cpp.

References photos.

Referenced by TitleWidget::dropEvent(), and SubalbumPreviewWidget::dropped().

{
  return photos;
}
Photo * SubalbumWidget::getSelectedPhoto ( )

Returns currently selected photo. If no or multiple photos selected returns NULL.

Definition at line 585 of file subalbumWidget.cpp.

References photos.

Referenced by TitleWidget::setAlbumImage(), TitleWidget::setSubalbumImage(), and setWallpaperAction().

{
  //determine if one photo is selected
  int numSelected = 0;
  QIconViewItem* current = photos->firstItem();
  QIconViewItem* selected = NULL;
  while(current != NULL)
  {
    //found a selected item!
    if(current->isSelected())
    {
      numSelected++;
      selected = current;
    }

    //if more than one found then bail!
    if(numSelected > 1) return NULL;

    //move to next item
    current = current->nextItem();
  }

  //if one item is selected then return photo pointer
  if(numSelected == 1) { return ((PhotoPreviewWidget*)selected)->getPhoto(); }
  else { return NULL; }
}
Subalbum * SubalbumWidget::getSubalbum ( )

returns a pointer to the backend subalbum

Definition at line 580 of file subalbumWidget.cpp.

References subalbum.

Referenced by SubalbumPreviewWidget::dropped(), TitleWidget::setSubalbumImage(), and LayoutWidget::tabChanged().

{
  return subalbum;
}
void SubalbumWidget::refreshAllPhotos ( )

refreshes all photos, selections are preserved

Definition at line 535 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::tabChanged().

{
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    ((PhotoPreviewWidget*)current)->updateImage();
    ((PhotoPreviewWidget*)current)->updateDescription();
    current = current->nextItem();
  }
}
void SubalbumWidget::refreshPhotos ( )

clears and reinserts all photos for the current collection the current selection is cleared

Definition at line 516 of file subalbumWidget.cpp.

References Subalbum::getFirst(), Photo::getNext(), photos, and subalbum.

Referenced by setSubalbum().

{
  //remove all thumbnails
  photos->clear();

  if(subalbum != NULL)
  {
    //insert photo thumbnails
    Photo* currentPhoto = subalbum->getFirst();
    while(currentPhoto != NULL)
    {
      new PhotoPreviewWidget( photos, currentPhoto );
      currentPhoto = currentPhoto->getNext();
    }

    photos->arrangeItemsInGrid();
  }
}
void SubalbumWidget::refreshSelectedPhotos ( )

refreshes selected photos, selections are preserved

Definition at line 546 of file subalbumWidget.cpp.

References photos.

{
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    //found a selected item!
    if(current->isSelected())
    {
      ((PhotoPreviewWidget*)current)->updateImage();
      ((PhotoPreviewWidget*)current)->updateDescription();
    }

    //move to next item
    current = current->nextItem();
  }
}
void SubalbumWidget::removeImageAction ( ) [private, slot]

Remove an image from the subalbum.

Definition at line 317 of file subalbumWidget.cpp.

References LayoutWidget::getSubalbums(), Window::getTitle(), LayoutWidget::getWindow(), layout, photos, Subalbum::removePhoto(), selectionChangedEvent(), TitleWidget::setBusy(), subalbum, SubalbumsWidget::updateButtons(), and updateButtons().

Referenced by SubalbumWidget().

{
  //set busy flag and deactivate menu's/buttons
  layout->getWindow()->getTitle()->setBusy(true);
  layout->getSubalbums()->updateButtons(false);
  updateButtons(false);
  photos->setSelectionMode( QIconView::NoSelection ) ;

  //if user has chosen to not receive destructive action warnings, or agrees to the action, then
  //delete photo and refresh view
  bool proceed = !((Window*)qApp->mainWidget())->getConfig()->getBool( "alerts", "showDestructiveAlerts" );
  if(!proceed)
  {
    QuestionDialog sure( tr("Remove selected photos?"),
                       tr("Once removed photos cannot be restored. Furthermore upon resaving they are physically removed from your album."),
                       "alertIcons/warning.png",
                       this );
    proceed = sure.exec();
  }
  if(proceed)
  {
    qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
    //iterate through all photos and remove those that are selected
    QIconViewItem* current = photos->firstItem();
    QIconViewItem* temp;

    while(current != NULL)
    {
      //if not selected move on
      if(!current->isSelected())
      {
        current = current->nextItem();
        continue;
      }
      
      //get next pointer
      temp = current->nextItem();

      //grab point to backend photo
      Photo* phto = ((PhotoPreviewWidget*)current)->getPhoto();

      //delete photo widget
      delete current;
      current = temp;

      //delete backend photo
      subalbum->removePhoto(phto);
    }

    //cleanup arrangement in case items were deleted in the middle or front
    photos->arrangeItemsInGrid();

    //unset busy flag and activate menu's/buttons
    qApp->restoreOverrideCursor();
  }

  layout->getWindow()->getTitle()->setBusy(false);
  layout->getSubalbums()->updateButtons(true);
  updateButtons(true);
  photos->setSelectionMode( QIconView::Extended ) ;

  //update buttons and emit selection changed signal
  selectionChangedEvent();
}
void SubalbumWidget::reorder ( ) [private, slot]

Definition at line 690 of file subalbumWidget.cpp.

References photos, subalbum, and Subalbum::syncPhotoList().

Referenced by SubalbumWidget().

{
  //so item has been moved, reorder linked list of items as necessary
  photos->sort( true );
  photos->arrangeItemsInGrid();

  //sync lists
  subalbum->syncPhotoList((PhotoPreviewWidget*)photos->firstItem());
}
void SubalbumWidget::resizeEvent ( QResizeEvent *  ) [protected]

Definition at line 680 of file subalbumWidget.cpp.

References photos.

{
  photos->arrangeItemsInGrid();
}
void SubalbumWidget::revertSelectedPhotos ( )

Revert selected photos to their original form.

Definition at line 382 of file subalbumWidget.cpp.

References photos, and selectedPhotoStateChanged().

Referenced by LayoutWidget::revertPhotos().

{
  //iterate over photos in current collection
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    //found a selected item!
    if(current->isSelected())
    {
      ((PhotoPreviewWidget*)current)->getPhoto()->revertPhoto();
      photos->ensureItemVisible(((PhotoPreviewWidget*)current));
      ((PhotoPreviewWidget*)current)->updateImage();
      qApp->processEvents();          
    }
    
    //move to next item
    current = current->nextItem();
  }

  //state of selected photos has changed
  emit selectedPhotoStateChanged();
}
void SubalbumWidget::rotate270ImageAction ( ) [private, slot]

Rotate counter-clockwise selected images.

Definition at line 466 of file subalbumWidget.cpp.

References Window::getStatus(), LayoutWidget::getSubalbums(), Window::getTitle(), LayoutWidget::getWindow(), layout, PhotosIconView::numSelected(), photos, selectedPhotoStateChanged(), TitleWidget::setBusy(), StatusWidget::setStatus(), StatusWidget::showProgressBar(), SubalbumsWidget::updateButtons(), updateButtons(), and StatusWidget::updateProgress().

Referenced by SubalbumWidget().

{
  //set busy flag and deactivate menu's/buttons
  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
  layout->getWindow()->getTitle()->setBusy(true);
  layout->getSubalbums()->updateButtons(false);
  photos->setSelectionMode( QIconView::NoSelection ) ;
  updateButtons(false);

  //setup progress bar
  QString statusMessage = tr("Rotating %1 photos:");
  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(photos->numSelected()), photos->numSelected() );
  qApp->processEvents();

  //rotate the selected photos
  int num = 0;
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    if(current->isSelected())
    {
      //update status message
      layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(photos->numSelected() - num) );

      ((PhotoPreviewWidget*)current)->getPhoto()->rotate270();
      photos->ensureItemVisible(((PhotoPreviewWidget*)current));
      ((PhotoPreviewWidget*)current)->updateImage();
      num++;
      layout->getWindow()->getStatus()->updateProgress( num );
      qApp->processEvents();
    }

    //move to next item
    current = current->nextItem();
  }

  //state of selected photos has changed
  emit selectedPhotoStateChanged();

  //hide progress bar
  layout->getWindow()->getStatus()->setStatus( tr("Rotating complete.") );

  //not busy any more
  layout->getWindow()->getTitle()->setBusy(false);
  layout->getSubalbums()->updateButtons(true);
  updateButtons(true);
  photos->setSelectionMode( QIconView::Extended ) ;
  qApp->restoreOverrideCursor();
}
void SubalbumWidget::rotate90ImageAction ( ) [private, slot]

Rotate clockwise selected images.

Definition at line 415 of file subalbumWidget.cpp.

References Window::getStatus(), LayoutWidget::getSubalbums(), Window::getTitle(), LayoutWidget::getWindow(), layout, PhotosIconView::numSelected(), photos, selectedPhotoStateChanged(), TitleWidget::setBusy(), StatusWidget::setStatus(), StatusWidget::showProgressBar(), SubalbumsWidget::updateButtons(), updateButtons(), and StatusWidget::updateProgress().

Referenced by SubalbumWidget().

{
  //set busy flag and deactivate menu's/buttons
  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
  layout->getWindow()->getTitle()->setBusy(true);
  layout->getSubalbums()->updateButtons(false);
  photos->setSelectionMode( QIconView::NoSelection ) ;
  updateButtons(false);

  //setup progress bar
  QString statusMessage = tr("Rotating %1 photos:");
  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(photos->numSelected()), photos->numSelected() );
  qApp->processEvents();
   
  //rotate the selected photos
  int num = 0;
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    if(current->isSelected())
    {
      //update status message
      layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(photos->numSelected() - num) );

      ((PhotoPreviewWidget*)current)->getPhoto()->rotate90();
      photos->ensureItemVisible(((PhotoPreviewWidget*)current));
      ((PhotoPreviewWidget*)current)->updateImage();
      num++;
      layout->getWindow()->getStatus()->updateProgress( num );
      qApp->processEvents();
    }

    //move to next item
    current = current->nextItem();
  }

  //state of selected photos has changed
  emit selectedPhotoStateChanged();
  
  //hide progress bar
  layout->getWindow()->getStatus()->setStatus( tr("Rotating complete.") );

  //not busy any more
  layout->getWindow()->getTitle()->setBusy(false);
  layout->getSubalbums()->updateButtons(true);
  updateButtons(true);
  photos->setSelectionMode( QIconView::Extended ) ;
  
  qApp->restoreOverrideCursor();
}
void SubalbumWidget::selectedPhotoStateChanged ( ) [signal]
void SubalbumWidget::selectionChangedEvent ( ) [private, slot]

handles changing selections

Definition at line 700 of file subalbumWidget.cpp.

References selectedPhotoStateChanged(), and updateButtons().

Referenced by removeImageAction(), setSubalbum(), and SubalbumWidget().

{
  //update rotate/add/remove buttons depending on whether or not any items are selected
  updateButtons();
  
  //emit selection changed signal so other menu's etc an be updated as well
  emit selectedPhotoStateChanged();
}
void SubalbumWidget::setSelectedPhoto ( Photo selection)

Sets the selected photo to selection and ensures it is visible.

Definition at line 630 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::tabChanged().

{
  //select specified photo  
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    if( ((PhotoPreviewWidget*)current)->getPhoto() == selection )
    {
      //deselect all
      photos->selectAll(false);

      //select photo and make sure it is visible
      current->setSelected(true);
      photos->ensureItemVisible( current );      
      
      return;
    }
    
    //move on to next photo
    current = current->nextItem();
  }
}
void SubalbumWidget::setSubalbum ( Subalbum salbum)

Resets the subalbum this subalbum widget is displaying.

Definition at line 219 of file subalbumWidget.cpp.

References buttonsFrame, refreshPhotos(), selectionChangedEvent(), and subalbum.

Referenced by TitleWidget::loadAlbum(), TitleWidget::newAlbum(), and LayoutWidget::showCollection().

{
  //set new subalbum pointer
  subalbum = salbum;

  //update photo listing
  refreshPhotos();

  if(subalbum == NULL) { buttonsFrame->hide(); }
  else
  {
    //disable/enable buttons as necessary
    buttonsFrame->show();
    selectionChangedEvent();
  }
}
void SubalbumWidget::setWallpaperAction ( ) [private, slot]

set desktop wallpaper

Definition at line 405 of file subalbumWidget.cpp.

References getSelectedPhoto(), and setWallpaper().

Referenced by SubalbumWidget().

{
  //get first selected photo, if no photo is selected then bail
  Photo* phto = getSelectedPhoto();
  if(phto == NULL) return;

  //set the wallpaper
  setWallpaper( phto );
}
void SubalbumWidget::stripDescriptionsFromSelectedPhotos ( )

Strip descriptions from selected photos.

Definition at line 563 of file subalbumWidget.cpp.

References photos.

Referenced by TitleWidget::removeSelectedPhotoDesc().

{
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    //found a selected item!
    if(current->isSelected())
    {
      ((PhotoPreviewWidget*)current)->getPhoto()->setDescription("");
      ((PhotoPreviewWidget*)current)->setText( "" );
    }

    //move to next item
    current = current->nextItem();
  }
}
void SubalbumWidget::updateButtons ( bool  enable)

Activates/Deactives remove/rotate buttons.

Definition at line 752 of file subalbumWidget.cpp.

References addImage, buttonsState, layout, removeImage, rotate270Image, rotate90Image, setDesktopBtn, LayoutWidget::setEditTabEnabled(), and wallpaperButtonState.

Referenced by TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum().

{
  if(!enable)
  {
    buttonsState = rotate90Image->isEnabled();
    addImage->setEnabled(enable && true);
    removeImage->setEnabled(enable && true);
    rotate90Image->setEnabled(enable);
    rotate270Image->setEnabled(enable);
    if(setDesktopBtn) 
    { 
      wallpaperButtonState = setDesktopBtn->isEnabled();
      setDesktopBtn->setEnabled(enable); 
    }
    layout->setEditTabEnabled(enable);
  }
  else
  {
    addImage->setEnabled(enable && true);
    removeImage->setEnabled(buttonsState && true);
    rotate90Image->setEnabled(buttonsState);
    rotate270Image->setEnabled(buttonsState);
    if(setDesktopBtn) { setDesktopBtn->setEnabled(wallpaperButtonState); }
    layout->setEditTabEnabled(buttonsState);
  }
}
void SubalbumWidget::updateButtons ( ) [private, slot]

Activates/Deactives remove/rotate buttons depending on if an image is selected.

Definition at line 709 of file subalbumWidget.cpp.

References layout, photos, removeImage, rotate270Image, rotate90Image, setDesktopBtn, and LayoutWidget::setEditTabEnabled().

Referenced by addImageAction(), removeImageAction(), rotate270ImageAction(), rotate90ImageAction(), and selectionChangedEvent().

{
  int numSelected = 0;
  QIconViewItem* current = photos->firstItem();
  while(current != NULL)
  {
    if(current->isSelected())
    {
     numSelected++;

     //there are effectively 3 states:
     //1) no items selected -> disable all buttons besides addPhoto
     //2) one itme selected -> enable all button, including set desktop wallpaper button
     //3) more than one item selected -> enable all but edit button (since we don't know which photo to edit)
     //thus once 2 selected photos are found we know we are in the multi select mode and can terminate the search
     if(numSelected > 1)
       break;
    }

    //move to next item
    current = current->nextItem();
  }

  if(numSelected == 0)
  {
    removeImage->setEnabled(false);
    rotate90Image->setEnabled(false);
    rotate270Image->setEnabled(false);
    if(setDesktopBtn) { setDesktopBtn->setEnabled(false); }
    layout->setEditTabEnabled(false);
  }
  else
  {
    removeImage->setEnabled(true);
    rotate90Image->setEnabled(true);
    rotate270Image->setEnabled(true);
    if(setDesktopBtn) { setDesktopBtn->setEnabled(true); }
    layout->setEditTabEnabled(true);
  }

  if(setDesktopBtn) { setDesktopBtn->setEnabled( numSelected == 1 ); }
}

Member Data Documentation

QToolButton* SubalbumWidget::addImage [private]

"Add" button

Definition at line 140 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

Definition at line 131 of file subalbumWidget.h.

Referenced by setSubalbum(), and SubalbumWidget().

QGridLayout* SubalbumWidget::buttonsGrid [private]

Definition at line 127 of file subalbumWidget.h.

Referenced by SubalbumWidget().

cached enabled/disabled state of buttons

Definition at line 158 of file subalbumWidget.h.

Referenced by updateButtons().

Pointer to the parent layout widget.

Definition at line 155 of file subalbumWidget.h.

Referenced by addImageAction(), removeImageAction(), rotate270ImageAction(), rotate90ImageAction(), SubalbumWidget(), and updateButtons().

QGridLayout* SubalbumWidget::mainGrid [private]

Grids widgets are placed in.

Definition at line 126 of file subalbumWidget.h.

Referenced by SubalbumWidget().

QToolButton* SubalbumWidget::removeImage [private]

"Remove" button

Definition at line 143 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QToolButton* SubalbumWidget::rotate270Image [private]

"Rotate 270" button

Definition at line 149 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QToolButton* SubalbumWidget::rotate90Image [private]

"Rotate 90" button

Definition at line 146 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QToolButton* SubalbumWidget::setDesktopBtn [private]

Set desktop wallpaper button.

Definition at line 152 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

Pointer to backend subalbum.

Definition at line 137 of file subalbumWidget.h.

Referenced by addImageAction(), getSubalbum(), refreshPhotos(), removeImageAction(), reorder(), setSubalbum(), and SubalbumWidget().

Grid lower buttons are placed in.

Definition at line 130 of file subalbumWidget.h.

cached enabled/distable state of set wallpaper button

Definition at line 161 of file subalbumWidget.h.

Referenced by updateButtons().


The documentation for this class was generated from the following files: