AlbumShaper  1.0a3
Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | List of all members
SubalbumWidget Class Reference

Displays subalbum layout. More...

#include <subalbumWidget.h>

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

Signals

void selectedPhotoStateChanged ()
 

Public Member Functions

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

Protected Member Functions

void resizeEvent (QResizeEvent *)
 

Private Slots

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

Private Attributes

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

Detailed Description

Displays subalbum layout.

Definition at line 40 of file subalbumWidget.h.

Constructor & Destructor Documentation

§ SubalbumWidget()

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

Creates layout based on backend object.

Definition at line 52 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.

54  :
55  QWidget(parent,name)
56 {
57  setWindowFlags(Qt::WNoAutoErase);
58 
59  //store subalbum pointer
60  subalbum = salbum;
61 
62  //store layout pointer
63  layout = (LayoutWidget*)parent;
64 
65  //create photo collection
66  photos = new PhotosIconView( this );
67 
68  //establish a top-down view such that the scrollbar is always placed on the right
69  photos->setArrangement( Q3IconView::LeftToRight );
70  photos->setVScrollBarMode( Q3ScrollView::Auto );
71 
72  //allow multiple photos to be selected with control and shift keys
73  photos->setSelectionMode( Q3IconView::Extended ) ;
74 
75  //set auto-scroll on for drag-n-drop
76  photos->setDragAutoScroll(true);
77  photos->setAcceptDrops(true);
78 
79  //connect selectionChanged signal to update buttons method
80  connect( photos, SIGNAL(selectionChanged()),
81  this, SLOT( selectionChangedEvent()) );
82 
83  //connect rightButtonClicked signal to update buttons method
84  connect( photos, SIGNAL(rightButtonClicked(Q3IconViewItem*, const QPoint&)),
85  this, SLOT(selectionChangedEvent()) );
86 
87  //connect itemhasMoved signal on iconview to reorder slot (phots have been rearranged)
88  connect( photos, SIGNAL(itemHasMoved()), SLOT(reorder()) );
89 
90  //connect addPhtos signal from iconview to actually add photos from disk (Drop from outside target, ie konqueror)
91  connect( photos, SIGNAL(addPhotos(QStringList)), SLOT(addImageAction(QStringList)) );
92 
93  //connect keyevent signals from iconview
94  connect( photos, SIGNAL(removeSelectedPhotos()), SLOT(removeImageAction()) );
95  connect( photos, SIGNAL(rotate90SelectedPhotos()), SLOT(rotate90ImageAction()) );
96  connect( photos, SIGNAL(rotate270SelectedPhotos()), SLOT(rotate270ImageAction()) );
97 
98  //connect key e press signal to edit slot
99  connect( photos, SIGNAL(editSelectedPhoto()),
100  layout, SLOT(editSelectedPhoto()) );
101  //connect double click signal to edit slot
102  connect( photos, SIGNAL( doubleClicked(Q3IconViewItem*) ),
103  layout, SLOT(editSelectedPhoto()) );
104 
105  //create all buttons
106  buttonsFrame = new Q3Frame(this);
107  if(subalbum == NULL) buttonsFrame->hide();
108 
109  QFont buttonFont( qApp->font() );
110  buttonFont.setBold(true);
111  buttonFont.setPointSize( 11 );
112 
113  addImage = new QToolButton( buttonsFrame );
114  addImage->setTextLabel(tr("Add Photo"));
115  addImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/add.png") );
116  addImage->setTextPosition(QToolButton::BesideIcon);
117  addImage->setFont( buttonFont );
118  addImage->setUsesTextLabel( true );
119  addImage->setEnabled( true );
120  QToolTip::add( addImage, tr("Add photos to selected collection") );
121  connect( addImage, SIGNAL(clicked()), SLOT(addImageAction()) );
122 
123  removeImage = new QToolButton( buttonsFrame );
124  removeImage->setTextLabel(tr("Remove Photo"));
125  removeImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/remove.png") );
126  removeImage->setTextPosition(QToolButton::BesideIcon);
127  removeImage->setFont( buttonFont );
128  removeImage->setUsesTextLabel( true );
129  removeImage->setEnabled( true );
130  QToolTip::add( removeImage, tr("Remove selected photos from collection") );
131  connect( removeImage, SIGNAL(clicked()), SLOT(removeImageAction()) );
132 
133  rotate90Image = new QToolButton( buttonsFrame );
134  rotate90Image->setTextLabel(tr("Rotate Right") );
135  QIcon rotate90Icon;
136  rotate90Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate90.png",
137  QIcon::Automatic,
138  QIcon::Normal );
139  rotate90Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate90_disabled.png",
140  QIcon::Automatic,
141  QIcon::Disabled );
142  rotate90Image->setIconSet( rotate90Icon );
143 
144  rotate90Image->setTextPosition(QToolButton::BesideIcon);
145  rotate90Image->setFont( buttonFont );
146  rotate90Image->setUsesTextLabel( true );
147  QToolTip::add( rotate90Image, tr("Rotate selected photos clockwise") );
148  connect( rotate90Image, SIGNAL(clicked()), SLOT(rotate90ImageAction()) );
149 
150  rotate270Image = new QToolButton( buttonsFrame );
151  rotate270Image->setTextLabel(tr("Rotate Left") );
152  QIcon rotate270Icon;
153  rotate270Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate270.png",
154  QIcon::Automatic,
155  QIcon::Normal );
156  rotate270Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate270_disabled.png",
157  QIcon::Automatic,
158  QIcon::Disabled );
159  rotate270Image->setIconSet( rotate270Icon );
160 
161  rotate270Image->setTextPosition(QToolButton::BesideIcon);
162  rotate270Image->setFont( buttonFont );
163  rotate270Image->setUsesTextLabel( true );
164  QToolTip::add( rotate270Image, tr("Rotate selected photos counterclockwise") );
165  connect( rotate270Image, SIGNAL(clicked()), SLOT(rotate270ImageAction()) );
166 
167  //place all items in grid layout
168  buttonsGrid = new Q3GridLayout( buttonsFrame, 1, 7, 0 );
169  buttonsGrid->addWidget( addImage, 0, 1, Qt::AlignLeft );
170  buttonsGrid->addWidget( removeImage, 0, 2, Qt::AlignLeft );
171  buttonsGrid->addWidget( rotate90Image, 0, 3, Qt::AlignLeft );
172  buttonsGrid->addWidget( rotate270Image, 0, 4, Qt::AlignLeft );
173  buttonsGrid->setColStretch( 0, 1 );
174  buttonsGrid->setColStretch( 6, 1 );
175 
176  //If setting the desktop wallpaper is supported on this system then add this button as well
177  if( setWallpaperSupported() )
178  {
179  setDesktopBtn = new QToolButton( buttonsFrame );
180  setDesktopBtn->setUsesTextLabel( true );
181  setDesktopBtn->setTextLabel(tr("Wallpaper") );
182  QIcon setDesktopIcon;
183  setDesktopIcon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/setDesktopWallpaper.png",
184  QIcon::Automatic,
185  QIcon::Normal );
186  setDesktopIcon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/setDesktopWallpaper_disabled.png",
187  QIcon::Automatic,
188  QIcon::Disabled );
189  setDesktopBtn->setIconSet( setDesktopIcon );
190 
191  setDesktopBtn->setTextPosition(QToolButton::BesideIcon);
192  setDesktopBtn->setFont( buttonFont );
193  setDesktopBtn->setUsesTextLabel( true );
194 
195  QToolTip::add( setDesktopBtn, tr("Set desktop wallpaper to selected photo") );
196  connect( setDesktopBtn, SIGNAL( clicked() ), this, SLOT( setWallpaperAction() ) );
197  buttonsGrid->addWidget( setDesktopBtn, 0, 5, Qt::AlignLeft );
198  }
199  else
200  { setDesktopBtn = NULL; }
201 
202  mainGrid = new Q3GridLayout( this, 2, 1, 0 );
203  mainGrid->addMultiCellWidget( photos, 0, 0, 0, 1 );
204  mainGrid->addMultiCellWidget( buttonsFrame, 1, 1, 0, 1 );
205  mainGrid->setRowStretch( 0, 1 );
206 
207  //set the background of the widget to be light blue
208  setPaletteBackgroundColor( QColor(193, 210, 238) );
209 
210  //by default no selected images so disable all buttons besides add
211  removeImage->setEnabled(false);
212  rotate90Image->setEnabled(false);
213  rotate270Image->setEnabled(false);
214 
215  //hook-up keyboard shortcut for deselecting all photos
216  //iconview provides select all shortcut for us
217  Q3Accel *keyAccel = new Q3Accel( this );
218  keyAccel->connectItem( keyAccel->insertItem( Qt::CTRL + Qt::SHIFT + Qt::Key_A ),
219  this, SLOT(deselectAll()) );
220 }
void addImageAction()
Adds an image to the subalbum.
Q3Frame * buttonsFrame
void removeImageAction()
Remove an image from the subalbum.
QToolButton * addImage
"Add" button
void rotate270ImageAction()
Rotate counter-clockwise selected images.
void setWallpaperAction()
set desktop wallpaper
bool setWallpaperSupported()
Does Album Shaper support setting the wallpaper on this system?
QToolButton * rotate270Image
"Rotate 270" button
Displays list of subalbums and a particular subalbum layout.
Definition: layoutWidget.h:39
QString IMAGE_PATH
Definition: config.cpp:18
Q3GridLayout * mainGrid
Grids widgets are placed in.
Q3GridLayout * buttonsGrid
Extension of iconview, used to list all photos in a subalbum. supports drag-n-drop within iconview...
QToolButton * removeImage
"Remove" button
QToolButton * rotate90Image
"Rotate 90" button
void rotate90ImageAction()
Rotate clockwise selected images.
QToolButton * setDesktopBtn
Set desktop wallpaper button.
PhotosIconView * photos
Photos layout.
void selectionChangedEvent()
handles changing selections
Subalbum * subalbum
Pointer to backend subalbum.
LayoutWidget * layout
Pointer to the parent layout widget.

Member Function Documentation

§ addImageAction [1/2]

void SubalbumWidget::addImageAction ( )
privateslot

Adds an image to the subalbum.

Definition at line 239 of file subalbumWidget.cpp.

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

Referenced by SubalbumWidget().

240 {
241  //---------------
242  //get file list
243 
244  Configuration* config = ((Window*)qApp->mainWidget())->getConfig();
245  QString path = config->getString( "loadSave", "addPhotoDir" );
246  QDir testPath(path);
247  if(!testPath.exists())
248  {
249  config->resetSetting( "loadSave", "addPhotoDir" );
250  path = config->getString( "loadSave", "addPhotoDir" );
251  }
252 
253  AddPhotosDialog* fileDialog = new AddPhotosDialog( path );
254  bool setDescriptions;
255  QStringList fileNames = fileDialog->getFilenames( setDescriptions );
256 
257  if(!fileNames.empty())
258  {
259  //store this addPhoto location
260  QDir lastDir = QDir( QFileInfo(*fileNames.begin()).dirPath() );
261  config->setString( "loadSave", "addPhotoDir", lastDir.path() );
262  addImageAction( fileNames, setDescriptions );
263  }
264 }
void addImageAction()
Adds an image to the subalbum.
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
Definition: window.h:39
QString getString(QString group, QString key)
Fetch string setting.
void resetSetting(QString group, QString key)
Resets a setting to it&#39;s default value.
void setString(QString group, QString key, QString value)
Sets a setting value, if group does not exist it is created, if setting does not exist it is also cre...
QStringList getFilenames(bool &setDescriptions)
returns the list of selected filenames, while setting setDescritions to the state the checkbox was le...
Simple dialog for browsing and select photos to add to a subalbum.
Configuration object manages all user-specific application settings.
Definition: configuration.h:24

§ addImageAction [2/2]

void SubalbumWidget::addImageAction ( QStringList  fileNames,
bool  setDescriptions = false 
)
privateslot

Definition at line 266 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().

267 {
268  if(fileNames.empty())
269  return;
270 
271  //---------------
272  //set busy flag and deactivate menu's/buttons, and selecting photos
273  layout->getWindow()->getTitle()->setBusy(true);
274  layout->getSubalbums()->updateButtons(false);
275  updateButtons(false);
276  photos->setSelectionMode( Q3IconView::NoSelection ) ;
277 
278  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
279 
280  //setup progress bar
281  QString statusMessage = tr("Adding %1 photos:");
282 
283  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(fileNames.count()), fileNames.count() );
284  qApp->processEvents();
285 
286  //iterate through each file and add to album
287  QStringList::iterator it;
288  int num=0;
289  for(it = fileNames.begin(); it != fileNames.end(); it++ )
290  {
291  //update status message
292  layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(fileNames.count() - num) );
293 
294  //if item is a file, add photo
295  if(QFileInfo(*it).isFile() && subalbum->addPhoto(*it, setDescriptions))
296  {
298  photos->ensureItemVisible(p);
299  }
300  num++;
301  qApp->processEvents();
302  }
303  photos->arrangeItemsInGrid();
304 
305  //remove progress bar
306  layout->getWindow()->getStatus()->setStatus( tr("Adding photos complete.") );
307 
308  //notifty title widget that the album's photo count has possible changed
310 
311  //unset busy flag and activate menu's/buttons
312  layout->getWindow()->getTitle()->setBusy(false);
314  updateButtons(true);
315  photos->setSelectionMode( Q3IconView::Extended ) ;
316 
317  qApp->restoreOverrideCursor();
318 }
bool 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: subalbum.cpp:198
void updateMenus(bool anySelected=false, bool anyRevertable=false)
update begin presentation menu entry - disabled when no photos in album
void showProgressBar(QString message, int numSteps)
Initializes the progress bar.
StatusWidget * getStatus()
returns a pointer to the status widget
Definition: window.cpp:198
Displays photo thumbnail and description.
void setBusy(bool val)
set program busy state
void setStatus(QString message)
Update message.
void updateButtons()
Activates/Deactives remove/rotate buttons depending on if an image is selected.
Window * getWindow()
Returns a pointer to the window.
void updateButtons(bool enable)
Activates/Deactives create/delete buttons.
PhotosIconView * photos
Photos layout.
SubalbumsWidget * getSubalbums()
Returns a pointer to the subalbums.
Subalbum * subalbum
Pointer to backend subalbum.
LayoutWidget * layout
Pointer to the parent layout widget.
TitleWidget * getTitle()
returns a pointer to the title widget
Definition: window.cpp:188
Photo * getLast()
Returns last photo in subalbum.
Definition: subalbum.cpp:101
void updateProgress(int progress, QString newMessage=QString::null)
Updates the progress bar.

§ anyPhotosSelected()

bool SubalbumWidget::anyPhotosSelected ( )

Returns true if any phtos are selected.

Definition at line 656 of file subalbumWidget.cpp.

References photos.

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

657 {
658  Q3IconViewItem* current = photos->firstItem();
659  while(current != NULL)
660  {
661  if(current->isSelected())
662  return true;
663  current = current->nextItem();
664  }
665  return false;
666 }
PhotosIconView * photos
Photos layout.

§ anySelectedPhotosRevertable()

bool SubalbumWidget::anySelectedPhotosRevertable ( )

Returns true if any selected photos are revertable.

Definition at line 668 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::photoStateChangedEvent().

669 {
670  Q3IconViewItem* current = photos->firstItem();
671  while(current != NULL)
672  {
673  if(current->isSelected())
674  {
675  if( ((PhotoPreviewWidget*)current)->getPhoto()->revertPossible() )
676  return true;
677  }
678  current = current->nextItem();
679  }
680  return false;
681 }
Displays photo thumbnail and description.
PhotosIconView * photos
Photos layout.

§ deselectAll

void SubalbumWidget::deselectAll ( )
privateslot

Definition at line 782 of file subalbumWidget.cpp.

References photos.

Referenced by SubalbumWidget().

783 {
784  photos->selectAll(false);
785 }
PhotosIconView * photos
Photos layout.

§ getFirstSelectedPhoto()

Photo * SubalbumWidget::getFirstSelectedPhoto ( )

Returns first selected photo.

Definition at line 615 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::tabChanged().

616 {
617  //determine if one photo is selected
618  Q3IconViewItem* current = photos->firstItem();
619  while(current != NULL)
620  {
621  //found a selected item!
622  if(current->isSelected())
623  { return ((PhotoPreviewWidget*)current)->getPhoto(); }
624 
625  //move to next item
626  current = current->nextItem();
627  }
628 
629  //no selected items found
630  return NULL;
631 }
Displays photo thumbnail and description.
PhotosIconView * photos
Photos layout.

§ getPhotos()

Q3IconView * SubalbumWidget::getPhotos ( )

Returns pointer to icon view.

Definition at line 688 of file subalbumWidget.cpp.

References photos.

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

689 {
690  return photos;
691 }
PhotosIconView * photos
Photos layout.

§ getSelectedPhoto()

Photo * SubalbumWidget::getSelectedPhoto ( )

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

Definition at line 588 of file subalbumWidget.cpp.

References photos.

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

589 {
590  //determine if one photo is selected
591  int numSelected = 0;
592  Q3IconViewItem* current = photos->firstItem();
593  Q3IconViewItem* selected = NULL;
594  while(current != NULL)
595  {
596  //found a selected item!
597  if(current->isSelected())
598  {
599  numSelected++;
600  selected = current;
601  }
602 
603  //if more than one found then bail!
604  if(numSelected > 1) return NULL;
605 
606  //move to next item
607  current = current->nextItem();
608  }
609 
610  //if one item is selected then return photo pointer
611  if(numSelected == 1) { return ((PhotoPreviewWidget*)selected)->getPhoto(); }
612  else { return NULL; }
613 }
Displays photo thumbnail and description.
PhotosIconView * photos
Photos layout.

§ getSubalbum()

Subalbum * SubalbumWidget::getSubalbum ( )

returns a pointer to the backend subalbum

Definition at line 583 of file subalbumWidget.cpp.

References subalbum.

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

584 {
585  return subalbum;
586 }
Subalbum * subalbum
Pointer to backend subalbum.

§ refreshAllPhotos()

void SubalbumWidget::refreshAllPhotos ( )

refreshes all photos, selections are preserved

Definition at line 538 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::tabChanged().

539 {
540  Q3IconViewItem* current = photos->firstItem();
541  while(current != NULL)
542  {
543  ((PhotoPreviewWidget*)current)->updateImage();
544  ((PhotoPreviewWidget*)current)->updateDescription();
545  current = current->nextItem();
546  }
547 }
Displays photo thumbnail and description.
PhotosIconView * photos
Photos layout.

§ refreshPhotos()

void SubalbumWidget::refreshPhotos ( )

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

Definition at line 519 of file subalbumWidget.cpp.

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

Referenced by setSubalbum().

520 {
521  //remove all thumbnails
522  photos->clear();
523 
524  if(subalbum != NULL)
525  {
526  //insert photo thumbnails
527  Photo* currentPhoto = subalbum->getFirst();
528  while(currentPhoto != NULL)
529  {
530  new PhotoPreviewWidget( photos, currentPhoto );
531  currentPhoto = currentPhoto->getNext();
532  }
533 
534  photos->arrangeItemsInGrid();
535  }
536 }
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
Definition: photo.h:44
Displays photo thumbnail and description.
Photo * getNext()
Returns next photo pointer.
Definition: photo.cpp:225
Photo * getFirst()
Returns first photo in subalbum.
Definition: subalbum.cpp:100
PhotosIconView * photos
Photos layout.
Subalbum * subalbum
Pointer to backend subalbum.

§ refreshSelectedPhotos()

void SubalbumWidget::refreshSelectedPhotos ( )

refreshes selected photos, selections are preserved

Definition at line 549 of file subalbumWidget.cpp.

References photos.

550 {
551  Q3IconViewItem* current = photos->firstItem();
552  while(current != NULL)
553  {
554  //found a selected item!
555  if(current->isSelected())
556  {
557  ((PhotoPreviewWidget*)current)->updateImage();
558  ((PhotoPreviewWidget*)current)->updateDescription();
559  }
560 
561  //move to next item
562  current = current->nextItem();
563  }
564 }
Displays photo thumbnail and description.
PhotosIconView * photos
Photos layout.

§ removeImageAction

void SubalbumWidget::removeImageAction ( )
privateslot

Remove an image from the subalbum.

Definition at line 320 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().

321 {
322  //set busy flag and deactivate menu's/buttons
323  layout->getWindow()->getTitle()->setBusy(true);
324  layout->getSubalbums()->updateButtons(false);
325  updateButtons(false);
326  photos->setSelectionMode( Q3IconView::NoSelection ) ;
327 
328  //if user has chosen to not receive destructive action warnings, or agrees to the action, then
329  //delete photo and refresh view
330  bool proceed = !((Window*)qApp->mainWidget())->getConfig()->getBool( "alerts", "showDestructiveAlerts" );
331  if(!proceed)
332  {
333  QuestionDialog sure( tr("Remove selected photos?"),
334  tr("Once removed photos cannot be restored. Furthermore upon resaving they are physically removed from your album."),
335  "alertIcons/warning.png",
336  this );
337  proceed = sure.exec();
338  }
339  if(proceed)
340  {
341  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
342  //iterate through all photos and remove those that are selected
343  Q3IconViewItem* current = photos->firstItem();
344  Q3IconViewItem* temp;
345 
346  while(current != NULL)
347  {
348  //if not selected move on
349  if(!current->isSelected())
350  {
351  current = current->nextItem();
352  continue;
353  }
354 
355  //get next pointer
356  temp = current->nextItem();
357 
358  //grab point to backend photo
359  Photo* phto = ((PhotoPreviewWidget*)current)->getPhoto();
360 
361  //delete photo widget
362  delete current;
363  current = temp;
364 
365  //delete backend photo
366  subalbum->removePhoto(phto);
367  }
368 
369  //cleanup arrangement in case items were deleted in the middle or front
370  photos->arrangeItemsInGrid();
371 
372  //unset busy flag and activate menu's/buttons
373  qApp->restoreOverrideCursor();
374  }
375 
376  layout->getWindow()->getTitle()->setBusy(false);
378  updateButtons(true);
379  photos->setSelectionMode( Q3IconView::Extended ) ;
380 
381  //update buttons and emit selection changed signal
383 }
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
Definition: photo.h:44
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
Definition: window.h:39
Displays photo thumbnail and description.
void setBusy(bool val)
set program busy state
void updateButtons()
Activates/Deactives remove/rotate buttons depending on if an image is selected.
Window * getWindow()
Returns a pointer to the window.
void updateButtons(bool enable)
Activates/Deactives create/delete buttons.
PhotosIconView * photos
Photos layout.
SubalbumsWidget * getSubalbums()
Returns a pointer to the subalbums.
void selectionChangedEvent()
handles changing selections
Subalbum * subalbum
Pointer to backend subalbum.
A configurable question dialog that returns true/false.
LayoutWidget * layout
Pointer to the parent layout widget.
void removePhoto(Photo *val)
Removes a specified photo.
Definition: subalbum.cpp:281
TitleWidget * getTitle()
returns a pointer to the title widget
Definition: window.cpp:188

§ reorder

void SubalbumWidget::reorder ( )
privateslot

Definition at line 693 of file subalbumWidget.cpp.

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

Referenced by SubalbumWidget().

694 {
695  //so item has been moved, reorder linked list of items as necessary
696  photos->sort( true );
697  photos->arrangeItemsInGrid();
698 
699  //sync lists
701 }
Displays photo thumbnail and description.
PhotosIconView * photos
Photos layout.
void syncPhotoList(PhotoPreviewWidget *item)
Syncs photo ordering with front end gui ordering.
Definition: subalbum.cpp:501
Subalbum * subalbum
Pointer to backend subalbum.

§ resizeEvent()

void SubalbumWidget::resizeEvent ( QResizeEvent *  )
protected

Definition at line 683 of file subalbumWidget.cpp.

References photos.

684 {
685  photos->arrangeItemsInGrid();
686 }
PhotosIconView * photos
Photos layout.

§ revertSelectedPhotos()

void SubalbumWidget::revertSelectedPhotos ( )

Revert selected photos to their original form.

Definition at line 385 of file subalbumWidget.cpp.

References photos, and selectedPhotoStateChanged().

Referenced by LayoutWidget::revertPhotos().

386 {
387  //iterate over photos in current collection
388  Q3IconViewItem* current = photos->firstItem();
389  while(current != NULL)
390  {
391  //found a selected item!
392  if(current->isSelected())
393  {
394  ((PhotoPreviewWidget*)current)->getPhoto()->revertPhoto();
395  photos->ensureItemVisible(((PhotoPreviewWidget*)current));
396  ((PhotoPreviewWidget*)current)->updateImage();
397  qApp->processEvents();
398  }
399 
400  //move to next item
401  current = current->nextItem();
402  }
403 
404  //state of selected photos has changed
406 }
Displays photo thumbnail and description.
void selectedPhotoStateChanged()
PhotosIconView * photos
Photos layout.

§ rotate270ImageAction

void SubalbumWidget::rotate270ImageAction ( )
privateslot

Rotate counter-clockwise selected images.

Definition at line 469 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().

470 {
471  //set busy flag and deactivate menu's/buttons
472  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
473  layout->getWindow()->getTitle()->setBusy(true);
474  layout->getSubalbums()->updateButtons(false);
475  photos->setSelectionMode( Q3IconView::NoSelection ) ;
476  updateButtons(false);
477 
478  //setup progress bar
479  QString statusMessage = tr("Rotating %1 photos:");
480  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(photos->numSelected()), photos->numSelected() );
481  qApp->processEvents();
482 
483  //rotate the selected photos
484  int num = 0;
485  Q3IconViewItem* current = photos->firstItem();
486  while(current != NULL)
487  {
488  if(current->isSelected())
489  {
490  //update status message
491  layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(photos->numSelected() - num) );
492 
493  ((PhotoPreviewWidget*)current)->getPhoto()->rotate270();
494  photos->ensureItemVisible(((PhotoPreviewWidget*)current));
495  ((PhotoPreviewWidget*)current)->updateImage();
496  num++;
498  qApp->processEvents();
499  }
500 
501  //move to next item
502  current = current->nextItem();
503  }
504 
505  //state of selected photos has changed
507 
508  //hide progress bar
509  layout->getWindow()->getStatus()->setStatus( tr("Rotating complete.") );
510 
511  //not busy any more
512  layout->getWindow()->getTitle()->setBusy(false);
514  updateButtons(true);
515  photos->setSelectionMode( Q3IconView::Extended ) ;
516  qApp->restoreOverrideCursor();
517 }
void showProgressBar(QString message, int numSteps)
Initializes the progress bar.
StatusWidget * getStatus()
returns a pointer to the status widget
Definition: window.cpp:198
Displays photo thumbnail and description.
void setBusy(bool val)
set program busy state
void setStatus(QString message)
Update message.
void selectedPhotoStateChanged()
void updateButtons()
Activates/Deactives remove/rotate buttons depending on if an image is selected.
Window * getWindow()
Returns a pointer to the window.
void updateButtons(bool enable)
Activates/Deactives create/delete buttons.
PhotosIconView * photos
Photos layout.
SubalbumsWidget * getSubalbums()
Returns a pointer to the subalbums.
LayoutWidget * layout
Pointer to the parent layout widget.
TitleWidget * getTitle()
returns a pointer to the title widget
Definition: window.cpp:188
void updateProgress(int progress, QString newMessage=QString::null)
Updates the progress bar.

§ rotate90ImageAction

void SubalbumWidget::rotate90ImageAction ( )
privateslot

Rotate clockwise selected images.

Definition at line 418 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().

419 {
420  //set busy flag and deactivate menu's/buttons
421  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
422  layout->getWindow()->getTitle()->setBusy(true);
423  layout->getSubalbums()->updateButtons(false);
424  photos->setSelectionMode( Q3IconView::NoSelection ) ;
425  updateButtons(false);
426 
427  //setup progress bar
428  QString statusMessage = tr("Rotating %1 photos:");
429  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(photos->numSelected()), photos->numSelected() );
430  qApp->processEvents();
431 
432  //rotate the selected photos
433  int num = 0;
434  Q3IconViewItem* current = photos->firstItem();
435  while(current != NULL)
436  {
437  if(current->isSelected())
438  {
439  //update status message
440  layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(photos->numSelected() - num) );
441 
442  ((PhotoPreviewWidget*)current)->getPhoto()->rotate90();
443  photos->ensureItemVisible(((PhotoPreviewWidget*)current));
444  ((PhotoPreviewWidget*)current)->updateImage();
445  num++;
447  qApp->processEvents();
448  }
449 
450  //move to next item
451  current = current->nextItem();
452  }
453 
454  //state of selected photos has changed
456 
457  //hide progress bar
458  layout->getWindow()->getStatus()->setStatus( tr("Rotating complete.") );
459 
460  //not busy any more
461  layout->getWindow()->getTitle()->setBusy(false);
463  updateButtons(true);
464  photos->setSelectionMode( Q3IconView::Extended ) ;
465 
466  qApp->restoreOverrideCursor();
467 }
void showProgressBar(QString message, int numSteps)
Initializes the progress bar.
StatusWidget * getStatus()
returns a pointer to the status widget
Definition: window.cpp:198
Displays photo thumbnail and description.
void setBusy(bool val)
set program busy state
void setStatus(QString message)
Update message.
void selectedPhotoStateChanged()
void updateButtons()
Activates/Deactives remove/rotate buttons depending on if an image is selected.
Window * getWindow()
Returns a pointer to the window.
void updateButtons(bool enable)
Activates/Deactives create/delete buttons.
PhotosIconView * photos
Photos layout.
SubalbumsWidget * getSubalbums()
Returns a pointer to the subalbums.
LayoutWidget * layout
Pointer to the parent layout widget.
TitleWidget * getTitle()
returns a pointer to the title widget
Definition: window.cpp:188
void updateProgress(int progress, QString newMessage=QString::null)
Updates the progress bar.

§ selectedPhotoStateChanged

void SubalbumWidget::selectedPhotoStateChanged ( )
signal

§ selectionChangedEvent

void SubalbumWidget::selectionChangedEvent ( )
privateslot

handles changing selections

Definition at line 703 of file subalbumWidget.cpp.

References selectedPhotoStateChanged(), and updateButtons().

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

704 {
705  //update rotate/add/remove buttons depending on whether or not any items are selected
706  updateButtons();
707 
708  //emit selection changed signal so other menu's etc an be updated as well
710 }
void selectedPhotoStateChanged()
void updateButtons()
Activates/Deactives remove/rotate buttons depending on if an image is selected.

§ setSelectedPhoto()

void SubalbumWidget::setSelectedPhoto ( Photo selection)

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

Definition at line 633 of file subalbumWidget.cpp.

References photos.

Referenced by LayoutWidget::tabChanged().

634 {
635  //select specified photo
636  Q3IconViewItem* current = photos->firstItem();
637  while(current != NULL)
638  {
639  if( ((PhotoPreviewWidget*)current)->getPhoto() == selection )
640  {
641  //deselect all
642  photos->selectAll(false);
643 
644  //select photo and make sure it is visible
645  current->setSelected(true);
646  photos->ensureItemVisible( current );
647 
648  return;
649  }
650 
651  //move on to next photo
652  current = current->nextItem();
653  }
654 }
Displays photo thumbnail and description.
PhotosIconView * photos
Photos layout.

§ setSubalbum()

void SubalbumWidget::setSubalbum ( Subalbum salbum)

Resets the subalbum this subalbum widget is displaying.

Definition at line 222 of file subalbumWidget.cpp.

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

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

223 {
224  //set new subalbum pointer
225  subalbum = salbum;
226 
227  //update photo listing
228  refreshPhotos();
229 
230  if(subalbum == NULL) { buttonsFrame->hide(); }
231  else
232  {
233  //disable/enable buttons as necessary
234  buttonsFrame->show();
236  }
237 }
Q3Frame * buttonsFrame
void refreshPhotos()
clears and reinserts all photos for the current collection the current selection is cleared ...
void selectionChangedEvent()
handles changing selections
Subalbum * subalbum
Pointer to backend subalbum.

§ setWallpaperAction

void SubalbumWidget::setWallpaperAction ( )
privateslot

set desktop wallpaper

Definition at line 408 of file subalbumWidget.cpp.

References getSelectedPhoto(), and setWallpaper().

Referenced by SubalbumWidget().

409 {
410  //get first selected photo, if no photo is selected then bail
411  Photo* phto = getSelectedPhoto();
412  if(phto == NULL) return;
413 
414  //set the wallpaper
415  setWallpaper( phto );
416 }
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
Definition: photo.h:44
Photo * getSelectedPhoto()
Returns currently selected photo. If no or multiple photos selected returns NULL. ...
void setWallpaper(Photo *phto)
Sets desktop wallpaper using specified photo.

§ stripDescriptionsFromSelectedPhotos()

void SubalbumWidget::stripDescriptionsFromSelectedPhotos ( )

Strip descriptions from selected photos.

Definition at line 566 of file subalbumWidget.cpp.

References photos.

Referenced by TitleWidget::removeSelectedPhotoDesc().

567 {
568  Q3IconViewItem* current = photos->firstItem();
569  while(current != NULL)
570  {
571  //found a selected item!
572  if(current->isSelected())
573  {
574  ((PhotoPreviewWidget*)current)->getPhoto()->setDescription("");
575  ((PhotoPreviewWidget*)current)->setText( "" );
576  }
577 
578  //move to next item
579  current = current->nextItem();
580  }
581 }
Displays photo thumbnail and description.
PhotosIconView * photos
Photos layout.

§ updateButtons() [1/2]

void SubalbumWidget::updateButtons ( bool  enable)

Activates/Deactives remove/rotate buttons.

Definition at line 755 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().

756 {
757  if(!enable)
758  {
759  buttonsState = rotate90Image->isEnabled();
760  addImage->setEnabled(enable && true);
761  removeImage->setEnabled(enable && true);
762  rotate90Image->setEnabled(enable);
763  rotate270Image->setEnabled(enable);
764  if(setDesktopBtn)
765  {
766  wallpaperButtonState = setDesktopBtn->isEnabled();
767  setDesktopBtn->setEnabled(enable);
768  }
769  layout->setEditTabEnabled(enable);
770  }
771  else
772  {
773  addImage->setEnabled(enable && true);
774  removeImage->setEnabled(buttonsState && true);
775  rotate90Image->setEnabled(buttonsState);
776  rotate270Image->setEnabled(buttonsState);
777  if(setDesktopBtn) { setDesktopBtn->setEnabled(wallpaperButtonState); }
779  }
780 }
bool wallpaperButtonState
cached enabled/distable state of set wallpaper button
QToolButton * addImage
"Add" button
QToolButton * rotate270Image
"Rotate 270" button
bool buttonsState
cached enabled/disabled state of buttons
QToolButton * removeImage
"Remove" button
QToolButton * rotate90Image
"Rotate 90" button
void setEditTabEnabled(bool val)
QToolButton * setDesktopBtn
Set desktop wallpaper button.
LayoutWidget * layout
Pointer to the parent layout widget.

§ updateButtons [2/2]

void SubalbumWidget::updateButtons ( )
privateslot

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

Definition at line 712 of file subalbumWidget.cpp.

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

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

713 {
714  int numSelected = 0;
715  Q3IconViewItem* current = photos->firstItem();
716  while(current != NULL)
717  {
718  if(current->isSelected())
719  {
720  numSelected++;
721 
722  //there are effectively 3 states:
723  //1) no items selected -> disable all buttons besides addPhoto
724  //2) one itme selected -> enable all button, including set desktop wallpaper button
725  //3) more than one item selected -> enable all but edit button (since we don't know which photo to edit)
726  //thus once 2 selected photos are found we know we are in the multi select mode and can terminate the search
727  if(numSelected > 1)
728  break;
729  }
730 
731  //move to next item
732  current = current->nextItem();
733  }
734 
735  if(numSelected == 0)
736  {
737  removeImage->setEnabled(false);
738  rotate90Image->setEnabled(false);
739  rotate270Image->setEnabled(false);
740  if(setDesktopBtn) { setDesktopBtn->setEnabled(false); }
741  layout->setEditTabEnabled(false);
742  }
743  else
744  {
745  removeImage->setEnabled(true);
746  rotate90Image->setEnabled(true);
747  rotate270Image->setEnabled(true);
748  if(setDesktopBtn) { setDesktopBtn->setEnabled(true); }
749  layout->setEditTabEnabled(true);
750  }
751 
752  if(setDesktopBtn) { setDesktopBtn->setEnabled( numSelected == 1 ); }
753 }
QToolButton * rotate270Image
"Rotate 270" button
QToolButton * removeImage
"Remove" button
QToolButton * rotate90Image
"Rotate 90" button
void setEditTabEnabled(bool val)
QToolButton * setDesktopBtn
Set desktop wallpaper button.
PhotosIconView * photos
Photos layout.
LayoutWidget * layout
Pointer to the parent layout widget.

Member Data Documentation

§ addImage

QToolButton* SubalbumWidget::addImage
private

"Add" button

Definition at line 145 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

§ buttonsFrame

Q3Frame* SubalbumWidget::buttonsFrame
private

Definition at line 136 of file subalbumWidget.h.

Referenced by setSubalbum(), and SubalbumWidget().

§ buttonsGrid

Q3GridLayout* SubalbumWidget::buttonsGrid
private

Definition at line 132 of file subalbumWidget.h.

Referenced by SubalbumWidget().

§ buttonsState

bool SubalbumWidget::buttonsState
private

cached enabled/disabled state of buttons

Definition at line 163 of file subalbumWidget.h.

Referenced by updateButtons().

§ layout

LayoutWidget* SubalbumWidget::layout
private

Pointer to the parent layout widget.

Definition at line 160 of file subalbumWidget.h.

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

§ mainGrid

Q3GridLayout* SubalbumWidget::mainGrid
private

Grids widgets are placed in.

Definition at line 131 of file subalbumWidget.h.

Referenced by SubalbumWidget().

§ photos

PhotosIconView* SubalbumWidget::photos
private

§ removeImage

QToolButton* SubalbumWidget::removeImage
private

"Remove" button

Definition at line 148 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

§ rotate270Image

QToolButton* SubalbumWidget::rotate270Image
private

"Rotate 270" button

Definition at line 154 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

§ rotate90Image

QToolButton* SubalbumWidget::rotate90Image
private

"Rotate 90" button

Definition at line 151 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

§ setDesktopBtn

QToolButton* SubalbumWidget::setDesktopBtn
private

Set desktop wallpaper button.

Definition at line 157 of file subalbumWidget.h.

Referenced by SubalbumWidget(), and updateButtons().

§ subalbum

Subalbum* SubalbumWidget::subalbum
private

Pointer to backend subalbum.

Definition at line 142 of file subalbumWidget.h.

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

§ thumbnailFrame

Q3Frame* SubalbumWidget::thumbnailFrame
private

Grid lower buttons are placed in.

Definition at line 135 of file subalbumWidget.h.

§ wallpaperButtonState

bool SubalbumWidget::wallpaperButtonState
private

cached enabled/distable state of set wallpaper button

Definition at line 166 of file subalbumWidget.h.

Referenced by updateButtons().


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