AlbumShaper 1.0a3
SubalbumsWidget Class Reference

Columnview of all subalbums in album. More...

#include <subalbumsWidget.h>

Inheritance diagram for SubalbumsWidget:
Collaboration diagram for SubalbumsWidget:

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.
 
Q3IconViewItemgetCurrentSelection ()
 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 (Q3IconViewItem *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 (Q3IconViewItem *item)
 select specified collection
 

Private Attributes

SubalbumsIconViewcollections
 list of subalbums
 
Q3IconViewItemcurrentSelection
 
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.
 

Detailed Description

Columnview of all subalbums in album.

Definition at line 31 of file subalbumsWidget.h.

Constructor & Destructor Documentation

◆ SubalbumsWidget()

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

Creates layout.

Definition at line 39 of file subalbumsWidget.cpp.

40 :
41 QWidget(parent,name)
42{
43 //set layout pointer
44 layout = (LayoutWidget*)parent;
45
46 //create "Collections:" header
47 QLabel* collectionsHeader = new QLabel( this );
48 collectionsHeader->setText( tr("Collections:") );
49 QFont labelFont = collectionsHeader->font();
50 labelFont.setWeight(QFont::Bold);
51 collectionsHeader->setFont( labelFont );
52 //--------------------------------------
53 //create collections list
54 collections = new SubalbumsIconView( this );
55
56 //only one item can be selected at a time
57 collections->setSelectionMode( Q3IconView::Single ) ;
58
59 //single column of items
60 collections->setGridX(1);
61
62 //text is on right of icons
63 collections->setItemTextPos( Q3IconView::Right );
64
65 //disable frame
66 collections->setFrameShape ( Q3Frame::NoFrame );
67
68 collections->setMaxItemWidth(500);
69 collections->setPaletteBackgroundColor( QColor(193, 210, 238) );
70 collections->setDragAutoScroll(true);
71 collections->setAcceptDrops(true);
72 collections->setVScrollBarMode( Q3ScrollView::Auto );
73 collections->setHScrollBarMode( Q3ScrollView::Auto );
74 //--------------------------------------
75 //no selection by default
76 currentSelection = NULL;
77 //--------------------------------------
78 //connect drop event on iconview to reorder slot
79 connect( collections, SIGNAL(itemHasMoved()), SLOT(reorder()) );
80
81 //handle selection attempts
82 connect( collections, SIGNAL(selectionChanged(Q3IconViewItem*)),
84 //--------------------------------------
85 //create create/delete buttons
86 QFont buttonFont( qApp->font() );
87 buttonFont.setBold(true);
88 buttonFont.setPointSize( 11 );
89
90 createButton = new QToolButton( this );
91 createButton->setTextLabel(tr("Create"));
92 createButton->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/create.png") );
93 createButton->setTextPosition(QToolButton::BesideIcon);
94 createButton->setFont( buttonFont );
95 createButton->setUsesTextLabel( true );
96 createButton->setEnabled(true);
97 createButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
98 QToolTip::add( createButton, tr("Create a collection and append to subalbum list") );
99 connect( createButton, SIGNAL(clicked()), SLOT(createAction()) );
100
101 deleteButton = new QToolButton( this );
102 deleteButton->setTextLabel(tr("Delete"));
103 deleteButton->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/delete.png") );
104 deleteButton->setTextPosition(QToolButton::BesideIcon);
105 deleteButton->setFont( buttonFont );
106 deleteButton->setUsesTextLabel( true );
107 deleteButton->setEnabled(false);
108 deleteButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
109 QToolTip::add( deleteButton, tr("Delete selected collection and all its contents") );
110 connect( deleteButton, SIGNAL(clicked()), SLOT(deleteAction()) );
111 //--------------------------------------
112 //place label, listbox, and buttons in grid
113 Q3GridLayout* grid = new Q3GridLayout( this, 3, 2, 0 );
114 grid->addMultiCellWidget( collectionsHeader, 0, 0, 0, 1, Qt::AlignHCenter );
115 grid->addMultiCellWidget( collections, 1, 1, 0, 1 );
116 grid->addWidget( createButton, 2, 0, Qt::AlignHCenter);
117 grid->addWidget( deleteButton, 2, 1, Qt::AlignHCenter);
118
119 //allow collections listing to grow
120 grid->setRowStretch( 1, 1 );
121
122 //set the background of the widget to be white
123 setPaletteBackgroundColor( QColor(193, 210, 238) );
124}
Displays list of subalbums and a particular subalbum layout.
Extension of iconview, used to list all subalbums in album. Supports drag-n-drop within iconview such...
QToolButton * createButton
Create collection button.
SubalbumsIconView * collections
list of subalbums
LayoutWidget * layout
Pointer to layoutwidget this widget is in.
void deleteAction()
deletes the currently selected collection
void createAction()
create a new collection
QToolButton * deleteButton
Delete collection button.
void handleSelectionAttempt(Q3IconViewItem *item)
respond to user clicking collection icons
void reorder()
relayout collectionicons after a create/delete refresh
Q3IconViewItem * currentSelection
QString IMAGE_PATH
Definition config.cpp:18

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

Member Function Documentation

◆ collectionSelected

void SubalbumsWidget::collectionSelected ( Subalbum * )
signal

Referenced by selectCollection().

◆ createAction

void SubalbumsWidget::createAction ( )
privateslot

create a new collection

Definition at line 126 of file subalbumsWidget.cpp.

127{
128 //create new collection object
129 Album* albm = layout->getWindow()->getTitle()->getAlbum();
130 Subalbum* newCollection = new Subalbum( albm, albm->getNumSubalbums()+1 );
131 albm->appendSubalbum( newCollection );
132
133 //create collection icon and auto select it
134 SubalbumPreviewWidget* newCollectionIcon = new SubalbumPreviewWidget( collections, newCollection );
135 newCollectionIcon->setDropEnabled(true);
136 selectCollection( newCollectionIcon );
137
138 //update enabled state of delete collection button
139 deleteButton->setEnabled( collections->count() > 1 );
140}
An album contains Subalbums.
Definition album.h:53
void appendSubalbum(Subalbum *val)
Appends subalbum to end of linked list.
Definition album.cpp:234
int getNumSubalbums()
Returns number of subalbums.
Definition album.cpp:144
Window * getWindow()
Returns a pointer to the window.
Displays subalbum icon and name.
A subalbum contains photos.
Definition subalbum.h:49
void selectCollection(Q3IconViewItem *item)
select specified collection
Album * getAlbum()
Returns a pointer to the album object.
TitleWidget * getTitle()
returns a pointer to the title widget
Definition window.cpp:188

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

Referenced by SubalbumsWidget().

◆ deleteAction

void SubalbumsWidget::deleteAction ( )
privateslot

deletes the currently selected collection

Definition at line 142 of file subalbumsWidget.cpp.

143{
144 //if an item is selected it remove it
145 if(collections->currentItem() != NULL)
146 {
147 //if user has chosen to not receive destructive action warnings, or agrees to the action, then
148 //delete subalbum and refresh view
149 bool proceed = !((Window*)qApp->mainWidget())->getConfig()->getBool( "alerts", "showDestructiveAlerts" );
150 if(!proceed)
151 {
152 QuestionDialog sure( tr("Delete collection?"),
153 tr("Once deleted a collection and it's contents cannot be brought back unless a saved copy of the album exists."),
154 "alertIcons/warning.png",
155 this );
156 proceed = sure.exec();
157 }
158 if(proceed)
159 {
160 //get handle on currently selected collection
161 Q3IconViewItem* oldSelection = collections->currentItem();
162
163 //get handle on the next automatically selected collection
164 //auto select the new collection. If there is no next
165 //collection, select the previous collection (again if present)
166 Q3IconViewItem* newSelection = oldSelection->nextItem();
167 if(newSelection == NULL) newSelection = oldSelection->prevItem();
168
169 //auto select a remaining collection if one exists
170 //we select before removing and deleting the old collection so that
171 //the collection information above smoothly transitions
172 selectCollection( newSelection );
173
174 //remove the collection from the album
175 Subalbum* s = ((SubalbumPreviewWidget*) oldSelection)->getSubalbum();
177
178 //free the collection icon
179 delete oldSelection;
180 oldSelection = NULL;
181
182 //rearrange the items in the grid, making
183 //sure new selection is visible
184 collections->arrangeItemsInGrid();
185 if(newSelection != NULL) collections->ensureItemVisible( newSelection );
186
187 //update enabled state of delete collection button
188 deleteButton->setEnabled( collections->count() > 1 );
189
190 //notifty title widget that the album's photo count has possible changed
192 }
193 }
194}
void removeSubalbum(Subalbum *val)
Removes a subalbum.
Definition album.cpp:257
A configurable question dialog that returns true/false.
void updateMenus(bool anySelected=false, bool anyRevertable=false)
update begin presentation menu entry - disabled when no photos in album
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget.
Definition window.h:40

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

Referenced by SubalbumsWidget().

◆ getCurrentSelection()

Q3IconViewItem * SubalbumsWidget::getCurrentSelection ( )

Returns current selection.

Definition at line 235 of file subalbumsWidget.cpp.

235{ return currentSelection; }

References currentSelection.

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

◆ getParent()

LayoutWidget * SubalbumsWidget::getParent ( )

Returns parent.

Definition at line 234 of file subalbumsWidget.cpp.

234{ return layout; }

References layout.

◆ getSelectedSubalbum()

Subalbum * SubalbumsWidget::getSelectedSubalbum ( )

Returns the currently selected subalbum.

Definition at line 237 of file subalbumsWidget.cpp.

238{
239 return ((SubalbumPreviewWidget*) currentSelection )->getSubalbum();
240}

References currentSelection.

Referenced by TitleWidget::storeAnnotations().

◆ handleSelectionAttempt

void SubalbumsWidget::handleSelectionAttempt ( Q3IconViewItem * item)
privateslot

respond to user clicking collection icons

Definition at line 276 of file subalbumsWidget.cpp.

277{
278 //select collections only when program is not busy.
279 if( !layout->getWindow()->getTitle()->getBusy() )
280 selectCollection( item );
281}
bool getBusy()
is program busy?

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

Referenced by SubalbumsWidget().

◆ refreshCollectionsList()

void SubalbumsWidget::refreshCollectionsList ( )

Refreshes list of collections, selecting first by default.

Definition at line 242 of file subalbumsWidget.cpp.

243{
244 //delete all previous entries
245 Q3IconViewItem* current = collections->firstItem();
246 while(current != NULL)
247 {
248 Q3IconViewItem* next = current->nextItem();
249 delete current;
250 current = next;
251 }
252
253 //for some reason scrollbar does not disappear automatically.
254 //Calling clear fixes this.
255 collections->clear();
256
257 //reset cached selection handle
258 currentSelection = NULL;
259
260 //insert all collections
261 Subalbum* curCollection = layout->getWindow()->getTitle()->getAlbum()->getFirstSubalbum();
262 while( curCollection != NULL)
263 {
264 SubalbumPreviewWidget* item = new SubalbumPreviewWidget( collections, curCollection );
265 item->setDropEnabled(true);
266 curCollection = curCollection->getNext();
267 }
268
269 //refresh iconview
270 collections->arrangeItemsInGrid();
271
272 //auto select first item
274}
Subalbum * getFirstSubalbum()
Returns a pointer to the first Subalbum.
Definition album.cpp:135
Subalbum * getNext()
Returns pointer to next subalbum.
Definition subalbum.cpp:98
void selectFirstCollection()
Select specified subalbum.

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

Referenced by LayoutWidget::refresh().

◆ refreshSelectedCollectionName

void SubalbumsWidget::refreshSelectedCollectionName ( )
slot

Definition at line 196 of file subalbumsWidget.cpp.

197{
198 if( currentSelection != NULL)
199 currentSelection->setText( ((SubalbumPreviewWidget*)currentSelection)->getSubalbum()->getName() );
200}

References currentSelection.

Referenced by LayoutWidget::refreshSelectedCollectionIconName().

◆ reorder

void SubalbumsWidget::reorder ( )
privateslot

relayout collectionicons after a create/delete refresh

Definition at line 208 of file subalbumsWidget.cpp.

209{
210 //so item has been moved, reorder linked list of items as necessary
211 collections->sort( true );
212 collections->arrangeItemsInGrid();
213
214 //sync lists
215 Album* albm = layout->getWindow()->getTitle()->getAlbum();
217}
void syncSubalbumList(SubalbumPreviewWidget *item)
Syncs subalbum ordering with front end gui ordering.
Definition album.cpp:1369

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

Referenced by SubalbumsWidget().

◆ selectCollection()

void SubalbumsWidget::selectCollection ( Q3IconViewItem * item)
private

select specified collection

Definition at line 288 of file subalbumsWidget.cpp.

289{
290 //no necessary action when selecting the currently selection collection
291 if(currentSelection == item) return;
292
293 //select item
294 if( item != NULL ) collections->setSelected( item, true);
295
296 //cachce selection
297 currentSelection = item;
298
299 //emit signal that a different collection has been selected
300 if(currentSelection == NULL )
301 emit collectionSelected( NULL );
302 else
304}
void collectionSelected(Subalbum *)

References collections, collectionSelected(), and currentSelection.

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

◆ selectFirstCollection()

void SubalbumsWidget::selectFirstCollection ( )
private

Select specified subalbum.

select first collection

Definition at line 283 of file subalbumsWidget.cpp.

284{
285 selectCollection( collections->firstItem() );
286}

References collections, and selectCollection().

Referenced by refreshCollectionsList().

◆ updateButtons()

void SubalbumsWidget::updateButtons ( bool enable)

Activates/Deactives create/delete buttons.

Definition at line 219 of file subalbumsWidget.cpp.

220{
221 if(enable)
222 {
223 createButton->setEnabled( true );
224 deleteButton->setEnabled( buttonsState );
225 }
226 else
227 {
228 buttonsState = createButton->isEnabled();
229 createButton->setEnabled( false );
230 deleteButton->setEnabled( false );
231 }
232}
bool buttonsState
Cached enabled/disabled state of buttons.

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().

◆ updatedSelectedCollectionImage

void SubalbumsWidget::updatedSelectedCollectionImage ( QPixmap * val)
slot

Definition at line 202 of file subalbumsWidget.cpp.

203{
204 if( currentSelection != NULL)
205 currentSelection->setPixmap( *val );
206}

References currentSelection.

Referenced by LayoutWidget::updateSubalbumImage().

Member Data Documentation

◆ buttonsState

bool SubalbumsWidget::buttonsState
private

Cached enabled/disabled state of buttons.

Definition at line 80 of file subalbumsWidget.h.

Referenced by updateButtons().

◆ collections

SubalbumsIconView* SubalbumsWidget::collections
private

◆ createButton

QToolButton* SubalbumsWidget::createButton
private

Create collection button.

Definition at line 71 of file subalbumsWidget.h.

Referenced by SubalbumsWidget(), and updateButtons().

◆ currentSelection

◆ deleteButton

QToolButton* SubalbumsWidget::deleteButton
private

Delete collection button.

Definition at line 74 of file subalbumsWidget.h.

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

◆ layout

LayoutWidget* SubalbumsWidget::layout
private

Pointer to layoutwidget this widget is in.

Definition at line 77 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: