Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

SubalbumWidget Class Reference

#include <subalbumWidget.h>

Inheritance diagram for SubalbumWidget:

Inheritance graph
[legend]
Collaboration diagram for SubalbumWidget:

Collaboration graph
[legend]
List of all members.

Detailed Description

Displays subalbum layout, name and description.

Definition at line 43 of file subalbumWidget.h.

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 ()
 refreshes all photos

void refreshSelectedPhotos ()
 refreshes selected photos

void syncPhotos ()
 Syncs all photo data to backend objects.

SubalbumgetSubalbum ()
 returns a pointer to the backend subalbum

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

QIconViewgetPhotos ()
 Returns pointer to icon view.

void updateButtons (bool enable)
 Activates/Deactives remove/rotate/flip buttons.


Protected Member Functions

void resizeEvent (QResizeEvent *)

Private Slots

void updateName (const QString &val)
 Updates subalbum name.

void updateDescription (const QString &val)
 Updates subalbum description.

void setImageAction ()
 Sets currently selected photo as the representative image for the subalbum.

void updateButtons ()
 Activates/Deactives remove/rotate/flip buttons depending on if an image is selected.

void addImageAction ()
 Adds an image to the subalbum.

void removeImageAction ()
 Remove an image from the subalbum.

void rotate90ImageAction ()
 Rotate clockwise selected images.

void rotate270ImageAction ()
 Rotate counter-clockwise selected images.

void flipHorizontallyImageAction ()
 Flip about horizontal axis selected images.

void flipVerticallyImageAction ()
 Flip about vertical axis selected images.

void editAction ()
 Brings up the edit dialog for the currently selected photo.

void rearrangeAndSaveCurrent (QIconViewItem *item)
 Rearranges photos and saves their text.

void reorder ()

Private Attributes

QGridLayout * mainGrid
 Grids widgets are placed in.

QGridLayout * buttonsGrid
QGridLayout * annotationGrid
QFramebuttonsFrame
 Grid lower buttons are placed in.

QFrameannotationsFrame
QLabel * subalbumName
 Label "Subalbum Name:".

QLineEdit * subalbumNameVal
 Actual subalbum name.

QLabel * subalbumDescription
 Label "Description:".

QLineEdit * subalbumDescriptionVal
 Actual subalbum description.

QLabel * representativeImageText
 Label which shows "set" image.

QToolButton * setImage
 Button allowing user to set the representative image for the subalbum.

QLabel * representativeLogo
 Label which shows the representative image.

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 * flipHorizontallyImage
 "Flip Horizontally" button

QToolButton * flipVerticallyImage
 "Flip Vertically" button

QToolButton * editButton
 "Edit" button

LayoutWidgetlayout
 Pointer to the parent layout widget.

bool buttonsState
 cached enabled/disabled state of buttons


Constructor & Destructor Documentation

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

Creates layout based on backend object.

Definition at line 47 of file subalbumWidget.cpp.

References addImage, addImageAction(), annotationGrid, annotationsFrame, buttonsFrame, buttonsGrid, editAction(), editButton, flipHorizontallyImage, flipHorizontallyImageAction(), flipVerticallyImage, flipVerticallyImageAction(), Subalbum::getDescription(), Subalbum::getName(), Subalbum::getRepresentativeImage(), IMAGE_PATH, layout, mainGrid, photos, rearrangeAndSaveCurrent(), removeImage, removeImageAction(), reorder(), representativeImageText, representativeLogo, rotate270Image, rotate270ImageAction(), rotate90Image, rotate90ImageAction(), setImage, setImageAction(), SMALL, subalbum, subalbumDescription, subalbumDescriptionVal, subalbumName, subalbumNameVal, updateButtons(), updateDescription(), and updateName().

00049                                                   : 
00050                                QWidget(parent,name)
00051 {
00052   //store subalbum pointer
00053   subalbum = salbum;
00054 
00055   //store layout pointer
00056   layout = (LayoutWidget*)parent;
00057 
00058   annotationsFrame = new QFrame(this); 
00059   
00060   //create subalbum name and description label and text entries
00061   subalbumName = new QLabel( annotationsFrame );
00062   subalbumName->setText( tr("Subalbum Name:") );
00063   subalbumName->setFont( QFont( "Times", 12, QFont::Bold ) );
00064   subalbumNameVal = new QLineEdit( annotationsFrame );
00065   subalbumNameVal->setFont( QFont( "Times", 12, QFont::Bold ) );
00066   subalbumNameVal->setText(  subalbum->getName() );
00067   connect( subalbumNameVal, SIGNAL(textChanged(const QString&)),
00068            SLOT(updateName(const QString&)) );
00069 
00070   subalbumDescription = new QLabel( annotationsFrame );
00071   subalbumDescription->setText( tr("Description:") );
00072   subalbumDescription->setFont( QFont( "Times", 12, QFont::Bold ) );
00073   subalbumDescriptionVal = new QLineEdit( annotationsFrame );
00074   subalbumDescriptionVal->setFont( QFont( "Times", 12, QFont::Bold ) );
00075   subalbumDescriptionVal->setText(  subalbum->getDescription() );
00076   connect( subalbumDescriptionVal, SIGNAL(textChanged(const QString&)),
00077            SLOT(updateDescription(const QString&)) );
00078 
00079   //create set image button
00080   representativeImageText = new QLabel( annotationsFrame );
00081   representativeImageText->setText( tr("Thumbnail:") );
00082   representativeImageText->setFont( QFont( "Times", 12, QFont::Bold ) );
00083  
00084   QFont buttonFont( qApp->font() );
00085   buttonFont.setBold(true);
00086   buttonFont.setPointSize( 11 );
00087  
00088   setImage = new QToolButton( annotationsFrame );
00089   setImage->setTextLabel(tr("Set") );
00090   setImage->setTextPosition(QToolButton::Right);
00091   setImage->setFont( buttonFont );
00092   setImage->setUsesTextLabel( true );
00093   setImage->setEnabled(false);
00094   QToolTip::add( setImage, tr("Set subalbum thumbnail to selected photo") );
00095   connect( setImage, SIGNAL(clicked()), SLOT(setImageAction()) );
00096   
00097   //create representative image
00098   representativeLogo = new QLabel( annotationsFrame );
00099   representativeLogo->setPixmap( *subalbum->getRepresentativeImage(SMALL) );
00100 
00101   //create photo collection
00102   photos = new PhotosIconView( this );
00103   
00104   //establish a top-down view such that the scrollbar is always placed on the right
00105   photos->setArrangement( QIconView::LeftToRight );
00106   photos->setVScrollBarMode( QScrollView::AlwaysOn );
00107   
00108   //allow multiple photos to be selected with control and shift keys
00109   photos->setSelectionMode( QIconView::Extended ) ;
00110   
00111   //set auto-scroll on for drag-n-drop
00112   photos->setDragAutoScroll(true);
00113   photos->setAcceptDrops(true);
00114 
00115   //whenever photo names are changed sync with backend object
00116   connect( photos, SIGNAL(itemRenamed( QIconViewItem *)), 
00117            this, SLOT(rearrangeAndSaveCurrent( QIconViewItem *)));
00118            
00119   //connect selectionChanged signal to update buttons method
00120   connect( photos, SIGNAL(selectionChanged()),
00121            SLOT(updateButtons()) );
00122 
00123   //connect rightButtonClicked signal to update buttons method
00124   connect( photos, SIGNAL(rightButtonClicked(QIconViewItem*, const QPoint&)),
00125            SLOT(updateButtons()) );
00126            
00127   //if the set button is clicked set the representative image for the subalbum
00128   connect( setImage, SIGNAL(clicked()), SLOT(setImageAction()) );
00129 
00130   //connect drop event on iconview to reorder slot
00131   connect( photos, SIGNAL(itemHasMoved()), SLOT(reorder()) );  
00132   
00133   //create all buttons
00134   buttonsFrame = new QFrame(this);
00135    
00136   addImage = new QToolButton( buttonsFrame );
00137   addImage->setTextLabel(tr("Add Photo"));
00138   addImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"add.png") );
00139   addImage->setTextPosition(QToolButton::Right);
00140   addImage->setFont( buttonFont );
00141   addImage->setUsesTextLabel( true );
00142   QToolTip::add( addImage, tr("Add photos to selected subalbum") );
00143   connect( addImage, SIGNAL(clicked()), SLOT(addImageAction()) );
00144   
00145   removeImage = new QToolButton( buttonsFrame );
00146   removeImage->setTextLabel(tr("Remove Photo"));
00147   removeImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"remove.png") );
00148   removeImage->setTextPosition(QToolButton::Right);
00149   removeImage->setFont( buttonFont );
00150   removeImage->setUsesTextLabel( true );
00151   QToolTip::add( removeImage, tr("Remove selected photos from subalbum") );
00152   connect( removeImage, SIGNAL(clicked()), SLOT(removeImageAction()) );
00153   
00154   rotate90Image = new QToolButton( buttonsFrame );
00155   rotate90Image->setTextLabel(tr("Rotate 90") );
00156   rotate90Image->setIconSet( QPixmap(QString(IMAGE_PATH)+"rotate90.png") );
00157   rotate90Image->setTextPosition(QToolButton::Right);
00158   rotate90Image->setFont( buttonFont );
00159   rotate90Image->setUsesTextLabel( true );
00160   QToolTip::add( rotate90Image, tr("Rotate selected photos clockwise 90 degrees") );
00161   connect( rotate90Image, SIGNAL(clicked()), SLOT(rotate90ImageAction()) );
00162     
00163   rotate270Image = new QToolButton( buttonsFrame );
00164   rotate270Image->setTextLabel(tr("Rotate 270") );
00165   rotate270Image->setIconSet( QPixmap(QString(IMAGE_PATH)+"rotate270.png") );
00166   rotate270Image->setTextPosition(QToolButton::Right);
00167   rotate270Image->setFont( buttonFont );
00168   rotate270Image->setUsesTextLabel( true );
00169   QToolTip::add( rotate270Image, tr("Rotate selected photos counterclockwise 90 degrees") );
00170   connect( rotate270Image, SIGNAL(clicked()), SLOT(rotate270ImageAction()) );
00171 
00172   flipHorizontallyImage = new QToolButton( buttonsFrame );
00173   flipHorizontallyImage->setTextLabel(tr("Flip Horiz.") );
00174   flipHorizontallyImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"flipHorizontally.png") );
00175   flipHorizontallyImage->setTextPosition(QToolButton::Right);
00176   flipHorizontallyImage->setFont( buttonFont );
00177   flipHorizontallyImage->setUsesTextLabel( true );
00178   QToolTip::add( flipHorizontallyImage, tr("Flip selected photos horizontally") );
00179   connect( flipHorizontallyImage, SIGNAL(clicked()), SLOT(flipHorizontallyImageAction()) );
00180   
00181   flipVerticallyImage = new QToolButton( buttonsFrame );
00182   flipVerticallyImage->setTextLabel(tr("Flip Vert.") );
00183   flipVerticallyImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"flipVertically.png") );
00184   flipVerticallyImage->setTextPosition(QToolButton::Right);
00185   flipVerticallyImage->setFont( buttonFont );
00186   flipVerticallyImage->setUsesTextLabel( true );
00187   QToolTip::add( flipVerticallyImage, tr("Flip selected photos vertically") );
00188   connect( flipVerticallyImage, SIGNAL(clicked()), SLOT(flipVerticallyImageAction()) );
00189     
00190   editButton = new QToolButton( buttonsFrame );
00191   editButton->setTextLabel(tr("Edit") );
00192   editButton->setIconSet( QPixmap(QString(IMAGE_PATH)+"editPhoto.png") );
00193   editButton->setTextPosition(QToolButton::Right);
00194   editButton->setFont( buttonFont );
00195   editButton->setUsesTextLabel( true );
00196   QToolTip::add( editButton, tr("Edit selected photo") );
00197   connect( editButton, SIGNAL(clicked()), SLOT(editAction()) );
00198     
00199   //place all items in grid layout
00200   annotationGrid = new QGridLayout( annotationsFrame, 4, 5, 0 );
00201   annotationGrid->addWidget( subalbumName,                1, 0, Qt::AlignLeft );
00202   annotationGrid->addWidget( subalbumNameVal,             1, 1 );
00203   annotationGrid->addWidget( subalbumDescription,         2, 0, Qt::AlignLeft );
00204   annotationGrid->addWidget( subalbumDescriptionVal,      2, 1 );
00205   annotationGrid->addWidget( representativeImageText,     1, 3, Qt::AlignLeft );
00206   annotationGrid->addMultiCellWidget( setImage,           2, 2, 3, 3 );
00207   annotationGrid->addMultiCellWidget( representativeLogo, 0, 3, 4, 4 );
00208   annotationGrid->setRowStretch( 0, 1 );
00209   annotationGrid->setRowStretch( 3, 1 );
00210   annotationGrid->addColSpacing( 1, 300 );
00211   annotationGrid->addColSpacing( 2, 10 );
00212   
00213   buttonsGrid = new QGridLayout( buttonsFrame,             1, 9, 0 );
00214   buttonsGrid->addWidget( addImage,                   0, 1, Qt::AlignLeft );
00215   buttonsGrid->addWidget( removeImage,                0, 2, Qt::AlignLeft );
00216   buttonsGrid->addWidget( rotate90Image,              0, 3, Qt::AlignLeft );
00217   buttonsGrid->addWidget( rotate270Image,             0, 4, Qt::AlignLeft );
00218   buttonsGrid->addWidget( flipHorizontallyImage,      0, 5, Qt::AlignLeft );
00219   buttonsGrid->addWidget( flipVerticallyImage,        0, 6, Qt::AlignLeft );
00220   buttonsGrid->addWidget( editButton,                 0, 7, Qt::AlignLeft );
00221   buttonsGrid->setColStretch( 0, 1 );
00222   buttonsGrid->setColStretch( 8, 1 );
00223   
00224   mainGrid = new QGridLayout( this, 1, 3, 0 );
00225   mainGrid->addWidget( annotationsFrame, 0, 0 );
00226   mainGrid->addWidget( photos, 1, 0 );
00227   mainGrid->addWidget( buttonsFrame, 2, 0 );
00228   mainGrid->setRowStretch( 1, 1 );
00229    
00230   //set the background of the widget to be white
00231   setPaletteBackgroundColor( QColor(255, 255, 255) );
00232   
00233   //by default no selected images so disable all buttons besides add
00234   removeImage->setEnabled(false);  
00235   rotate90Image->setEnabled(false);  
00236   rotate270Image->setEnabled(false);  
00237   flipHorizontallyImage->setEnabled(false);  
00238   flipVerticallyImage->setEnabled(false);  
00239   editButton->setEnabled(false);  
00240 }


Member Function Documentation

void SubalbumWidget::addImageAction  )  [private, slot]
 

Adds an image to the subalbum.

Definition at line 288 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, updateButtons(), SubalbumsWidget::updateButtons(), and StatusWidget::updateProgress().

Referenced by SubalbumWidget().

00289 {
00290   //set busy flag and deactivate menu's/buttons, and selecting photos
00291   layout->getWindow()->getTitle()->setBusy(true);
00292   layout->getSubalbums()->updateButtons(false);
00293   updateButtons(false);
00294   photos->setSelectionMode( QIconView::NoSelection ) ;
00295     
00296   //Get filename from user  
00297   QStringList fileNames = QFileDialog::getOpenFileNames(tr("Images (*.gif *.jpg *.jpeg *.png *.xpm *.GIF *.JPG *.JPEG *.PNG *.XPM)"),
00298                                                         NULL,
00299                                                         this,
00300                                                         "add photos dialog",
00301                                                         tr("Select photos"));
00302                                                               
00303   qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00304   
00305   //setup progress bar
00306   layout->getWindow()->getStatus()->showProgressBar( tr("Adding photos:"), fileNames.count() );
00307   qApp->processEvents();
00308   
00309   //iterate through each file and add to album
00310   QStringList::iterator it;
00311   int num=0;
00312   for(it = fileNames.begin(); it != fileNames.end(); it++ )
00313   {
00314     //if successful adding photo add widget
00315     if(subalbum->addPhoto(*it, false))
00316     {  
00317       PhotoWidget* p =  new PhotoWidget( photos, subalbum->getLast() );
00318       p->setRenameEnabled(true);
00319       photos->ensureItemVisible(p);
00320     }
00321     num++;
00322     layout->getWindow()->getStatus()->updateProgress( num );
00323     qApp->processEvents();
00324   }
00325   photos->arrangeItemsInGrid();
00326   
00327   //remove progress bar
00328   layout->getWindow()->getStatus()->setStatus( tr("Adding photos complete.") );
00329   
00330   //unset busy flag and activate menu's/buttons
00331   layout->getWindow()->getTitle()->setBusy(false);
00332   layout->getSubalbums()->updateButtons(true);
00333   updateButtons(true);
00334   photos->setSelectionMode( QIconView::Extended ) ;
00335   qApp->restoreOverrideCursor();
00336 }

void SubalbumWidget::editAction  )  [private, slot]
 

Brings up the edit dialog for the currently selected photo.

Definition at line 568 of file subalbumWidget.cpp.

References LayoutWidget::editPhoto(), getSelectedPhoto(), and layout.

Referenced by SubalbumWidget().

00569 {
00570   Photo* selected = getSelectedPhoto();
00571   if(selected != NULL)
00572     layout->editPhoto( selected );
00573   else
00574   {
00575     //bring up dialog scolding user for trying to edit either no or multiple photos at once
00576   }
00577 }

void SubalbumWidget::flipHorizontallyImageAction  )  [private, slot]
 

Flip about horizontal axis selected images.

Definition at line 482 of file subalbumWidget.cpp.

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

Referenced by SubalbumWidget().

00483 {
00484   //set busy flag and deactivate menu's/buttons
00485   qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00486   layout->getWindow()->getTitle()->setBusy(true);
00487   layout->getSubalbums()->updateButtons(false);
00488   photos->setSelectionMode( QIconView::NoSelection ) ;
00489   updateButtons(false);
00490   
00491   //setup progress bar
00492   layout->getWindow()->getStatus()->showProgressBar( tr("Flipping images horizontally:"), photos->numSelected() );
00493   qApp->processEvents();
00494   
00495   //flip the selected photos
00496   int num = 0;
00497   QIconViewItem* current = photos->firstItem();
00498   while(current != NULL)
00499   {
00500     if(current->isSelected())
00501     {
00502       ((PhotoWidget*)current)->getPhoto()->flipHorizontally();
00503       photos->ensureItemVisible(((PhotoWidget*)current));
00504       ((PhotoWidget*)current)->updateImage();
00505       num++;
00506       layout->getWindow()->getStatus()->updateProgress( num );
00507       qApp->processEvents();
00508     }
00509     
00510     //move to next item
00511     current = current->nextItem();
00512   }
00513   
00514   //hide progress bar
00515   layout->getWindow()->getStatus()->setStatus( tr("Flipping complete.") );
00516   
00517   //not busy any more
00518   layout->getWindow()->getTitle()->setBusy(false);
00519   layout->getSubalbums()->updateButtons(true);
00520   updateButtons(true);
00521   photos->setSelectionMode( QIconView::Extended ) ;
00522   qApp->restoreOverrideCursor();
00523 }

void SubalbumWidget::flipVerticallyImageAction  )  [private, slot]
 

Flip about vertical axis selected images.

Definition at line 525 of file subalbumWidget.cpp.

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

Referenced by SubalbumWidget().

00526 {
00527   //set busy flag and deactivate menu's/buttons
00528   qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00529   layout->getWindow()->getTitle()->setBusy(true);
00530   layout->getSubalbums()->updateButtons(false);
00531   photos->setSelectionMode( QIconView::NoSelection ) ;
00532   updateButtons(false);
00533   
00534   //setup progress bar
00535   layout->getWindow()->getStatus()->showProgressBar( tr("Flipping images vertically:"), photos->numSelected() );
00536   qApp->processEvents();
00537   
00538   //flip the selected photos
00539   int num = 0;
00540   QIconViewItem* current = photos->firstItem();
00541   while(current != NULL)
00542   {
00543     if(current->isSelected())
00544     {
00545       ((PhotoWidget*)current)->getPhoto()->flipVertically();
00546       photos->ensureItemVisible(((PhotoWidget*)current));
00547       ((PhotoWidget*)current)->updateImage();
00548       num++;
00549       layout->getWindow()->getStatus()->updateProgress( num );
00550       qApp->processEvents();
00551     }
00552     
00553     //move to next item
00554     current = current->nextItem();
00555   }
00556   
00557   //hide progress bar
00558   layout->getWindow()->getStatus()->setStatus( tr("Flipping complete.") );
00559   
00560   //not busy any more
00561   layout->getWindow()->getTitle()->setBusy(false);
00562   layout->getSubalbums()->updateButtons(true);
00563   updateButtons(true);
00564   photos->setSelectionMode( QIconView::Extended ) ;
00565   qApp->restoreOverrideCursor();
00566 }

QIconView * SubalbumWidget::getPhotos  ) 
 

Returns pointer to icon view.

Definition at line 667 of file subalbumWidget.cpp.

References photos.

Referenced by SubalbumPreviewWidget::dropped().

00668 {
00669   return photos;
00670 }

Photo * SubalbumWidget::getSelectedPhoto  ) 
 

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

Definition at line 628 of file subalbumWidget.cpp.

References photos.

Referenced by editAction(), TitleWidget::setImageAction(), and setImageAction().

00629 {
00630   //determine if one photo is selected
00631   int numSelected = 0;
00632   QIconViewItem* current = photos->firstItem();
00633   QIconViewItem* selected = NULL;
00634   while(current != NULL)
00635   {
00636     //found a selected item!
00637     if(current->isSelected())
00638     {
00639       numSelected++;
00640       selected = current;
00641     }
00642     
00643     //if more than one found then bail!
00644     if(numSelected > 1)
00645       break;
00646     
00647     //move to next item
00648     current = current->nextItem();
00649   }
00650   
00651   //if one item is selected then return photo pointer
00652   if(numSelected == 1)
00653   {
00654     return ((PhotoWidget*)selected)->getPhoto();
00655   }
00656   else
00657   {
00658     return NULL;
00659   }
00660 }

Subalbum * SubalbumWidget::getSubalbum  ) 
 

returns a pointer to the backend subalbum

Definition at line 623 of file subalbumWidget.cpp.

References subalbum.

Referenced by SubalbumPreviewWidget::dropped(), and LayoutWidget::updateSubalbum().

00624 {
00625   return subalbum;
00626 }

void SubalbumWidget::rearrangeAndSaveCurrent QIconViewItem item  )  [private, slot]
 

Rearranges photos and saves their text.

Definition at line 672 of file subalbumWidget.cpp.

References photos.

Referenced by SubalbumWidget().

00673 {
00674   ((PhotoWidget*)item)->sync();
00675   photos->arrangeItemsInGrid();  
00676 }

void SubalbumWidget::refreshPhotos  ) 
 

refreshes all photos

Definition at line 579 of file subalbumWidget.cpp.

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

Referenced by setSubalbum(), and LayoutWidget::updateSubalbum().

00580 {
00581   //remove all thumbnails
00582   photos->clear();
00583 
00584   //insert photo thumbnails
00585   Photo* currentPhoto = subalbum->getFirst();
00586   while(currentPhoto != NULL)
00587   {
00588     PhotoWidget* p = new PhotoWidget( photos, currentPhoto );
00589     p->setRenameEnabled(true);
00590     currentPhoto = currentPhoto->getNext();
00591   }
00592   
00593   photos->arrangeItemsInGrid();
00594 }

void SubalbumWidget::refreshSelectedPhotos  ) 
 

refreshes selected photos

Definition at line 596 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::stopEdit().

00597 {
00598   QIconViewItem* current = photos->firstItem();
00599   while(current != NULL)
00600   {
00601     //found a selected item!
00602     if(current->isSelected())
00603     {
00604       ((PhotoWidget*)current)->updateImage();
00605       ((PhotoWidget*)current)->updateDescription();
00606     }
00607     
00608     //move to next item
00609     current = current->nextItem();
00610   }
00611 }

void SubalbumWidget::removeImageAction  )  [private, slot]
 

Remove an image from the subalbum.

Definition at line 338 of file subalbumWidget.cpp.

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

Referenced by SubalbumWidget().

00339 {
00340   //set busy flag and deactivate menu's/buttons
00341   layout->getWindow()->getTitle()->setBusy(true);
00342   layout->getSubalbums()->updateButtons(false);
00343   updateButtons(false);
00344   photos->setSelectionMode( QIconView::NoSelection ) ;
00345   
00346   //check if user is sure
00347   QuestionDialog sure( tr("Remove selected photos?"),
00348                        tr("Once removed photos cannot be restored. Furthermore apon resaving they are physically removed from your album."),
00349                        "warning.png",
00350                        this );    
00351   //if user say yes then delete subalbum and refresh
00352   if(sure.exec())  
00353   {
00354     qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00355     //iterate through all photos and remove those that are selected
00356     QIconViewItem* current = photos->firstItem();
00357     QIconViewItem* temp;
00358     while(current != NULL)
00359     {
00360       //if not selected move on
00361       if(!current->isSelected())
00362       {
00363         current = current->nextItem();
00364         continue;
00365       }
00366       
00367       //get next pointer  
00368       temp = current->nextItem();
00369     
00370       //grab point to backend photo
00371       Photo* phto = ((PhotoWidget*)current)->getPhoto();
00372     
00373       //delete photo widget
00374       delete current;
00375       current = temp;
00376     
00377       //delete backend photo
00378       subalbum->removePhoto(phto); 
00379       
00380       //check if any photos selected, if not deactivate all buttons besides add button
00381       updateButtons();
00382     }
00383   
00384     photos->arrangeItemsInGrid();
00385   
00386     //unset busy flag and activate menu's/buttons
00387     qApp->restoreOverrideCursor();
00388   }
00389     
00390   layout->getWindow()->getTitle()->setBusy(false);
00391   layout->getSubalbums()->updateButtons(true);
00392   updateButtons(true);
00393   photos->setSelectionMode( QIconView::Extended ) ;
00394 }

void SubalbumWidget::reorder  )  [private, slot]
 

Definition at line 678 of file subalbumWidget.cpp.

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

Referenced by SubalbumWidget().

00679 {
00680   //so item has been moved, reorder linked list of items as necessary
00681   photos->sort( true );
00682   photos->arrangeItemsInGrid();
00683     
00684   //sync lists
00685   subalbum->syncPhotoList((PhotoWidget*)photos->firstItem());
00686 }

void SubalbumWidget::resizeEvent QResizeEvent *   )  [protected]
 

Definition at line 662 of file subalbumWidget.cpp.

References photos.

00663 {
00664   photos->arrangeItemsInGrid();  
00665 }

void SubalbumWidget::rotate270ImageAction  )  [private, slot]
 

Rotate counter-clockwise selected images.

Definition at line 439 of file subalbumWidget.cpp.

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

Referenced by SubalbumWidget().

00440 {
00441   //set busy flag and deactivate menu's/buttons
00442   qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00443   layout->getWindow()->getTitle()->setBusy(true);
00444   layout->getSubalbums()->updateButtons(false);
00445   photos->setSelectionMode( QIconView::NoSelection ) ;
00446   updateButtons(false);
00447   
00448   //setup progress bar
00449   layout->getWindow()->getStatus()->showProgressBar( tr("Rotating images 270 degrees:"), photos->numSelected() );
00450   qApp->processEvents();
00451   
00452   //rotate the selected photos
00453   int num = 0;
00454   QIconViewItem* current = photos->firstItem();
00455   while(current != NULL)
00456   {
00457     if(current->isSelected())
00458     {
00459       ((PhotoWidget*)current)->getPhoto()->rotate270();
00460       photos->ensureItemVisible(((PhotoWidget*)current));
00461       ((PhotoWidget*)current)->updateImage();
00462       num++;
00463       layout->getWindow()->getStatus()->updateProgress( num );
00464       qApp->processEvents();
00465     }
00466     
00467     //move to next item
00468     current = current->nextItem();
00469   }
00470   
00471   //hide progress bar
00472   layout->getWindow()->getStatus()->setStatus( tr("Rotation complete.") );
00473   
00474   //not busy any more
00475   layout->getWindow()->getTitle()->setBusy(false);
00476   layout->getSubalbums()->updateButtons(true);
00477   updateButtons(true);
00478   photos->setSelectionMode( QIconView::Extended ) ;
00479   qApp->restoreOverrideCursor();
00480 }

void SubalbumWidget::rotate90ImageAction  )  [private, slot]
 

Rotate clockwise selected images.

Definition at line 396 of file subalbumWidget.cpp.

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

Referenced by SubalbumWidget().

00397 {
00398   //set busy flag and deactivate menu's/buttons
00399   qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00400   layout->getWindow()->getTitle()->setBusy(true);
00401   layout->getSubalbums()->updateButtons(false);
00402   photos->setSelectionMode( QIconView::NoSelection ) ;
00403   updateButtons(false);
00404   
00405   //setup progress bar
00406   layout->getWindow()->getStatus()->showProgressBar( tr("Rotating images 90 degrees:"), photos->numSelected() );
00407   qApp->processEvents();
00408     
00409   //rotate the selected photos
00410   int num = 0;
00411   QIconViewItem* current = photos->firstItem();
00412   while(current != NULL)
00413   {
00414     if(current->isSelected())
00415     {
00416       ((PhotoWidget*)current)->getPhoto()->rotate90();
00417       photos->ensureItemVisible(((PhotoWidget*)current));
00418       ((PhotoWidget*)current)->updateImage();
00419       num++; 
00420       layout->getWindow()->getStatus()->updateProgress( num );
00421       qApp->processEvents();
00422     }
00423     
00424     //move to next item
00425     current = current->nextItem();
00426   }
00427 
00428   //hide progress bar
00429   layout->getWindow()->getStatus()->setStatus( tr("Rotation complete.") );
00430     
00431   //not busy any more
00432   layout->getWindow()->getTitle()->setBusy(false);
00433   layout->getSubalbums()->updateButtons(true);
00434   updateButtons(true);
00435   photos->setSelectionMode( QIconView::Extended ) ;
00436   qApp->restoreOverrideCursor();
00437 }

void SubalbumWidget::setImageAction  )  [private, slot]
 

Sets currently selected photo as the representative image for the subalbum.

Definition at line 260 of file subalbumWidget.cpp.

References Photo::getImage(), Subalbum::getRepresentativeImage(), getSelectedPhoto(), layout, MEDIUM, representativeLogo, Subalbum::setRepresentativeImages(), SMALL, subalbum, THUMBNAIL, and LayoutWidget::updateSubalbumImage().

Referenced by SubalbumWidget().

00261 {
00262   //---------------------------------------------------------    
00263   //get handle on photo widget
00264   Photo* selectedPhoto = getSelectedPhoto();
00265   if(selectedPhoto == NULL)
00266     return;
00267   //---------------------------------------------------------    
00268   //set representative images
00269   subalbum->setRepresentativeImages( selectedPhoto->getImage(THUMBNAIL) );
00270   //---------------------------------------------------------    
00271   //update onscreen images
00272   representativeLogo->setPixmap( *(subalbum->getRepresentativeImage(SMALL)) );
00273   layout->updateSubalbumImage( subalbum->getRepresentativeImage(MEDIUM) );
00274   //---------------------------------------------------------    
00275 }

void SubalbumWidget::setSubalbum Subalbum salbum  ) 
 

Resets the subalbum this subalbum widget is displaying.

Definition at line 242 of file subalbumWidget.cpp.

References Subalbum::getDescription(), Subalbum::getName(), Subalbum::getRepresentativeImage(), refreshPhotos(), representativeLogo, SMALL, subalbum, subalbumDescriptionVal, subalbumNameVal, and updateButtons().

Referenced by LayoutWidget::updateSubalbum().

00243 {
00244   //set new subalbum pointer
00245   subalbum = salbum;
00246   
00247   //update representative image, subalbum name and description
00248   subalbumNameVal->setText(  subalbum->getName() );
00249   subalbumDescriptionVal->setText(  subalbum->getDescription() );
00250   representativeLogo->setPixmap( *subalbum->getRepresentativeImage(SMALL) );
00251   
00252   //update photo listing
00253   refreshPhotos();
00254   
00255   //disable/enable buttons as necessary
00256   updateButtons();
00257 }

void SubalbumWidget::syncPhotos  ) 
 

Syncs all photo data to backend objects.

Definition at line 613 of file subalbumWidget.cpp.

References photos, and PhotoWidget::sync().

Referenced by TitleWidget::saveAlbum(), TitleWidget::saveAsAlbum(), and LayoutWidget::updateSubalbum().

00614 {
00615   PhotoWidget* current = (PhotoWidget*)photos->firstItem(); 
00616   while(current != NULL)
00617   {
00618     current->sync();
00619     current = (PhotoWidget*)current->nextItem();  
00620   }
00621 }

void SubalbumWidget::updateButtons  )  [private, slot]
 

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

Definition at line 688 of file subalbumWidget.cpp.

References editButton, flipHorizontallyImage, flipVerticallyImage, Window::getTitle(), LayoutWidget::getWindow(), layout, photos, removeImage, rotate270Image, rotate90Image, setImage, and TitleWidget::setSetButtonState().

Referenced by addImageAction(), flipHorizontallyImageAction(), flipVerticallyImageAction(), removeImageAction(), rotate270ImageAction(), rotate90ImageAction(), setSubalbum(), and SubalbumWidget().

00689 {
00690   bool anySelected = false;
00691   QIconViewItem* current = photos->firstItem();
00692   while(current != NULL)
00693   {
00694     if(current->isSelected())
00695     {
00696      anySelected = true;
00697      break;
00698     }
00699     
00700     //move to next item
00701     current = current->nextItem();
00702   }
00703 
00704   if(!anySelected)
00705   {
00706     removeImage->setEnabled(false);  
00707     rotate90Image->setEnabled(false);  
00708     rotate270Image->setEnabled(false);  
00709     flipHorizontallyImage->setEnabled(false);  
00710     flipVerticallyImage->setEnabled(false);  
00711     editButton->setEnabled(false);  
00712     layout->getWindow()->getTitle()->setSetButtonState(false);
00713     setImage->setEnabled(false);
00714   }
00715   else
00716   {
00717     removeImage->setEnabled(true);  
00718     rotate90Image->setEnabled(true);  
00719     rotate270Image->setEnabled(true);  
00720     flipHorizontallyImage->setEnabled(true);  
00721     flipVerticallyImage->setEnabled(true);  
00722     editButton->setEnabled(true);  
00723     layout->getWindow()->getTitle()->setSetButtonState(true);
00724     setImage->setEnabled(true);
00725   }
00726 }

void SubalbumWidget::updateButtons bool  enable  ) 
 

Activates/Deactives remove/rotate/flip buttons.

Definition at line 728 of file subalbumWidget.cpp.

References addImage, buttonsState, editButton, flipHorizontallyImage, flipVerticallyImage, removeImage, rotate270Image, rotate90Image, and setImage.

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

00729 {
00730   if(!enable)
00731   {
00732     buttonsState = rotate90Image->isEnabled();
00733     addImage->setEnabled(enable);
00734     removeImage->setEnabled(enable);  
00735     rotate90Image->setEnabled(enable);  
00736     rotate270Image->setEnabled(enable);  
00737     flipHorizontallyImage->setEnabled(enable);  
00738     flipVerticallyImage->setEnabled(enable);  
00739     editButton->setEnabled(enable);  
00740     setImage->setEnabled(enable);
00741   }
00742   else
00743   {
00744     addImage->setEnabled(enable);
00745     removeImage->setEnabled(buttonsState);  
00746     rotate90Image->setEnabled(buttonsState);  
00747     rotate270Image->setEnabled(buttonsState);  
00748     flipHorizontallyImage->setEnabled(buttonsState);  
00749     flipVerticallyImage->setEnabled(buttonsState);  
00750     editButton->setEnabled(buttonsState);  
00751     setImage->setEnabled(buttonsState);
00752   }
00753 }

void SubalbumWidget::updateDescription const QString &  val  )  [private, slot]
 

Updates subalbum description.

Definition at line 283 of file subalbumWidget.cpp.

References Subalbum::setDescription(), and subalbum.

Referenced by SubalbumWidget().

00284 {
00285   subalbum->setDescription(val);
00286 }

void SubalbumWidget::updateName const QString &  val  )  [private, slot]
 

Updates subalbum name.

Definition at line 277 of file subalbumWidget.cpp.

References layout, Subalbum::setName(), subalbum, and LayoutWidget::updateSubalbumName().

Referenced by SubalbumWidget().

00278 {
00279   subalbum->setName(val);
00280   layout->updateSubalbumName(val);
00281 }


Member Data Documentation

QToolButton* SubalbumWidget::addImage [private]
 

"Add" button

Definition at line 158 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QGridLayout* SubalbumWidget::annotationGrid [private]
 

Definition at line 124 of file subalbumWidget.h.

Referenced by SubalbumWidget().

QFrame* SubalbumWidget::annotationsFrame [private]
 

Definition at line 128 of file subalbumWidget.h.

Referenced by SubalbumWidget().

QFrame* SubalbumWidget::buttonsFrame [private]
 

Grid lower buttons are placed in.

Definition at line 127 of file subalbumWidget.h.

Referenced by SubalbumWidget().

QGridLayout* SubalbumWidget::buttonsGrid [private]
 

Definition at line 123 of file subalbumWidget.h.

Referenced by SubalbumWidget().

bool SubalbumWidget::buttonsState [private]
 

cached enabled/disabled state of buttons

Definition at line 182 of file subalbumWidget.h.

Referenced by updateButtons().

QToolButton* SubalbumWidget::editButton [private]
 

"Edit" button

Definition at line 176 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QToolButton* SubalbumWidget::flipHorizontallyImage [private]
 

"Flip Horizontally" button

Definition at line 170 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QToolButton* SubalbumWidget::flipVerticallyImage [private]
 

"Flip Vertically" button

Definition at line 173 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

LayoutWidget* SubalbumWidget::layout [private]
 

Pointer to the parent layout widget.

Definition at line 179 of file subalbumWidget.h.

Referenced by addImageAction(), editAction(), flipHorizontallyImageAction(), flipVerticallyImageAction(), removeImageAction(), rotate270ImageAction(), rotate90ImageAction(), setImageAction(), SubalbumWidget(), updateButtons(), and updateName().

QGridLayout* SubalbumWidget::mainGrid [private]
 

Grids widgets are placed in.

Definition at line 122 of file subalbumWidget.h.

Referenced by SubalbumWidget().

PhotosIconView* SubalbumWidget::photos [private]
 

Photos layout.

Definition at line 152 of file subalbumWidget.h.

Referenced by addImageAction(), flipHorizontallyImageAction(), flipVerticallyImageAction(), getPhotos(), getSelectedPhoto(), rearrangeAndSaveCurrent(), refreshPhotos(), refreshSelectedPhotos(), removeImageAction(), reorder(), resizeEvent(), rotate270ImageAction(), rotate90ImageAction(), SubalbumWidget(), syncPhotos(), and updateButtons().

QToolButton* SubalbumWidget::removeImage [private]
 

"Remove" button

Definition at line 161 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QLabel* SubalbumWidget::representativeImageText [private]
 

Label which shows "set" image.

Definition at line 143 of file subalbumWidget.h.

Referenced by SubalbumWidget().

QLabel* SubalbumWidget::representativeLogo [private]
 

Label which shows the representative image.

Definition at line 149 of file subalbumWidget.h.

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

QToolButton* SubalbumWidget::rotate270Image [private]
 

"Rotate 270" button

Definition at line 167 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QToolButton* SubalbumWidget::rotate90Image [private]
 

"Rotate 90" button

Definition at line 164 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

QToolButton* SubalbumWidget::setImage [private]
 

Button allowing user to set the representative image for the subalbum.

Definition at line 146 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

Subalbum* SubalbumWidget::subalbum [private]
 

Pointer to backend subalbum.

Definition at line 155 of file subalbumWidget.h.

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

QLabel* SubalbumWidget::subalbumDescription [private]
 

Label "Description:".

Definition at line 137 of file subalbumWidget.h.

Referenced by SubalbumWidget().

QLineEdit* SubalbumWidget::subalbumDescriptionVal [private]
 

Actual subalbum description.

Definition at line 140 of file subalbumWidget.h.

Referenced by setSubalbum(), and SubalbumWidget().

QLabel* SubalbumWidget::subalbumName [private]
 

Label "Subalbum Name:".

Definition at line 131 of file subalbumWidget.h.

Referenced by SubalbumWidget().

QLineEdit* SubalbumWidget::subalbumNameVal [private]
 

Actual subalbum name.

Definition at line 134 of file subalbumWidget.h.

Referenced by setSubalbum(), and SubalbumWidget().


The documentation for this class was generated from the following files:
Generated on Thu Nov 13 00:11:20 2003 for AlbumShaper by doxygen 1.3.4