AlbumShaper  1.0a3
layoutWidget.cpp
Go to the documentation of this file.
1 //==============================================
2 // copyright : (C) 2003-2005 by Will Stokes
3 //==============================================
4 // This program is free software; you can redistribute it
5 // and/or modify it under the terms of the GNU General
6 // Public License as published by the Free Software
7 // Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //==============================================
10 
11 //Systemwide includes
12 #include <qwidget.h>
13 #include <qlayout.h>
14 #include <qlabel.h>
15 #include <q3iconview.h>
16 #include <qtabwidget.h>
17 //Added by qt3to4:
18 #include <QPixmap>
19 #include <Q3GridLayout>
20 
21 //Projectwide includes
22 #include "layoutWidget.h"
23 #include "titleWidget.h"
24 #include "window.h"
25 #include "subalbumsWidget.h"
26 #include "subalbumWidget.h"
28 #include "../backend/subalbum.h"
29 #include "../backend/photo.h"
30 #include "../config.h"
31 
32 //==============================================
33 LayoutWidget::LayoutWidget(QWidget *parent, const char* name ) : QWidget(parent,name)
34 {
35  window = (Window*)parent;
36  subalbums = new SubalbumsWidget( this, "subalbums" );
37  connect( subalbums, SIGNAL( collectionSelected(Subalbum*)),
38  this, SLOT( showCollection( Subalbum* )) );
39 
40  subalbum = new SubalbumWidget( NULL, this, "subalbum" );
41  editingInterface = new EditingInterface( this, "editingInterface" );
42 
43  tabbedArea = new QTabWidget( this, "tabbedArea" );
44  tabbedArea->addTab(subalbum, tr("Organize") );
45  tabbedArea->addTab(editingInterface, tr("Edit") );
46 
47  //by default no photo has been edited
48  tabbedArea->setTabEnabled(editingInterface, false);
49 
50  //catch changing tab selection in order to
51  //initialize editing interface if it was selected
52  connect( tabbedArea, SIGNAL( currentChanged(QWidget*) ),
53  this, SLOT( tabChanged(QWidget*) ) );
54 
55  //catch selectedPhotoStateChanged signal in order to
56  //enable/disable Photos and Tools menu items
57  connect( subalbum, SIGNAL( selectedPhotoStateChanged() ),
58  this, SLOT( photoStateChangedEvent() ) );
59 
60  //catch photo modified signal in order to
61  //enable/disable Photos and Tools menu items
62  connect( editingInterface, SIGNAL( photoModified() ),
63  this, SLOT( photoStateChangedEvent() ) );
64 
65  //place the subalbums list and tabbed area in grid
66  grid = new Q3GridLayout( this, 1, 2, 0 );
67 
68  grid->addWidget( subalbums, 0, 0 );
69  grid->setColSpacing( 0, subalbums->sizeHint().width() );
70 
71  grid->addWidget( tabbedArea, 0, 1 );
72  grid->setColStretch( 1, 1 );
73 }
74 //==============================================
76 {
77  //ensure currently in organize mode
78  organize();
79 
80  //load collection
81  subalbum->setSubalbum(collection);
82 
83  //pass signal on so title area can update as well
84  emit collectionSelected( collection );
85 }
86 //==============================================
88 {
90 }
91 //==============================================
93 {
95 }
96 //==============================================
98 {
99  return subalbum;
100 }
101 //==============================================
103 {
104  return subalbums;
105 }
106 //==============================================
108 {
109  return window;
110 }
111 //==============================================
113 {
115 }
116 //==============================================
118 {
119  //orignize tab seleced
120  if(widget != editingInterface)
121  {
122  //refresh all thumbnails since any could have changed
124 
125  //handle the selected/shown photo state having been changed
127 
128  //find and select the last shown photo in the
129  //editing interface, unselect all other items
131 
132  return;
133  }
134  //edit tab selected - init editor
135  else
136  {
138  Subalbum* collection = subalbum->getSubalbum();
139  Photo* photo = subalbum->getFirstSelectedPhoto();
140 
141  //bail if either pointer is null (sanity check)
142  if(collection == NULL || photo == NULL)
143  return;
144 
145  //init editing interface for current collection:photo
146  editingInterface->setPhoto( collection, photo);
148 
149  //handle the selected/shown photo state having been changed
151  }
152 }
153 //==============================================
155 {
156  tabbedArea->showPage( editingInterface );
157 }
158 //==============================================
160 {
161  tabbedArea->setCurrentPage( 0 );
162 }
163 //==============================================
165 {
166  tabbedArea->setTabEnabled(editingInterface, val);
167 }
168 //==============================================
170 {
171  if( tabbedArea->currentPage() == subalbum )
173  else if( tabbedArea->currentPage() == editingInterface )
175 }
176 //==============================================
178 {
179  //determine if:
180  //1.) any photos are selected - false if in editing mode
181  //2.) if any revertable photos are selected/shown
182  bool anySelected = false;
183  bool anyRevertable = false;
184 
185  if( tabbedArea->currentPage() == subalbum )
186  {
187  anySelected = subalbum->anyPhotosSelected();
188  anyRevertable = anySelected && subalbum->anySelectedPhotosRevertable();
189  }
190  else
191  {
192  //none selected in editing mode
193  anySelected = false;
194  anyRevertable = editingInterface->currentPhotoRevertable();
195  }
196 
197  //update menus
198  window->getTitle()->updateMenus(anySelected, anyRevertable);
199 }
200 //==============================================
Interface for editing photo.
void setPhoto(Subalbum *collection, Photo *photo)
Sets the photo pointer and constructs scaled qimage's for painting.
Photo * getPhoto()
Returns a pointer to the currently selected photo.
void revertCurrentPhoto()
reverts current photo and updates display
void revertPhotos()
Reverts all selected photos in organize mode, or currently shown photo if in editing mode.
SubalbumsWidget * subalbums
List of subalbums.
Definition: layoutWidget.h:71
void photoStateChangedEvent()
handle the changing state of selected/shown photos
SubalbumWidget * getSubalbum()
Returns a pointer to the subalbum.
void collectionSelected(Subalbum *)
void updateSubalbumImage(QPixmap *val)
Updates the current subalbums image.
void refresh()
Refreshes layout.
EditingInterface * editingInterface
Editing interface.
Definition: layoutWidget.h:80
Q3GridLayout * grid
Grid items placed in.
Definition: layoutWidget.h:68
void showCollection(Subalbum *collection)
Window * window
Window pointer.
Definition: layoutWidget.h:65
void setEditTabEnabled(bool val)
void refreshSelectedCollectionIconName()
updates the selected collection icon name
SubalbumWidget * subalbum
Collection organize widget.
Definition: layoutWidget.h:77
LayoutWidget(QWidget *parent=0, const char *name=0)
Creates empty layout.
void editSelectedPhoto()
Edits first select photo.
void tabChanged(QWidget *widget)
handle tab shown changed signal
void organize()
Select organize tab.
Window * getWindow()
Returns a pointer to the window.
SubalbumsWidget * getSubalbums()
Returns a pointer to the subalbums.
QTabWidget * tabbedArea
Tab widget containing organize and edit widgets.
Definition: layoutWidget.h:74
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image,...
Definition: photo.h:45
Displays subalbum layout.
void setSubalbum(Subalbum *salbum)
Resets the subalbum this subalbum widget is displaying.
void refreshAllPhotos()
refreshes all photos, selections are preserved
void setSelectedPhoto(Photo *selection)
Sets the selected photo to selection and ensures it is visible.
bool anyPhotosSelected()
Returns true if any phtos are selected.
Subalbum * getSubalbum()
returns a pointer to the backend subalbum
Photo * getFirstSelectedPhoto()
Returns first selected photo.
void revertSelectedPhotos()
Revert selected photos to their original form.
bool anySelectedPhotosRevertable()
Returns true if any selected photos are revertable.
A subalbum contains photos.
Definition: subalbum.h:49
Columnview of all subalbums in album.
void updatedSelectedCollectionImage(QPixmap *val)
void refreshSelectedCollectionName()
void refreshCollectionsList()
Refreshes list of collections, selecting first by default.
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
TitleWidget * getTitle()
returns a pointer to the title widget
Definition: window.cpp:188