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

layoutWidget.cpp

Go to the documentation of this file.
00001 //==============================================
00002 //  copyright            : (C) 2003 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 //  As a special exception, Will Stokes gives permission to 
00011 //  link this program with Qt non-commercial edition, and 
00012 //  distribute the resulting executable, without including the 
00013 //  source code for the Qt non-commercial edition in the 
00014 //  source distribution. 
00015 //==============================================
00016 
00017 //Systemwide includes
00018 #include <qwidget.h>
00019 #include <qlayout.h>
00020 #include <qlabel.h>
00021 
00022 //Projectwide includes
00023 #include "layoutWidget.h"
00024 #include "window.h"
00025 #include "subalbumsWidget.h"
00026 #include "subalbumWidget.h"
00027 #include "photoEditWidget.h"
00028 #include "../backend/subalbum.h"
00029 #include "../backend/photo.h"
00030 
00031 //==============================================
00032 LayoutWidget::LayoutWidget(QWidget *parent, 
00033                            const char* name ) : QWidget(parent,name)
00034 {
00035   window = (Window*)parent;
00036   
00037   subalbums = new SubalbumsWidget( this, "subalbums" );
00038   subalbum = NULL;
00039   
00040   //place the subalbums list and subalbum view in grid
00041   grid = new QGridLayout( this, 1, 2, 0 );
00042   grid->addWidget( subalbums, 0, 0 );
00043 
00044   //create a photo edit widget, when need the current subalbum can be
00045   //removed from the grid and the photo edit widget can be inserted, then
00046   //exchanged again when edting concludes.
00047   photoEdit = new PhotoEditWidget( this, "photo edit" );
00048   grid->addWidget( photoEdit, 0, 1 );
00049   photoEdit->hide();
00050     
00051   grid->setColStretch( 1, 1 );
00052 
00053   //set the background of the widget to be white
00054   setPaletteBackgroundColor( QColor(255, 255, 255) );
00055 }
00056 //==============================================
00057 void LayoutWidget::updateSubalbum(Subalbum* salbum, bool oldExists)
00058 {
00059   //if new selection is same as old selection do nothing
00060   if(subalbum != NULL && salbum == subalbum->getSubalbum())
00061     return;
00062     
00063   //if a subalbum previously displayed update it
00064   if(subalbum != NULL)
00065   {
00066     //sync up old data
00067     if(oldExists)
00068       subalbum->syncPhotos();
00069     
00070     //if new subalbum exists update subalbum
00071     if(salbum != NULL)
00072     {
00073       subalbum->setSubalbum(salbum);
00074     }
00075     //else just destroy old subalbum view
00076     else
00077     {
00078       delete subalbum;
00079       subalbum = NULL;
00080     }
00081   }
00082   //else create a new subalbum widget and populate it
00083   else if(salbum != NULL)
00084   {
00085     //create new subalbum widget
00086     subalbum = new SubalbumWidget( salbum, this, "subalbum" );
00087 
00088     //insert into layout
00089     grid->addWidget( subalbum, 0, 1 );
00090     subalbum->show();
00091     subalbum->refreshPhotos();
00092   }
00093 }
00094 //==============================================
00095 void LayoutWidget::updateSubalbumName(const QString& val)
00096 {
00097   subalbums->updateSubalbumName(val);
00098 }
00099 //==============================================
00100 void LayoutWidget::updateSubalbumImage( QPixmap* val)
00101 {
00102   subalbums->updateSubalbumThumbnail(val);
00103 }
00104 //==============================================
00105 SubalbumWidget* LayoutWidget::getSubalbum()
00106 {
00107   return subalbum;
00108 }
00109 //==============================================
00110 SubalbumsWidget* LayoutWidget::getSubalbums()
00111 {
00112   return subalbums;
00113 }
00114 //==============================================
00115 Window* LayoutWidget::getWindow()
00116 {
00117   return window;
00118 }
00119 //==============================================
00120 void LayoutWidget::refresh()
00121 {
00122   subalbums->refresh();
00123 }
00124 //==============================================
00125 void LayoutWidget::editPhoto(Photo* photo)
00126 {
00127   //never edit null photos, this should never happen but it's a sanity check anyways
00128   if(photo == NULL)
00129     return;
00130     
00131   //if a subalbum exists hide it
00132   if(subalbum != NULL)
00133     subalbum->hide();
00134     
00135   //set the photo pointer for the photo edit widget
00136   photoEdit->setPhoto(photo);
00137   
00138   //unhide the photo edit widget
00139   photoEdit->show();    
00140 }
00141 //==============================================
00142 void LayoutWidget::stopEdit(bool oldExists)
00143 {
00144    //hide edit window, show subalbum window
00145   //refresh thumbnail and text for selected image
00146   photoEdit->hide();
00147   if(subalbum != NULL)
00148   {
00149     subalbum->show();
00150    if(oldExists)
00151      subalbum->refreshSelectedPhotos();
00152   }  
00153 }
00154 //==============================================

Generated on Thu Nov 13 00:10:53 2003 for AlbumShaper by doxygen 1.3.4