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

layoutWidget.cpp

Go to the documentation of this file.
00001 //============================================== 00002 // copyright : (C) 2003-2005 by Will Stokes 00003 //============================================== 00004 // This program is free software; you can redistribute it 00005 // and/or modify it under the terms of the GNU General 00006 // Public License as published by the Free Software 00007 // Foundation; either version 2 of the License, or 00008 // (at your option) any later version. 00009 //============================================== 00010 00011 //Systemwide includes 00012 #include <qwidget.h> 00013 #include <qlayout.h> 00014 #include <qlabel.h> 00015 #include <qiconview.h> 00016 #include <qtabwidget.h> 00017 00018 //Projectwide includes 00019 #include "layoutWidget.h" 00020 #include "titleWidget.h" 00021 #include "window.h" 00022 #include "subalbumsWidget.h" 00023 #include "subalbumWidget.h" 00024 #include "editing/editingInterface.h" 00025 #include "../backend/subalbum.h" 00026 #include "../backend/photo.h" 00027 #include "../config.h" 00028 00029 //============================================== 00030 LayoutWidget::LayoutWidget(QWidget *parent, const char* name ) : QWidget(parent,name) 00031 { 00032 window = (Window*)parent; 00033 subalbums = new SubalbumsWidget( this, "subalbums" ); 00034 connect( subalbums, SIGNAL( collectionSelected(Subalbum*)), 00035 this, SLOT( showCollection( Subalbum* )) ); 00036 00037 subalbum = new SubalbumWidget( NULL, this, "subalbum" ); 00038 editingInterface = new EditingInterface( this, "editingInterface" ); 00039 00040 tabbedArea = new QTabWidget( this, "tabbedArea" ); 00041 tabbedArea->addTab(subalbum, tr("Organize") ); 00042 tabbedArea->addTab(editingInterface, tr("Edit") ); 00043 00044 //by default no photo has been edited 00045 tabbedArea->setTabEnabled(editingInterface, false); 00046 00047 //catch changing tab selection in order to 00048 //initialize editing interface if it was selected 00049 connect( tabbedArea, SIGNAL( currentChanged(QWidget*) ), 00050 this, SLOT( tabChanged(QWidget*) ) ); 00051 00052 //catch selectedPhotoStateChanged signal in order to 00053 //enable/disable Photos and Tools menu items 00054 connect( subalbum, SIGNAL( selectedPhotoStateChanged() ), 00055 this, SLOT( photoStateChangedEvent() ) ); 00056 00057 //catch photo modified signal in order to 00058 //enable/disable Photos and Tools menu items 00059 connect( editingInterface, SIGNAL( photoModified() ), 00060 this, SLOT( photoStateChangedEvent() ) ); 00061 00062 //place the subalbums list and tabbed area in grid 00063 grid = new QGridLayout( this, 1, 2, 0 ); 00064 00065 grid->addWidget( subalbums, 0, 0 ); 00066 grid->setColSpacing( 0, subalbums->sizeHint().width() ); 00067 00068 grid->addWidget( tabbedArea, 0, 1 ); 00069 grid->setColStretch( 1, 1 ); 00070 } 00071 //============================================== 00072 void LayoutWidget::showCollection(Subalbum* collection) 00073 { 00074 //ensure currently in organize mode 00075 organize(); 00076 00077 //load collection 00078 subalbum->setSubalbum(collection); 00079 00080 //pass signal on so title area can update as well 00081 emit collectionSelected( collection ); 00082 } 00083 //============================================== 00084 void LayoutWidget::refreshSelectedCollectionIconName() 00085 { 00086 subalbums->refreshSelectedCollectionName(); 00087 } 00088 //============================================== 00089 void LayoutWidget::updateSubalbumImage( QPixmap* val) 00090 { 00091 subalbums->updatedSelectedCollectionImage(val); 00092 } 00093 //============================================== 00094 SubalbumWidget* LayoutWidget::getSubalbum() 00095 { 00096 return subalbum; 00097 } 00098 //============================================== 00099 SubalbumsWidget* LayoutWidget::getSubalbums() 00100 { 00101 return subalbums; 00102 } 00103 //============================================== 00104 Window* LayoutWidget::getWindow() 00105 { 00106 return window; 00107 } 00108 //============================================== 00109 void LayoutWidget::refresh() 00110 { 00111 subalbums->refreshCollectionsList(); 00112 } 00113 //============================================== 00114 void LayoutWidget::tabChanged( QWidget* widget) 00115 { 00116 //orignize tab seleced 00117 if(widget != editingInterface) 00118 { 00119 //refresh all thumbnails since any could have changed 00120 subalbum->refreshAllPhotos(); 00121 00122 //handle the selected/shown photo state having been changed 00123 photoStateChangedEvent(); 00124 00125 //find and select the last shown photo in the 00126 //editing interface, unselect all other items 00127 subalbum->setSelectedPhoto( editingInterface->getPhoto() ); 00128 00129 return; 00130 } 00131 //edit tab selected - init editor 00132 else 00133 { 00135 Subalbum* collection = subalbum->getSubalbum(); 00136 Photo* photo = subalbum->getFirstSelectedPhoto(); 00137 00138 //bail if either pointer is null (sanity check) 00139 if(collection == NULL || photo == NULL) 00140 return; 00141 00142 //init editing interface for current collection:photo 00143 editingInterface->setPhoto( collection, photo); 00144 editingInterface->setFocus(); 00145 00146 //handle the selected/shown photo state having been changed 00147 photoStateChangedEvent(); 00148 } 00149 } 00150 //============================================== 00151 void LayoutWidget::editSelectedPhoto() 00152 { 00153 tabbedArea->showPage( editingInterface ); 00154 } 00155 //============================================== 00156 void LayoutWidget::organize() 00157 { 00158 tabbedArea->setCurrentPage( 0 ); 00159 } 00160 //============================================== 00161 void LayoutWidget::setEditTabEnabled(bool val) 00162 { 00163 tabbedArea->setTabEnabled(editingInterface, val); 00164 } 00165 //============================================== 00166 void LayoutWidget::revertPhotos() 00167 { 00168 if( tabbedArea->currentPage() == subalbum ) 00169 subalbum->revertSelectedPhotos(); 00170 else if( tabbedArea->currentPage() == editingInterface ) 00171 editingInterface->revertCurrentPhoto(); 00172 } 00173 //============================================== 00174 void LayoutWidget::photoStateChangedEvent() 00175 { 00176 //determine if: 00177 //1.) any photos are selected - false if in editing mode 00178 //2.) if any revertable photos are selected/shown 00179 bool anySelected = false; 00180 bool anyRevertable = false; 00181 00182 if( tabbedArea->currentPage() == subalbum ) 00183 { 00184 anySelected = subalbum->anyPhotosSelected(); 00185 anyRevertable = anySelected && subalbum->anySelectedPhotosRevertable(); 00186 } 00187 else 00188 { 00189 //none selected in editing mode 00190 anySelected = false; 00191 anyRevertable = editingInterface->currentPhotoRevertable(); 00192 } 00193 00194 //update menus 00195 window->getTitle()->updateMenus(anySelected, anyRevertable); 00196 } 00197 //==============================================

Generated on Sun Mar 4 19:42:56 2007 for AlbumShaper by doxygen 1.3.7