Main Page   Compound List   File List   Compound 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 #include <iostream.h>
00032 
00033 //==============================================
00034 LayoutWidget::LayoutWidget(QWidget *parent, 
00035                            const char* name ) : QWidget(parent,name)
00036 {
00037   window = (Window*)parent;
00038   
00039   subalbums = new SubalbumsWidget( this, "subalbums" );
00040   subalbum = NULL;
00041   
00042   //place the subalbums list and subalbum view in grid
00043   grid = new QGridLayout( this, 1, 2, 0 );
00044   grid->addWidget( subalbums, 0, 0 );
00045 
00046   //create a photo edit widget, when need the current subalbum can be
00047   //removed from the grid and the photo edit widget can be inserted, then
00048   //exchanged again when edting concludes.
00049   photoEdit = new PhotoEditWidget( this, "photo edit" );
00050   grid->addWidget( photoEdit, 0, 1 );
00051   photoEdit->hide();
00052     
00053   grid->setColStretch( 1, 1 );
00054 
00055   grid->addColSpacing(0, 100 );
00056 
00057   //set the background of the widget to be white
00058   setPaletteBackgroundColor( QColor(255, 255, 255) );
00059 }
00060 //==============================================
00061 void LayoutWidget::updateSubalbum(Subalbum* salbum, bool oldExists)
00062 {
00063   //if new selection is same as old selection do nothing
00064   if(subalbum != NULL && salbum == subalbum->getSubalbum())
00065     return;
00066     
00067   //if a subalbum previously displayed update it
00068   if(subalbum != NULL)
00069   {
00070     //sync up old data
00071     if(oldExists)
00072       subalbum->syncPhotos();
00073     
00074     //if new subalbum exists update subalbum
00075     if(salbum != NULL)
00076     {
00077       subalbum->setSubalbum(salbum);
00078     }
00079     //else just destroy old subalbum view
00080     else
00081     {
00082       delete subalbum;
00083       subalbum = NULL;
00084     }
00085   }
00086   //else create a new subalbum widget and populate it
00087   else if(salbum != NULL)
00088   {
00089     //create new subalbum widget
00090     subalbum = new SubalbumWidget( salbum, this, "subalbum" );
00091 
00092     //insert into layout
00093     grid->addWidget( subalbum, 0, 1 );
00094     subalbum->show();
00095     subalbum->refreshPhotos();
00096   }
00097 }
00098 //==============================================
00099 void LayoutWidget::updateSubalbumName(const QString& val)
00100 {
00101   subalbums->updateSubalbumName(val);
00102 }
00103 //==============================================
00104 void LayoutWidget::updateSubalbumImage( QPixmap* val)
00105 {
00106   subalbums->updateSubalbumThumbnail(val);
00107 }
00108 //==============================================
00109 SubalbumWidget* LayoutWidget::getSubalbum()
00110 {
00111   return subalbum;
00112 }
00113 //==============================================
00114 SubalbumsWidget* LayoutWidget::getSubalbums()
00115 {
00116   return subalbums;
00117 }
00118 //==============================================
00119 Window* LayoutWidget::getWindow()
00120 {
00121   return window;
00122 }
00123 //==============================================
00124 void LayoutWidget::refresh()
00125 {
00126   subalbums->refresh();
00127 }
00128 //==============================================
00129 void LayoutWidget::editPhoto(Photo* photo)
00130 {
00131   //never edit null photos, this should never happen but it's a sanity check anyways
00132   if(photo == NULL)
00133     return;
00134     
00135   //if a subalbum exists hide it
00136   if(subalbum != NULL)
00137     subalbum->hide();
00138     
00139   //set the photo pointer for the photo edit widget
00140   photoEdit->setPhoto(photo);
00141   
00142   //unhide the photo edit widget
00143   photoEdit->show();    
00144 }
00145 //==============================================
00146 void LayoutWidget::stopEdit(bool oldExists)
00147 {
00148    //hide edit window, show subalbum window
00149   //refresh thumbnail and text for selected image
00150   photoEdit->hide();
00151   if(subalbum != NULL)
00152   {
00153     subalbum->show();
00154    if(oldExists)
00155      subalbum->refreshSelectedPhotos();
00156   }  
00157 }
00158 //==============================================

Generated on Tue Jun 10 23:41:20 2003 for AlbumShaper by doxygen 1.3.1