AlbumShaper
1.0a3
|
Columnview of all subalbums in album. More...
#include <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. | |
LayoutWidget * | getParent () |
Returns parent. | |
void | updateButtons (bool enable) |
Activates/Deactives create/delete buttons. | |
QIconViewItem * | getCurrentSelection () |
Returns current selection. | |
Subalbum * | getSelectedSubalbum () |
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 specified subalbum. | |
void | selectCollection (QIconViewItem *item) |
select specified collection | |
Private Attributes | |
SubalbumsIconView * | collections |
list of subalbums | |
QIconViewItem * | currentSelection |
QToolButton * | createButton |
Create collection button. | |
QToolButton * | deleteButton |
Delete collection button. | |
LayoutWidget * | layout |
Pointer to layoutwidget this widget is in. | |
bool | buttonsState |
Cached enabled/disabled state of buttons. |
Columnview of all subalbums in album.
Definition at line 29 of file subalbumsWidget.h.
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, and reorder().
: QWidget(parent,name) { //set layout pointer layout = (LayoutWidget*)parent; //create "Collections:" header QLabel* collectionsHeader = new QLabel( this ); collectionsHeader->setText( tr("Collections:") ); QFont labelFont = collectionsHeader->font(); labelFont.setWeight(QFont::Bold); collectionsHeader->setFont( labelFont ); //-------------------------------------- //create collections list collections = new SubalbumsIconView( this ); //only one item can be selected at a time collections->setSelectionMode( QIconView::Single ) ; //single column of items collections->setGridX(1); //text is on right of icons collections->setItemTextPos( QIconView::Right ); //disable frame collections->setFrameShape ( QFrame::NoFrame ); collections->setMaxItemWidth(500); collections->setPaletteBackgroundColor( QColor(193, 210, 238) ); collections->setDragAutoScroll(true); collections->setAcceptDrops(true); collections->setVScrollBarMode( QScrollView::Auto ); collections->setHScrollBarMode( QScrollView::Auto ); //-------------------------------------- //no selection by default currentSelection = NULL; //-------------------------------------- //connect drop event on iconview to reorder slot connect( collections, SIGNAL(itemHasMoved()), SLOT(reorder()) ); //handle selection attempts connect( collections, SIGNAL(selectionChanged(QIconViewItem*)), this, SLOT(handleSelectionAttempt(QIconViewItem*))); //-------------------------------------- //create create/delete buttons QFont buttonFont( qApp->font() ); buttonFont.setBold(true); buttonFont.setPointSize( 11 ); createButton = new QToolButton( this ); createButton->setTextLabel(tr("Create")); createButton->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/create.png") ); createButton->setTextPosition(QToolButton::Right); createButton->setFont( buttonFont ); createButton->setUsesTextLabel( true ); createButton->setEnabled(true); createButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); QToolTip::add( createButton, tr("Create a collection and append to subalbum list") ); connect( createButton, SIGNAL(clicked()), SLOT(createAction()) ); deleteButton = new QToolButton( this ); deleteButton->setTextLabel(tr("Delete")); deleteButton->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/delete.png") ); deleteButton->setTextPosition(QToolButton::Right); deleteButton->setFont( buttonFont ); deleteButton->setUsesTextLabel( true ); deleteButton->setEnabled(false); deleteButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); QToolTip::add( deleteButton, tr("Delete selected collection and all its contents") ); connect( deleteButton, SIGNAL(clicked()), SLOT(deleteAction()) ); //-------------------------------------- //place label, listbox, and buttons in grid QGridLayout* grid = new QGridLayout( this, 3, 2, 0 ); grid->addMultiCellWidget( collectionsHeader, 0, 0, 0, 1, Qt::AlignHCenter ); grid->addMultiCellWidget( collections, 1, 1, 0, 1 ); grid->addWidget( createButton, 2, 0, Qt::AlignHCenter); grid->addWidget( deleteButton, 2, 1, Qt::AlignHCenter); //allow collections listing to grow grid->setRowStretch( 1, 1 ); //set the background of the widget to be white setPaletteBackgroundColor( QColor(193, 210, 238) ); }
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().
{ //create new collection object Album* albm = layout->getWindow()->getTitle()->getAlbum(); Subalbum* newCollection = new Subalbum( albm, albm->getNumSubalbums()+1 ); albm->appendSubalbum( newCollection ); //create collection icon and auto select it SubalbumPreviewWidget* newCollectionIcon = new SubalbumPreviewWidget( collections, newCollection ); newCollectionIcon->setDropEnabled(true); selectCollection( newCollectionIcon ); //update enabled state of delete collection button deleteButton->setEnabled( collections->count() > 1 ); }
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().
{ //if an item is selected it remove it if(collections->currentItem() != NULL) { //if user has chosen to not receive destructive action warnings, or agrees to the action, then //delete subalbum and refresh view bool proceed = !((Window*)qApp->mainWidget())->getConfig()->getBool( "alerts", "showDestructiveAlerts" ); if(!proceed) { QuestionDialog sure( tr("Delete collection?"), tr("Once deleted a collection and it's contents cannot be brought back unless a saved copy of the album exists."), "alertIcons/warning.png", this ); proceed = sure.exec(); } if(proceed) { //get handle on currently selected collection QIconViewItem* oldSelection = collections->currentItem(); //get handle on the next automatically selected collection //auto select the new collection. If there is no next //collection, select the previous collection (again if present) QIconViewItem* newSelection = oldSelection->nextItem(); if(newSelection == NULL) newSelection = oldSelection->prevItem(); //auto select a remaining collection if one exists //we select before removing and deleting the old collection so that //the collection information above smoothly transitions selectCollection( newSelection ); //remove the collection from the album Subalbum* s = ((SubalbumPreviewWidget*) oldSelection)->getSubalbum(); layout->getWindow()->getTitle()->getAlbum()->removeSubalbum( s ); //free the collection icon delete oldSelection; oldSelection = NULL; //rearrange the items in the grid, making //sure new selection is visible collections->arrangeItemsInGrid(); if(newSelection != NULL) collections->ensureItemVisible( newSelection ); //update enabled state of delete collection button deleteButton->setEnabled( collections->count() > 1 ); //notifty title widget that the album's photo count has possible changed layout->getWindow()->getTitle()->updateMenus(); } } }
QIconViewItem * SubalbumsWidget::getCurrentSelection | ( | ) |
Returns current selection.
Definition at line 232 of file subalbumsWidget.cpp.
References currentSelection.
Referenced by TitleWidget::setSubalbumImage(), and TitleWidget::unsetSubalbumImage().
{ return currentSelection; }
LayoutWidget * SubalbumsWidget::getParent | ( | ) |
Returns parent.
Definition at line 231 of file subalbumsWidget.cpp.
References layout.
{ return layout; }
Subalbum * SubalbumsWidget::getSelectedSubalbum | ( | ) |
Returns the currently selected subalbum.
Definition at line 234 of file subalbumsWidget.cpp.
References currentSelection.
Referenced by TitleWidget::storeAnnotations().
{ return ((SubalbumPreviewWidget*) currentSelection )->getSubalbum(); }
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(), layout, and selectCollection().
Referenced by SubalbumsWidget().
{ //select collections only when program is not busy. if( !layout->getWindow()->getTitle()->getBusy() ) selectCollection( item ); }
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().
{ //delete all previous entries QIconViewItem* current = collections->firstItem(); while(current != NULL) { QIconViewItem* next = current->nextItem(); delete current; current = next; } //for some reason scrollbar does not disappear automatically. //Calling clear fixes this. collections->clear(); //reset cached selection handle currentSelection = NULL; //insert all collections Subalbum* curCollection = layout->getWindow()->getTitle()->getAlbum()->getFirstSubalbum(); while( curCollection != NULL) { SubalbumPreviewWidget* item = new SubalbumPreviewWidget( collections, curCollection ); item->setDropEnabled(true); curCollection = curCollection->getNext(); } //refresh iconview collections->arrangeItemsInGrid(); //auto select first item selectFirstCollection(); }
void SubalbumsWidget::refreshSelectedCollectionName | ( | ) | [slot] |
Definition at line 193 of file subalbumsWidget.cpp.
References currentSelection.
Referenced by LayoutWidget::refreshSelectedCollectionIconName().
{ if( currentSelection != NULL) currentSelection->setText( ((SubalbumPreviewWidget*)currentSelection)->getSubalbum()->getName() ); }
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().
{ //so item has been moved, reorder linked list of items as necessary collections->sort( true ); collections->arrangeItemsInGrid(); //sync lists Album* albm = layout->getWindow()->getTitle()->getAlbum(); albm->syncSubalbumList((SubalbumPreviewWidget*)collections->firstItem()); }
void SubalbumsWidget::selectCollection | ( | QIconViewItem * | item | ) | [private] |
select specified collection
Definition at line 285 of file subalbumsWidget.cpp.
References collections, collectionSelected(), and currentSelection.
Referenced by createAction(), deleteAction(), handleSelectionAttempt(), and selectFirstCollection().
{ //no necessary action when selecting the currently selection collection if(currentSelection == item) return; //select item if( item != NULL ) collections->setSelected( item, true); //cachce selection currentSelection = item; //emit signal that a different collection has been selected if(currentSelection == NULL ) emit collectionSelected( NULL ); else emit collectionSelected( ((SubalbumPreviewWidget*)currentSelection)->getSubalbum() ); }
void SubalbumsWidget::selectFirstCollection | ( | ) | [private] |
Select specified subalbum.
select first collection
Definition at line 280 of file subalbumsWidget.cpp.
References collections, and selectCollection().
Referenced by refreshCollectionsList().
{ selectCollection( collections->firstItem() ); }
void SubalbumsWidget::updateButtons | ( | bool | enable | ) |
Activates/Deactives create/delete buttons.
Definition at line 216 of file subalbumsWidget.cpp.
References buttonsState, createButton, and deleteButton.
Referenced by SubalbumWidget::addImageAction(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), TitleWidget::loadAlbum(), SubalbumWidget::removeImageAction(), SubalbumWidget::rotate270ImageAction(), SubalbumWidget::rotate90ImageAction(), TitleWidget::saveAlbum(), and TitleWidget::saveAsAlbum().
{ if(enable) { createButton->setEnabled( true ); deleteButton->setEnabled( buttonsState ); } else { buttonsState = createButton->isEnabled(); createButton->setEnabled( false ); deleteButton->setEnabled( false ); } }
void SubalbumsWidget::updatedSelectedCollectionImage | ( | QPixmap * | val | ) | [slot] |
Definition at line 199 of file subalbumsWidget.cpp.
References currentSelection.
Referenced by LayoutWidget::updateSubalbumImage().
{ if( currentSelection != NULL) currentSelection->setPixmap( *val ); }
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().