Main Page   Compound List   File List   Compound Members   File Members  

toolbarWidget.cpp

Go to the documentation of this file.
00001 //Systemwide includes
00002 #include <qwidget.h>
00003 #include <qlayout.h>
00004 #include <qpushbutton.h>
00005 #include <qpixmap.h>
00006 #include <qsplitter.h>
00007 
00008 //Projectwide includes
00009 #include "toolbarWidget.h"
00010 #include "titleWidget.h"
00011 #include "layoutWidget.h"
00012 #include "subalbumWidget.h"
00013 #include "window.h"
00014 #include "../backend/album.h"
00015 
00016 #include <iostream.h>
00017 
00018 
00019 //==============================================
00021 ToolbarWidget::ToolbarWidget(QWidget *parent, 
00022                              const char* name ) : QFrame(parent,name)
00023 {
00024   //store parent window pointer
00025   this->parent = (Window*)parent;
00026   //Create horizontal line
00027   line = new QFrame(this);
00028   line->setFrameShadow( QFrame::Plain );
00029   line->setLineWidth( 2 );
00030   line->setFrameShape( QFrame::HLine );
00031 
00032   //Create buttons and connect their click signals to the action slots
00033   loadImage = new QPixmap( "images/load.png" );
00034   load = new QPushButton( this );
00035   load->setPixmap( *loadImage );
00036   connect( load, SIGNAL(clicked()), SLOT(loadAction()) );
00037 
00038   storeImage = new QPixmap( "images/store.png" );
00039   store = new QPushButton( this );
00040   store->setPixmap( *storeImage );
00041   connect( store, SIGNAL(clicked()), SLOT(storeAction()) );
00042   
00043   //Place images in grid
00044   grid = new QGridLayout( this, 2, 5, 0 );
00045   grid->addMultiCellWidget( line, 0, 0, 0, 8 );
00046   grid->addWidget( load, 1, 1, Qt::AlignCenter);
00047   grid->addWidget( store, 1, 3, Qt::AlignCenter);
00048 
00049   //Set spaces between buttons to stretch to fill any empty space
00050   grid->setColStretch( 0, 1 );
00051   grid->setColStretch( 2, 1 );
00052   grid->setColStretch( 4, 1 );
00053 
00054   //set the background of the widget to be white
00055   setPaletteBackgroundColor( QColor(255, 255, 255) );
00056 }
00057 //==============================================
00058 ToolbarWidget::~ToolbarWidget()
00059 {
00060   delete loadImage;
00061   delete load;
00062   delete storeImage;
00063   delete store;
00064   delete line;
00065   delete grid;
00066 }
00067 //==============================================
00068 void ToolbarWidget::loadAction()
00069 {
00070   //create a new album
00071   Album* albm = new Album();
00072   
00073   //attempt to load xml file
00074   albm->importFromDisk();
00075   
00076   //set album in title
00077   parent->getTitle()->setAlbum( albm );
00078   
00079   //refresh screen
00080   parent->refresh();
00081 }
00082 //==============================================
00083 void ToolbarWidget::storeAction()
00084 {
00085   //sync current subalbum to ensure all photo descriptions saved
00086   if(  parent->getLayout()->getSubalbum() != NULL )
00087     parent->getLayout()->getSubalbum()->syncPhotos();
00088     
00089   parent->getTitle()->getAlbum()->exportToDisk();
00090 }
00091 //==============================================

Generated on Sun Feb 23 00:52:09 2003 for AlbumMaker by doxygen1.2.18