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

SubalbumsWidget Class Reference

#include <subalbumsWidget.h>

Inheritance diagram for SubalbumsWidget:

[legend]
Collaboration diagram for SubalbumsWidget:
[legend]
List of all members.

Detailed Description

Columnview of all subalbums in album.

Definition at line 29 of file subalbumsWidget.h.

Public Slots

void updatedSelectedCollectionImage (QPixmap *val)
void refreshSelectedCollectionName ()

Signals

void collectionSelected (Subalbum *)

Public Member Functions

 SubalbumsWidget (QWidget *parent=0, const char *name=0)
 Creates layout.

void refreshCollectionsList ()
 Refreshes list of collections, selecting first by default.

LayoutWidgetgetParent ()
 Returns parent.

void updateButtons (bool enable)
 Activates/Deactives create/delete buttons.

QIconViewItemgetCurrentSelection ()
 Returns current selection.

SubalbumgetSelectedSubalbum ()
 Returns the currently selected subalbum.


Private Slots

void createAction ()
 create a new collection

void deleteAction ()
 deletes the currently selected collection

void handleSelectionAttempt (QIconViewItem *item)
 respond to user clicking collection icons

void reorder ()
 relayout collectionicons after a create/delete refresh


Private Member Functions

void selectFirstCollection ()
 select first collection

void selectCollection (QIconViewItem *item)
 select specified collection


Private Attributes

SubalbumsIconViewcollections
 list of subalbums

QIconViewItemcurrentSelection
QToolButton * createButton
 Create collection button.

QToolButton * deleteButton
 Delete collection button.

LayoutWidgetlayout
 Pointer to layoutwidget this widget is in.

bool buttonsState
 Cached enabled/disabled state of buttons.


Constructor & Destructor Documentation

SubalbumsWidget::SubalbumsWidget QWidget parent = 0,
const char *  name = 0
 

Creates layout.

Definition at line 36 of file subalbumsWidget.cpp.

References collections, createAction(), createButton, currentSelection, deleteAction(), deleteButton, handleSelectionAttempt(), IMAGE_PATH, layout, reorder(), and SubalbumsWidget().

Referenced by SubalbumsWidget().

00037 : 00038 QWidget(parent,name) 00039 { 00040 //set layout pointer 00041 layout = (LayoutWidget*)parent; 00042 00043 //create "Collections:" header 00044 QLabel* collectionsHeader = new QLabel( this ); 00045 collectionsHeader->setText( tr("Collections:") ); 00046 QFont labelFont = collectionsHeader->font(); 00047 labelFont.setWeight(QFont::Bold); 00048 collectionsHeader->setFont( labelFont ); 00049 //-------------------------------------- 00050 //create collections list 00051 collections = new SubalbumsIconView( this ); 00052 00053 //only one item can be selected at a time 00054 collections->setSelectionMode( QIconView::Single ) ; 00055 00056 //single column of items 00057 collections->setGridX(1); 00058 00059 //text is on right of icons 00060 collections->setItemTextPos( QIconView::Right ); 00061 00062 //disable frame 00063 collections->setFrameShape ( QFrame::NoFrame ); 00064 00065 collections->setMaxItemWidth(500); 00066 collections->setPaletteBackgroundColor( QColor(193, 210, 238) ); 00067 collections->setDragAutoScroll(true); 00068 collections->setAcceptDrops(true); 00069 collections->setVScrollBarMode( QScrollView::Auto ); 00070 collections->setHScrollBarMode( QScrollView::Auto ); 00071 //-------------------------------------- 00072 //no selection by default 00073 currentSelection = NULL; 00074 //-------------------------------------- 00075 //connect drop event on iconview to reorder slot 00076 connect( collections, SIGNAL(itemHasMoved()), SLOT(reorder()) ); 00077 00078 //handle selection attempts 00079 connect( collections, SIGNAL(selectionChanged(QIconViewItem*)), 00080 this, SLOT(handleSelectionAttempt(QIconViewItem*))); 00081 //-------------------------------------- 00082 //create create/delete buttons 00083 QFont buttonFont( qApp->font() ); 00084 buttonFont.setBold(true); 00085 buttonFont.setPointSize( 11 ); 00086 00087 createButton = new QToolButton( this ); 00088 createButton->setTextLabel(tr("Create")); 00089 createButton->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/create.png") ); 00090 createButton->setTextPosition(QToolButton::Right); 00091 createButton->setFont( buttonFont ); 00092 createButton->setUsesTextLabel( true ); 00093 createButton->setEnabled(true); 00094 createButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); 00095 QToolTip::add( createButton, tr("Create a collection and append to subalbum list") ); 00096 connect( createButton, SIGNAL(clicked()), SLOT(createAction()) ); 00097 00098 deleteButton = new QToolButton( this ); 00099 deleteButton->setTextLabel(tr("Delete")); 00100 deleteButton->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/delete.png") ); 00101 deleteButton->setTextPosition(QToolButton::Right); 00102 deleteButton->setFont( buttonFont ); 00103 deleteButton->setUsesTextLabel( true ); 00104 deleteButton->setEnabled(false); 00105 deleteButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); 00106 QToolTip::add( deleteButton, tr("Delete selected collection and all its contents") ); 00107 connect( deleteButton, SIGNAL(clicked()), SLOT(deleteAction()) ); 00108 //-------------------------------------- 00109 //place label, listbox, and buttons in grid 00110 QGridLayout* grid = new QGridLayout( this, 3, 2, 0 ); 00111 grid->addMultiCellWidget( collectionsHeader, 0, 0, 0, 1, Qt::AlignHCenter ); 00112 grid->addMultiCellWidget( collections, 1, 1, 0, 1 ); 00113 grid->addWidget( createButton, 2, 0, Qt::AlignHCenter); 00114 grid->addWidget( deleteButton, 2, 1, Qt::AlignHCenter); 00115 00116 //allow collections listing to grow 00117 grid->setRowStretch( 1, 1 ); 00118 00119 //set the background of the widget to be white 00120 setPaletteBackgroundColor( QColor(193, 210, 238) ); 00121 } //==============================================


Member Function Documentation

void SubalbumsWidget::collectionSelected Subalbum  )  [signal]
 

Referenced by selectCollection().

void SubalbumsWidget::createAction  )  [private, slot]
 

create a new collection

Definition at line 123 of file subalbumsWidget.cpp.

References Album::appendSubalbum(), collections, deleteButton, TitleWidget::getAlbum(), Album::getNumSubalbums(), Window::getTitle(), LayoutWidget::getWindow(), layout, and selectCollection().

Referenced by SubalbumsWidget().

00124 { 00125 //create new collection object 00126 Album* albm = layout->getWindow()->getTitle()->getAlbum(); 00127 Subalbum* newCollection = new Subalbum( albm, albm->getNumSubalbums()+1 ); 00128 albm->appendSubalbum( newCollection ); 00129 00130 //create collection icon and auto select it 00131 SubalbumPreviewWidget* newCollectionIcon = new SubalbumPreviewWidget( collections, newCollection ); 00132 newCollectionIcon->setDropEnabled(true); 00133 selectCollection( newCollectionIcon ); 00134 00135 //update enabled state of delete collection button 00136 deleteButton->setEnabled( collections->count() > 1 ); 00137 }

void SubalbumsWidget::deleteAction  )  [private, slot]
 

deletes the currently selected collection

Definition at line 139 of file subalbumsWidget.cpp.

References collections, deleteButton, TitleWidget::getAlbum(), Window::getTitle(), LayoutWidget::getWindow(), layout, Album::removeSubalbum(), selectCollection(), and TitleWidget::updateMenus().

Referenced by SubalbumsWidget().

00140 { 00141 //if an item is selected it remove it 00142 if(collections->currentItem() != NULL) 00143 { 00144 //if user has chosen to not receive destructive action warnings, or agrees to the action, then 00145 //delete subalbum and refresh view 00146 bool proceed = !((Window*)qApp->mainWidget())->getConfig()->getBool( "alerts", "showDestructiveAlerts" ); 00147 if(!proceed) 00148 { 00149 QuestionDialog sure( tr("Delete collection?"), 00150 tr("Once deleted a collection and it's contents cannot be brought back unless a saved copy of the album exists."), 00151 "alertIcons/warning.png", 00152 this ); 00153 proceed = sure.exec(); 00154 } 00155 if(proceed) 00156 { 00157 //get handle on currently selected collection 00158 QIconViewItem* oldSelection = collections->currentItem(); 00159 00160 //get handle on the next automatically selected collection 00161 //auto select the new collection. If there is no next 00162 //collection, select the previous collection (again if present) 00163 QIconViewItem* newSelection = oldSelection->nextItem(); 00164 if(newSelection == NULL) newSelection = oldSelection->prevItem(); 00165 00166 //auto select a remaining collection if one exists 00167 //we select before removing and deleting the old collection so that 00168 //the collection information above smoothly transitions 00169 selectCollection( newSelection ); 00170 00171 //remove the collection from the album 00172 Subalbum* s = ((SubalbumPreviewWidget*) oldSelection)->getSubalbum(); 00173 layout->getWindow()->getTitle()->getAlbum()->removeSubalbum( s ); 00174 00175 //free the collection icon 00176 delete oldSelection; 00177 oldSelection = NULL; 00178 00179 //rearrange the items in the grid, making 00180 //sure new selection is visible 00181 collections->arrangeItemsInGrid(); 00182 if(newSelection != NULL) collections->ensureItemVisible( newSelection ); 00183 00184 //update enabled state of delete collection button 00185 deleteButton->setEnabled( collections->count() > 1 ); 00186 00187 //notifty title widget that the album's photo count has possible changed 00188 layout->getWindow()->getTitle()->updateMenus(); 00189 } 00190 } 00191 }

QIconViewItem * SubalbumsWidget::getCurrentSelection  ) 
 

Returns current selection.

Definition at line 232 of file subalbumsWidget.cpp.

References currentSelection.

Referenced by TitleWidget::setSubalbumImage(), and TitleWidget::unsetSubalbumImage().

00232 { return currentSelection; }

LayoutWidget * SubalbumsWidget::getParent  ) 
 

Returns parent.

Definition at line 231 of file subalbumsWidget.cpp.

References layout.

00231 { return layout; }

Subalbum * SubalbumsWidget::getSelectedSubalbum  ) 
 

Returns the currently selected subalbum.

Definition at line 234 of file subalbumsWidget.cpp.

References currentSelection.

Referenced by TitleWidget::storeAnnotations().

00235 { 00236 return ((SubalbumPreviewWidget*) currentSelection )->getSubalbum(); 00237 }

void SubalbumsWidget::handleSelectionAttempt QIconViewItem item  )  [private, slot]
 

respond to user clicking collection icons

Definition at line 273 of file subalbumsWidget.cpp.

References TitleWidget::getBusy(), Window::getTitle(), LayoutWidget::getWindow(), handleSelectionAttempt(), layout, and selectCollection().

Referenced by handleSelectionAttempt(), and SubalbumsWidget().

00274 { 00275 //select collections only when program is not busy. 00276 if( !layout->getWindow()->getTitle()->getBusy() ) 00277 selectCollection( item ); 00278 }

void SubalbumsWidget::refreshCollectionsList  ) 
 

Refreshes list of collections, selecting first by default.

Definition at line 239 of file subalbumsWidget.cpp.

References collections, currentSelection, TitleWidget::getAlbum(), Album::getFirstSubalbum(), Subalbum::getNext(), Window::getTitle(), LayoutWidget::getWindow(), layout, and selectFirstCollection().

Referenced by LayoutWidget::refresh().

00240 { 00241 //delete all previous entries 00242 QIconViewItem* current = collections->firstItem(); 00243 while(current != NULL) 00244 { 00245 QIconViewItem* next = current->nextItem(); 00246 delete current; 00247 current = next; 00248 } 00249 00250 //for some reason scrollbar does not disappear automatically. 00251 //Calling clear fixes this. 00252 collections->clear(); 00253 00254 //reset cached selection handle 00255 currentSelection = NULL; 00256 00257 //insert all collections 00258 Subalbum* curCollection = layout->getWindow()->getTitle()->getAlbum()->getFirstSubalbum(); 00259 while( curCollection != NULL) 00260 { 00261 SubalbumPreviewWidget* item = new SubalbumPreviewWidget( collections, curCollection ); 00262 item->setDropEnabled(true); 00263 curCollection = curCollection->getNext(); 00264 } 00265 00266 //refresh iconview 00267 collections->arrangeItemsInGrid(); 00268 00269 //auto select first item 00270 selectFirstCollection(); 00271 }

void SubalbumsWidget::refreshSelectedCollectionName  )  [slot]
 

Definition at line 193 of file subalbumsWidget.cpp.

References currentSelection.

Referenced by LayoutWidget::refreshSelectedCollectionIconName().

00194 { 00195 if( currentSelection != NULL) 00196 currentSelection->setText( ((SubalbumPreviewWidget*)currentSelection)->getSubalbum()->getName() ); 00197 }

void SubalbumsWidget::reorder  )  [private, slot]
 

relayout collectionicons after a create/delete refresh

Definition at line 205 of file subalbumsWidget.cpp.

References collections, TitleWidget::getAlbum(), Window::getTitle(), LayoutWidget::getWindow(), layout, and Album::syncSubalbumList().

Referenced by SubalbumsWidget().

00206 { 00207 //so item has been moved, reorder linked list of items as necessary 00208 collections->sort( true ); 00209 collections->arrangeItemsInGrid(); 00210 00211 //sync lists 00212 Album* albm = layout->getWindow()->getTitle()->getAlbum(); 00213 albm->syncSubalbumList((SubalbumPreviewWidget*)collections->firstItem()); 00214 }

void SubalbumsWidget::selectCollection QIconViewItem item  )  [private]
 

select specified collection

Definition at line 285 of file subalbumsWidget.cpp.

References collections, collectionSelected(), currentSelection, and selectCollection().

Referenced by createAction(), deleteAction(), handleSelectionAttempt(), selectCollection(), and selectFirstCollection().

00286 { 00287 //no necessary action when selecting the currently selection collection 00288 if(currentSelection == item) return; 00289 00290 //select item 00291 if( item != NULL ) collections->setSelected( item, true); 00292 00293 //cachce selection 00294 currentSelection = item; 00295 00296 //emit signal that a different collection has been selected 00297 if(currentSelection == NULL ) 00298 emit collectionSelected( NULL ); 00299 else 00300 emit collectionSelected( ((SubalbumPreviewWidget*)currentSelection)->getSubalbum() ); 00301 }

void SubalbumsWidget::selectFirstCollection  )  [private]
 

select first collection

Definition at line 280 of file subalbumsWidget.cpp.

References collections, and selectCollection().

Referenced by refreshCollectionsList().

00281 { 00282 selectCollection( collections->firstItem() ); 00283 }

void SubalbumsWidget::updateButtons bool  enable  ) 
 

Activates/Deactives create/delete buttons.

Definition at line 216 of file subalbumsWidget.cpp.

References buttonsState, createButton, deleteButton, and updateButtons().

Referenced by SubalbumWidget::addImageAction(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), SubalbumWidget::removeImageAction(), SubalbumWidget::rotate270ImageAction(), SubalbumWidget::rotate90ImageAction(), TitleWidget::saveAlbum(), TitleWidget::saveAsAlbum(), and updateButtons().

00217 { 00218 if(enable) 00219 { 00220 createButton->setEnabled( true ); 00221 deleteButton->setEnabled( buttonsState ); 00222 } 00223 else 00224 { 00225 buttonsState = createButton->isEnabled(); 00226 createButton->setEnabled( false ); 00227 deleteButton->setEnabled( false ); 00228 } 00229 }

void SubalbumsWidget::updatedSelectedCollectionImage QPixmap *  val  )  [slot]
 

Definition at line 199 of file subalbumsWidget.cpp.

References currentSelection, and updatedSelectedCollectionImage().

Referenced by updatedSelectedCollectionImage(), and LayoutWidget::updateSubalbumImage().

00200 { 00201 if( currentSelection != NULL) 00202 currentSelection->setPixmap( *val ); 00203 }


Member Data Documentation

bool SubalbumsWidget::buttonsState [private]
 

Cached enabled/disabled state of buttons.

Definition at line 78 of file subalbumsWidget.h.

Referenced by updateButtons().

SubalbumsIconView* SubalbumsWidget::collections [private]
 

list of subalbums

Definition at line 63 of file subalbumsWidget.h.

Referenced by createAction(), deleteAction(), refreshCollectionsList(), reorder(), selectCollection(), selectFirstCollection(), and SubalbumsWidget().

QToolButton* SubalbumsWidget::createButton [private]
 

Create collection button.

Definition at line 69 of file subalbumsWidget.h.

Referenced by SubalbumsWidget(), and updateButtons().

QIconViewItem* SubalbumsWidget::currentSelection [private]
 

Definition at line 66 of file subalbumsWidget.h.

Referenced by getCurrentSelection(), getSelectedSubalbum(), refreshCollectionsList(), refreshSelectedCollectionName(), selectCollection(), SubalbumsWidget(), and updatedSelectedCollectionImage().

QToolButton* SubalbumsWidget::deleteButton [private]
 

Delete collection button.

Definition at line 72 of file subalbumsWidget.h.

Referenced by createAction(), deleteAction(), SubalbumsWidget(), and updateButtons().

LayoutWidget* SubalbumsWidget::layout [private]
 

Pointer to layoutwidget this widget is in.

Definition at line 75 of file subalbumsWidget.h.

Referenced by createAction(), deleteAction(), getParent(), handleSelectionAttempt(), refreshCollectionsList(), reorder(), and SubalbumsWidget().


The documentation for this class was generated from the following files:
Generated on Sun Mar 4 19:43:09 2007 for AlbumShaper by doxygen 1.3.7