#include <subalbumWidget.h>
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 | |
Subalbum * | getSubalbum () |
returns a pointer to the backend subalbum | |
Photo * | getSelectedPhoto () |
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. | |
Photo * | getFirstSelectedPhoto () |
Returns first selected photo. | |
bool | anyPhotosSelected () |
Returns true if any phtos are selected. | |
bool | anySelectedPhotosRevertable () |
Returns true if any selected photos are revertable. | |
QIconView * | getPhotos () |
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 |
QFrame * | thumbnailFrame |
Grid lower buttons are placed in. | |
QFrame * | buttonsFrame |
PhotosIconView * | photos |
Photos layout. | |
Subalbum * | subalbum |
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. | |
LayoutWidget * | layout |
Pointer to the parent layout widget. | |
bool | buttonsState |
cached enabled/disabled state of buttons | |
bool | wallpaperButtonState |
cached enabled/distable state of set wallpaper button |
Definition at line 35 of file subalbumWidget.h.
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.
00051 : 00052 QWidget(parent,name) 00053 { 00054 setWFlags(WNoAutoErase); 00055 00056 //store subalbum pointer 00057 subalbum = salbum; 00058 00059 //store layout pointer 00060 layout = (LayoutWidget*)parent; 00061 00062 //create photo collection 00063 photos = new PhotosIconView( this ); 00064 00065 //establish a top-down view such that the scrollbar is always placed on the right 00066 photos->setArrangement( QIconView::LeftToRight ); 00067 photos->setVScrollBarMode( QScrollView::Auto ); 00068 00069 //allow multiple photos to be selected with control and shift keys 00070 photos->setSelectionMode( QIconView::Extended ) ; 00071 00072 //set auto-scroll on for drag-n-drop 00073 photos->setDragAutoScroll(true); 00074 photos->setAcceptDrops(true); 00075 00076 //connect selectionChanged signal to update buttons method 00077 connect( photos, SIGNAL(selectionChanged()), 00078 this, SLOT( selectionChangedEvent()) ); 00079 00080 //connect rightButtonClicked signal to update buttons method 00081 connect( photos, SIGNAL(rightButtonClicked(QIconViewItem*, const QPoint&)), 00082 this, SLOT(selectionChangedEvent()) ); 00083 00084 //connect itemhasMoved signal on iconview to reorder slot (phots have been rearranged) 00085 connect( photos, SIGNAL(itemHasMoved()), SLOT(reorder()) ); 00086 00087 //connect addPhtos signal from iconview to actually add photos from disk (Drop from outside target, ie konqueror) 00088 connect( photos, SIGNAL(addPhotos(QStringList)), SLOT(addImageAction(QStringList)) ); 00089 00090 //connect keyevent signals from iconview 00091 connect( photos, SIGNAL(removeSelectedPhotos()), SLOT(removeImageAction()) ); 00092 connect( photos, SIGNAL(rotate90SelectedPhotos()), SLOT(rotate90ImageAction()) ); 00093 connect( photos, SIGNAL(rotate270SelectedPhotos()), SLOT(rotate270ImageAction()) ); 00094 00095 //connect key e press signal to edit slot 00096 connect( photos, SIGNAL(editSelectedPhoto()), 00097 layout, SLOT(editSelectedPhoto()) ); 00098 //connect double click signal to edit slot 00099 connect( photos, SIGNAL( doubleClicked(QIconViewItem*) ), 00100 layout, SLOT(editSelectedPhoto()) ); 00101 00102 //create all buttons 00103 buttonsFrame = new QFrame(this); 00104 if(subalbum == NULL) buttonsFrame->hide(); 00105 00106 QFont buttonFont( qApp->font() ); 00107 buttonFont.setBold(true); 00108 buttonFont.setPointSize( 11 ); 00109 00110 addImage = new QToolButton( buttonsFrame ); 00111 addImage->setTextLabel(tr("Add Photo")); 00112 addImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/add.png") ); 00113 addImage->setTextPosition(QToolButton::Right); 00114 addImage->setFont( buttonFont ); 00115 addImage->setUsesTextLabel( true ); 00116 addImage->setEnabled( true ); 00117 QToolTip::add( addImage, tr("Add photos to selected collection") ); 00118 connect( addImage, SIGNAL(clicked()), SLOT(addImageAction()) ); 00119 00120 removeImage = new QToolButton( buttonsFrame ); 00121 removeImage->setTextLabel(tr("Remove Photo")); 00122 removeImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/remove.png") ); 00123 removeImage->setTextPosition(QToolButton::Right); 00124 removeImage->setFont( buttonFont ); 00125 removeImage->setUsesTextLabel( true ); 00126 removeImage->setEnabled( true ); 00127 QToolTip::add( removeImage, tr("Remove selected photos from collection") ); 00128 connect( removeImage, SIGNAL(clicked()), SLOT(removeImageAction()) ); 00129 00130 rotate90Image = new QToolButton( buttonsFrame ); 00131 rotate90Image->setTextLabel(tr("Rotate Right") ); 00132 QIconSet rotate90Icon; 00133 rotate90Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate90.png", 00134 QIconSet::Automatic, 00135 QIconSet::Normal ); 00136 rotate90Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate90_disabled.png", 00137 QIconSet::Automatic, 00138 QIconSet::Disabled ); 00139 rotate90Image->setIconSet( rotate90Icon ); 00140 00141 rotate90Image->setTextPosition(QToolButton::Right); 00142 rotate90Image->setFont( buttonFont ); 00143 rotate90Image->setUsesTextLabel( true ); 00144 QToolTip::add( rotate90Image, tr("Rotate selected photos clockwise") ); 00145 connect( rotate90Image, SIGNAL(clicked()), SLOT(rotate90ImageAction()) ); 00146 00147 rotate270Image = new QToolButton( buttonsFrame ); 00148 rotate270Image->setTextLabel(tr("Rotate Left") ); 00149 QIconSet rotate270Icon; 00150 rotate270Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate270.png", 00151 QIconSet::Automatic, 00152 QIconSet::Normal ); 00153 rotate270Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate270_disabled.png", 00154 QIconSet::Automatic, 00155 QIconSet::Disabled ); 00156 rotate270Image->setIconSet( rotate270Icon ); 00157 00158 rotate270Image->setTextPosition(QToolButton::Right); 00159 rotate270Image->setFont( buttonFont ); 00160 rotate270Image->setUsesTextLabel( true ); 00161 QToolTip::add( rotate270Image, tr("Rotate selected photos counterclockwise") ); 00162 connect( rotate270Image, SIGNAL(clicked()), SLOT(rotate270ImageAction()) ); 00163 00164 //place all items in grid layout 00165 buttonsGrid = new QGridLayout( buttonsFrame, 1, 7, 0 ); 00166 buttonsGrid->addWidget( addImage, 0, 1, Qt::AlignLeft ); 00167 buttonsGrid->addWidget( removeImage, 0, 2, Qt::AlignLeft ); 00168 buttonsGrid->addWidget( rotate90Image, 0, 3, Qt::AlignLeft ); 00169 buttonsGrid->addWidget( rotate270Image, 0, 4, Qt::AlignLeft ); 00170 buttonsGrid->setColStretch( 0, 1 ); 00171 buttonsGrid->setColStretch( 6, 1 ); 00172 00173 //If setting the desktop wallpaper is supported on this system then add this button as well 00174 if( setWallpaperSupported() ) 00175 { 00176 setDesktopBtn = new QToolButton( buttonsFrame ); 00177 setDesktopBtn->setUsesTextLabel( true ); 00178 setDesktopBtn->setTextLabel(tr("Wallpaper") ); 00179 QIconSet setDesktopIcon; 00180 setDesktopIcon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/setDesktopWallpaper.png", 00181 QIconSet::Automatic, 00182 QIconSet::Normal ); 00183 setDesktopIcon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/setDesktopWallpaper_disabled.png", 00184 QIconSet::Automatic, 00185 QIconSet::Disabled ); 00186 setDesktopBtn->setIconSet( setDesktopIcon ); 00187 00188 setDesktopBtn->setTextPosition(QToolButton::Right); 00189 setDesktopBtn->setFont( buttonFont ); 00190 setDesktopBtn->setUsesTextLabel( true ); 00191 00192 QToolTip::add( setDesktopBtn, tr("Set desktop wallpaper to selected photo") ); 00193 connect( setDesktopBtn, SIGNAL( clicked() ), this, SLOT( setWallpaperAction() ) ); 00194 buttonsGrid->addWidget( setDesktopBtn, 0, 5, Qt::AlignLeft ); 00195 } 00196 else 00197 { setDesktopBtn = NULL; } 00198 00199 mainGrid = new QGridLayout( this, 2, 1, 0 ); 00200 mainGrid->addMultiCellWidget( photos, 0, 0, 0, 1 ); 00201 mainGrid->addMultiCellWidget( buttonsFrame, 1, 1, 0, 1 ); 00202 mainGrid->setRowStretch( 0, 1 ); 00203 00204 //set the background of the widget to be light blue 00205 setPaletteBackgroundColor( QColor(193, 210, 238) ); 00206 00207 //by default no selected images so disable all buttons besides add 00208 removeImage->setEnabled(false); 00209 rotate90Image->setEnabled(false); 00210 rotate270Image->setEnabled(false); 00211 00212 //hook-up keyboard shortcut for deselecting all photos 00213 //iconview provides select all shortcut for us 00214 QAccel *keyAccel = new QAccel( this ); 00215 keyAccel->connectItem( keyAccel->insertItem( CTRL + SHIFT + Key_A ), 00216 this, SLOT(deselectAll()) ); 00217 } //==============================================
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, updateButtons(), SubalbumsWidget::updateButtons(), TitleWidget::updateMenus(), and StatusWidget::updateProgress().
00264 { 00265 if(fileNames.empty()) 00266 return; 00267 00268 //--------------- 00269 //set busy flag and deactivate menu's/buttons, and selecting photos 00270 layout->getWindow()->getTitle()->setBusy(true); 00271 layout->getSubalbums()->updateButtons(false); 00272 updateButtons(false); 00273 photos->setSelectionMode( QIconView::NoSelection ) ; 00274 00275 qApp->setOverrideCursor( QCursor(Qt::WaitCursor)); 00276 00277 //setup progress bar 00278 QString statusMessage = tr("Adding %1 photos:"); 00279 00280 layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(fileNames.count()), fileNames.count() ); 00281 qApp->processEvents(); 00282 00283 //iterate through each file and add to album 00284 QStringList::iterator it; 00285 int num=0; 00286 for(it = fileNames.begin(); it != fileNames.end(); it++ ) 00287 { 00288 //update status message 00289 layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(fileNames.count() - num) ); 00290 00291 //if item is a file, add photo 00292 if(QFileInfo(*it).isFile() && subalbum->addPhoto(*it, setDescriptions)) 00293 { 00294 PhotoPreviewWidget* p = new PhotoPreviewWidget( photos, subalbum->getLast() ); 00295 photos->ensureItemVisible(p); 00296 } 00297 num++; 00298 qApp->processEvents(); 00299 } 00300 photos->arrangeItemsInGrid(); 00301 00302 //remove progress bar 00303 layout->getWindow()->getStatus()->setStatus( tr("Adding photos complete.") ); 00304 00305 //notifty title widget that the album's photo count has possible changed 00306 layout->getWindow()->getTitle()->updateMenus(); 00307 00308 //unset busy flag and activate menu's/buttons 00309 layout->getWindow()->getTitle()->setBusy(false); 00310 layout->getSubalbums()->updateButtons(true); 00311 updateButtons(true); 00312 photos->setSelectionMode( QIconView::Extended ) ; 00313 00314 qApp->restoreOverrideCursor(); 00315 }
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().
00237 { 00238 //--------------- 00239 //get file list 00240 00241 Configuration* config = ((Window*)qApp->mainWidget())->getConfig(); 00242 QString path = config->getString( "loadSave", "addPhotoDir" ); 00243 QDir testPath(path); 00244 if(!testPath.exists()) 00245 { 00246 config->resetSetting( "loadSave", "addPhotoDir" ); 00247 path = config->getString( "loadSave", "addPhotoDir" ); 00248 } 00249 00250 AddPhotosDialog* fileDialog = new AddPhotosDialog( path ); 00251 bool setDescriptions; 00252 QStringList fileNames = fileDialog->getFilenames( setDescriptions ); 00253 00254 if(!fileNames.empty()) 00255 { 00256 //store this addPhoto location 00257 QDir lastDir = QDir( QFileInfo(*fileNames.begin()).dirPath() ); 00258 config->setString( "loadSave", "addPhotoDir", lastDir.path() ); 00259 addImageAction( fileNames, setDescriptions ); 00260 } 00261 }
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().
00654 { 00655 QIconViewItem* current = photos->firstItem(); 00656 while(current != NULL) 00657 { 00658 if(current->isSelected()) 00659 return true; 00660 current = current->nextItem(); 00661 } 00662 return false; 00663 }
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().
00666 { 00667 QIconViewItem* current = photos->firstItem(); 00668 while(current != NULL) 00669 { 00670 if(current->isSelected()) 00671 { 00672 if( ((PhotoPreviewWidget*)current)->getPhoto()->revertPossible() ) 00673 return true; 00674 } 00675 current = current->nextItem(); 00676 } 00677 return false; 00678 }
void SubalbumWidget::deselectAll | ( | ) | [private, slot] |
Definition at line 779 of file subalbumWidget.cpp.
References photos.
Referenced by SubalbumWidget().
00780 { 00781 photos->selectAll(false); 00782 }
Photo * SubalbumWidget::getFirstSelectedPhoto | ( | ) |
Returns first selected photo.
Definition at line 612 of file subalbumWidget.cpp.
References photos.
Referenced by LayoutWidget::tabChanged().
00613 { 00614 //determine if one photo is selected 00615 QIconViewItem* current = photos->firstItem(); 00616 while(current != NULL) 00617 { 00618 //found a selected item! 00619 if(current->isSelected()) 00620 { return ((PhotoPreviewWidget*)current)->getPhoto(); } 00621 00622 //move to next item 00623 current = current->nextItem(); 00624 } 00625 00626 //no selected items found 00627 return NULL; 00628 }
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().
00686 { 00687 return photos; 00688 }
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().
00586 { 00587 //determine if one photo is selected 00588 int numSelected = 0; 00589 QIconViewItem* current = photos->firstItem(); 00590 QIconViewItem* selected = NULL; 00591 while(current != NULL) 00592 { 00593 //found a selected item! 00594 if(current->isSelected()) 00595 { 00596 numSelected++; 00597 selected = current; 00598 } 00599 00600 //if more than one found then bail! 00601 if(numSelected > 1) return NULL; 00602 00603 //move to next item 00604 current = current->nextItem(); 00605 } 00606 00607 //if one item is selected then return photo pointer 00608 if(numSelected == 1) { return ((PhotoPreviewWidget*)selected)->getPhoto(); } 00609 else { return NULL; } 00610 }
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().
00581 { 00582 return subalbum; 00583 }
void SubalbumWidget::refreshAllPhotos | ( | ) |
refreshes all photos, selections are preserved
Definition at line 535 of file subalbumWidget.cpp.
References photos.
Referenced by LayoutWidget::tabChanged().
00536 { 00537 QIconViewItem* current = photos->firstItem(); 00538 while(current != NULL) 00539 { 00540 ((PhotoPreviewWidget*)current)->updateImage(); 00541 ((PhotoPreviewWidget*)current)->updateDescription(); 00542 current = current->nextItem(); 00543 } 00544 }
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().
00517 { 00518 //remove all thumbnails 00519 photos->clear(); 00520 00521 if(subalbum != NULL) 00522 { 00523 //insert photo thumbnails 00524 Photo* currentPhoto = subalbum->getFirst(); 00525 while(currentPhoto != NULL) 00526 { 00527 new PhotoPreviewWidget( photos, currentPhoto ); 00528 currentPhoto = currentPhoto->getNext(); 00529 } 00530 00531 photos->arrangeItemsInGrid(); 00532 } 00533 }
void SubalbumWidget::refreshSelectedPhotos | ( | ) |
refreshes selected photos, selections are preserved
Definition at line 546 of file subalbumWidget.cpp.
References photos.
00547 { 00548 QIconViewItem* current = photos->firstItem(); 00549 while(current != NULL) 00550 { 00551 //found a selected item! 00552 if(current->isSelected()) 00553 { 00554 ((PhotoPreviewWidget*)current)->updateImage(); 00555 ((PhotoPreviewWidget*)current)->updateDescription(); 00556 } 00557 00558 //move to next item 00559 current = current->nextItem(); 00560 } 00561 }
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, updateButtons(), and SubalbumsWidget::updateButtons().
Referenced by SubalbumWidget().
00318 { 00319 //set busy flag and deactivate menu's/buttons 00320 layout->getWindow()->getTitle()->setBusy(true); 00321 layout->getSubalbums()->updateButtons(false); 00322 updateButtons(false); 00323 photos->setSelectionMode( QIconView::NoSelection ) ; 00324 00325 //if user has chosen to not receive destructive action warnings, or agrees to the action, then 00326 //delete photo and refresh view 00327 bool proceed = !((Window*)qApp->mainWidget())->getConfig()->getBool( "alerts", "showDestructiveAlerts" ); 00328 if(!proceed) 00329 { 00330 QuestionDialog sure( tr("Remove selected photos?"), 00331 tr("Once removed photos cannot be restored. Furthermore upon resaving they are physically removed from your album."), 00332 "alertIcons/warning.png", 00333 this ); 00334 proceed = sure.exec(); 00335 } 00336 if(proceed) 00337 { 00338 qApp->setOverrideCursor( QCursor(Qt::WaitCursor)); 00339 //iterate through all photos and remove those that are selected 00340 QIconViewItem* current = photos->firstItem(); 00341 QIconViewItem* temp; 00342 00343 while(current != NULL) 00344 { 00345 //if not selected move on 00346 if(!current->isSelected()) 00347 { 00348 current = current->nextItem(); 00349 continue; 00350 } 00351 00352 //get next pointer 00353 temp = current->nextItem(); 00354 00355 //grab point to backend photo 00356 Photo* phto = ((PhotoPreviewWidget*)current)->getPhoto(); 00357 00358 //delete photo widget 00359 delete current; 00360 current = temp; 00361 00362 //delete backend photo 00363 subalbum->removePhoto(phto); 00364 } 00365 00366 //cleanup arrangement in case items were deleted in the middle or front 00367 photos->arrangeItemsInGrid(); 00368 00369 //unset busy flag and activate menu's/buttons 00370 qApp->restoreOverrideCursor(); 00371 } 00372 00373 layout->getWindow()->getTitle()->setBusy(false); 00374 layout->getSubalbums()->updateButtons(true); 00375 updateButtons(true); 00376 photos->setSelectionMode( QIconView::Extended ) ; 00377 00378 //update buttons and emit selection changed signal 00379 selectionChangedEvent(); 00380 }
void SubalbumWidget::reorder | ( | ) | [private, slot] |
Definition at line 690 of file subalbumWidget.cpp.
References photos, subalbum, and Subalbum::syncPhotoList().
Referenced by SubalbumWidget().
00691 { 00692 //so item has been moved, reorder linked list of items as necessary 00693 photos->sort( true ); 00694 photos->arrangeItemsInGrid(); 00695 00696 //sync lists 00697 subalbum->syncPhotoList((PhotoPreviewWidget*)photos->firstItem()); 00698 }
void SubalbumWidget::resizeEvent | ( | QResizeEvent * | ) | [protected] |
Definition at line 680 of file subalbumWidget.cpp.
References photos.
00681 { 00682 photos->arrangeItemsInGrid(); 00683 }
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().
00383 { 00384 //iterate over photos in current collection 00385 QIconViewItem* current = photos->firstItem(); 00386 while(current != NULL) 00387 { 00388 //found a selected item! 00389 if(current->isSelected()) 00390 { 00391 ((PhotoPreviewWidget*)current)->getPhoto()->revertPhoto(); 00392 photos->ensureItemVisible(((PhotoPreviewWidget*)current)); 00393 ((PhotoPreviewWidget*)current)->updateImage(); 00394 qApp->processEvents(); 00395 } 00396 00397 //move to next item 00398 current = current->nextItem(); 00399 } 00400 00401 //state of selected photos has changed 00402 emit selectedPhotoStateChanged(); 00403 }
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(), updateButtons(), SubalbumsWidget::updateButtons(), and StatusWidget::updateProgress().
Referenced by SubalbumWidget().
00467 { 00468 //set busy flag and deactivate menu's/buttons 00469 qApp->setOverrideCursor( QCursor(Qt::WaitCursor)); 00470 layout->getWindow()->getTitle()->setBusy(true); 00471 layout->getSubalbums()->updateButtons(false); 00472 photos->setSelectionMode( QIconView::NoSelection ) ; 00473 updateButtons(false); 00474 00475 //setup progress bar 00476 QString statusMessage = tr("Rotating %1 photos:"); 00477 layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(photos->numSelected()), photos->numSelected() ); 00478 qApp->processEvents(); 00479 00480 //rotate the selected photos 00481 int num = 0; 00482 QIconViewItem* current = photos->firstItem(); 00483 while(current != NULL) 00484 { 00485 if(current->isSelected()) 00486 { 00487 //update status message 00488 layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(photos->numSelected() - num) ); 00489 00490 ((PhotoPreviewWidget*)current)->getPhoto()->rotate270(); 00491 photos->ensureItemVisible(((PhotoPreviewWidget*)current)); 00492 ((PhotoPreviewWidget*)current)->updateImage(); 00493 num++; 00494 layout->getWindow()->getStatus()->updateProgress( num ); 00495 qApp->processEvents(); 00496 } 00497 00498 //move to next item 00499 current = current->nextItem(); 00500 } 00501 00502 //state of selected photos has changed 00503 emit selectedPhotoStateChanged(); 00504 00505 //hide progress bar 00506 layout->getWindow()->getStatus()->setStatus( tr("Rotating complete.") ); 00507 00508 //not busy any more 00509 layout->getWindow()->getTitle()->setBusy(false); 00510 layout->getSubalbums()->updateButtons(true); 00511 updateButtons(true); 00512 photos->setSelectionMode( QIconView::Extended ) ; 00513 qApp->restoreOverrideCursor(); 00514 }
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(), updateButtons(), SubalbumsWidget::updateButtons(), and StatusWidget::updateProgress().
Referenced by SubalbumWidget().
00416 { 00417 //set busy flag and deactivate menu's/buttons 00418 qApp->setOverrideCursor( QCursor(Qt::WaitCursor)); 00419 layout->getWindow()->getTitle()->setBusy(true); 00420 layout->getSubalbums()->updateButtons(false); 00421 photos->setSelectionMode( QIconView::NoSelection ) ; 00422 updateButtons(false); 00423 00424 //setup progress bar 00425 QString statusMessage = tr("Rotating %1 photos:"); 00426 layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(photos->numSelected()), photos->numSelected() ); 00427 qApp->processEvents(); 00428 00429 //rotate the selected photos 00430 int num = 0; 00431 QIconViewItem* current = photos->firstItem(); 00432 while(current != NULL) 00433 { 00434 if(current->isSelected()) 00435 { 00436 //update status message 00437 layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(photos->numSelected() - num) ); 00438 00439 ((PhotoPreviewWidget*)current)->getPhoto()->rotate90(); 00440 photos->ensureItemVisible(((PhotoPreviewWidget*)current)); 00441 ((PhotoPreviewWidget*)current)->updateImage(); 00442 num++; 00443 layout->getWindow()->getStatus()->updateProgress( num ); 00444 qApp->processEvents(); 00445 } 00446 00447 //move to next item 00448 current = current->nextItem(); 00449 } 00450 00451 //state of selected photos has changed 00452 emit selectedPhotoStateChanged(); 00453 00454 //hide progress bar 00455 layout->getWindow()->getStatus()->setStatus( tr("Rotating complete.") ); 00456 00457 //not busy any more 00458 layout->getWindow()->getTitle()->setBusy(false); 00459 layout->getSubalbums()->updateButtons(true); 00460 updateButtons(true); 00461 photos->setSelectionMode( QIconView::Extended ) ; 00462 00463 qApp->restoreOverrideCursor(); 00464 }
void SubalbumWidget::selectedPhotoStateChanged | ( | ) | [signal] |
Referenced by revertSelectedPhotos(), rotate270ImageAction(), rotate90ImageAction(), and selectionChangedEvent().
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().
00701 { 00702 //update rotate/add/remove buttons depending on whether or not any items are selected 00703 updateButtons(); 00704 00705 //emit selection changed signal so other menu's etc an be updated as well 00706 emit selectedPhotoStateChanged(); 00707 }
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().
00631 { 00632 //select specified photo 00633 QIconViewItem* current = photos->firstItem(); 00634 while(current != NULL) 00635 { 00636 if( ((PhotoPreviewWidget*)current)->getPhoto() == selection ) 00637 { 00638 //deselect all 00639 photos->selectAll(false); 00640 00641 //select photo and make sure it is visible 00642 current->setSelected(true); 00643 photos->ensureItemVisible( current ); 00644 00645 return; 00646 } 00647 00648 //move on to next photo 00649 current = current->nextItem(); 00650 } 00651 }
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().
00220 { 00221 //set new subalbum pointer 00222 subalbum = salbum; 00223 00224 //update photo listing 00225 refreshPhotos(); 00226 00227 if(subalbum == NULL) { buttonsFrame->hide(); } 00228 else 00229 { 00230 //disable/enable buttons as necessary 00231 buttonsFrame->show(); 00232 selectionChangedEvent(); 00233 } 00234 }
void SubalbumWidget::setWallpaperAction | ( | ) | [private, slot] |
set desktop wallpaper
Definition at line 405 of file subalbumWidget.cpp.
References getSelectedPhoto(), and setWallpaper().
Referenced by SubalbumWidget().
00406 { 00407 //get first selected photo, if no photo is selected then bail 00408 Photo* phto = getSelectedPhoto(); 00409 if(phto == NULL) return; 00410 00411 //set the wallpaper 00412 setWallpaper( phto ); 00413 }
void SubalbumWidget::stripDescriptionsFromSelectedPhotos | ( | ) |
Strip descriptions from selected photos.
Definition at line 563 of file subalbumWidget.cpp.
References photos.
Referenced by TitleWidget::removeSelectedPhotoDesc().
00564 { 00565 QIconViewItem* current = photos->firstItem(); 00566 while(current != NULL) 00567 { 00568 //found a selected item! 00569 if(current->isSelected()) 00570 { 00571 ((PhotoPreviewWidget*)current)->getPhoto()->setDescription(""); 00572 ((PhotoPreviewWidget*)current)->setText( "" ); 00573 } 00574 00575 //move to next item 00576 current = current->nextItem(); 00577 } 00578 }
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().
00710 { 00711 int numSelected = 0; 00712 QIconViewItem* current = photos->firstItem(); 00713 while(current != NULL) 00714 { 00715 if(current->isSelected()) 00716 { 00717 numSelected++; 00718 00719 //there are effectively 3 states: 00720 //1) no items selected -> disable all buttons besides addPhoto 00721 //2) one itme selected -> enable all button, including set desktop wallpaper button 00722 //3) more than one item selected -> enable all but edit button (since we don't know which photo to edit) 00723 //thus once 2 selected photos are found we know we are in the multi select mode and can terminate the search 00724 if(numSelected > 1) 00725 break; 00726 } 00727 00728 //move to next item 00729 current = current->nextItem(); 00730 } 00731 00732 if(numSelected == 0) 00733 { 00734 removeImage->setEnabled(false); 00735 rotate90Image->setEnabled(false); 00736 rotate270Image->setEnabled(false); 00737 if(setDesktopBtn) { setDesktopBtn->setEnabled(false); } 00738 layout->setEditTabEnabled(false); 00739 } 00740 else 00741 { 00742 removeImage->setEnabled(true); 00743 rotate90Image->setEnabled(true); 00744 rotate270Image->setEnabled(true); 00745 if(setDesktopBtn) { setDesktopBtn->setEnabled(true); } 00746 layout->setEditTabEnabled(true); 00747 } 00748 00749 if(setDesktopBtn) { setDesktopBtn->setEnabled( numSelected == 1 ); } 00750 }
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().
00753 { 00754 if(!enable) 00755 { 00756 buttonsState = rotate90Image->isEnabled(); 00757 addImage->setEnabled(enable && true); 00758 removeImage->setEnabled(enable && true); 00759 rotate90Image->setEnabled(enable); 00760 rotate270Image->setEnabled(enable); 00761 if(setDesktopBtn) 00762 { 00763 wallpaperButtonState = setDesktopBtn->isEnabled(); 00764 setDesktopBtn->setEnabled(enable); 00765 } 00766 layout->setEditTabEnabled(enable); 00767 } 00768 else 00769 { 00770 addImage->setEnabled(enable && true); 00771 removeImage->setEnabled(buttonsState && true); 00772 rotate90Image->setEnabled(buttonsState); 00773 rotate270Image->setEnabled(buttonsState); 00774 if(setDesktopBtn) { setDesktopBtn->setEnabled(wallpaperButtonState); } 00775 layout->setEditTabEnabled(buttonsState); 00776 } 00777 }
QToolButton* SubalbumWidget::addImage [private] |
"Add" button
Definition at line 140 of file subalbumWidget.h.
Referenced by SubalbumWidget(), and updateButtons().
QFrame* SubalbumWidget::buttonsFrame [private] |
QGridLayout* SubalbumWidget::buttonsGrid [private] |
bool SubalbumWidget::buttonsState [private] |
cached enabled/disabled state of buttons
Definition at line 158 of file subalbumWidget.h.
Referenced by updateButtons().
LayoutWidget* SubalbumWidget::layout [private] |
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().
PhotosIconView* SubalbumWidget::photos [private] |
Photos layout.
Definition at line 134 of file subalbumWidget.h.
Referenced by addImageAction(), anyPhotosSelected(), anySelectedPhotosRevertable(), deselectAll(), getFirstSelectedPhoto(), getPhotos(), getSelectedPhoto(), refreshAllPhotos(), refreshPhotos(), refreshSelectedPhotos(), removeImageAction(), reorder(), resizeEvent(), revertSelectedPhotos(), rotate270ImageAction(), rotate90ImageAction(), setSelectedPhoto(), stripDescriptionsFromSelectedPhotos(), SubalbumWidget(), and updateButtons().
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().
Subalbum* SubalbumWidget::subalbum [private] |
Pointer to backend subalbum.
Definition at line 137 of file subalbumWidget.h.
Referenced by addImageAction(), getSubalbum(), refreshPhotos(), removeImageAction(), reorder(), setSubalbum(), and SubalbumWidget().
QFrame* SubalbumWidget::thumbnailFrame [private] |
bool SubalbumWidget::wallpaperButtonState [private] |
cached enabled/distable state of set wallpaper button
Definition at line 161 of file subalbumWidget.h.
Referenced by updateButtons().