FilePreview Class Reference

#include <addPhotosDialog.h>

Inheritance diagram for FilePreview:

[legend]
Collaboration diagram for FilePreview:
[legend]
List of all members.

Detailed Description

Definition at line 55 of file addPhotosDialog.h.

Public Member Functions

 FilePreview (QWidget *parent=0)
 ~FilePreview ()
QSize minimumSizeHint () const
void previewUrl (const QUrl &)
 declared to make base class happy. we'll use an updatePreview function instead
void updatePreview (const QString &path)
 call this function to update the file preview

Protected Member Functions

void customEvent (QCustomEvent *e)
 handle update events that come from the GeneratePreviewThread

Private Attributes

QLabelfilePreview
 preview of last selected file
QLabelfileDetails
 details about last selected file
GeneratePreviewThreadgeneratorThread
 a worker thread that actually generates the file preview image and details information that is displayed.


Constructor & Destructor Documentation

FilePreview::FilePreview ( QWidget parent = 0  ) 

Definition at line 173 of file addPhotosDialog.cpp.

References fileDetails, filePreview, and generatorThread.

00173                                         : QWidget(parent) 
00174 {
00175   //create widgets for display preview image and details
00176   filePreview = new QLabel( this );  
00177   fileDetails = new QLabel( this );  
00178   
00179   QGridLayout* grid = new QGridLayout( this, 4, 3 );
00180   grid->setRowStretch( 0, 1 );
00181   grid->addWidget( filePreview, 1, 1, Qt::AlignHCenter );
00182   grid->addWidget( fileDetails, 2, 1, Qt::AlignHCenter );
00183   grid->setRowStretch( 3, 1 );
00184 
00185   grid->setColStretch( 0, 1 );
00186   grid->setColStretch( 2, 1 );
00187  
00188   //create a generator thread that will be used for actually generating 
00189   //preview images and constructing details strings
00190   generatorThread = new GeneratePreviewThread(this);
00191 }

FilePreview::~FilePreview (  ) 

Definition at line 193 of file addPhotosDialog.cpp.

References generatorThread.

00194 {
00195   //make sure generator thread is done!
00196   generatorThread->wait();
00197   delete generatorThread;
00198   generatorThread = NULL;
00199 }


Member Function Documentation

QSize FilePreview::minimumSizeHint (  )  const

Definition at line 201 of file addPhotosDialog.cpp.

References MIN_HEIGHT, and MIN_WIDTH.

00202 {
00203   QFontMetrics fm( font() );
00204   return QSize(MIN_WIDTH, MIN_HEIGHT + 2*fm.height() );
00205 }

void FilePreview::previewUrl ( const QUrl &   )  [inline]

declared to make base class happy. we'll use an updatePreview function instead

Definition at line 63 of file addPhotosDialog.h.

00063 {}

void FilePreview::updatePreview ( const QString &  path  ) 

call this function to update the file preview

Definition at line 226 of file addPhotosDialog.cpp.

References generatorThread, and GeneratePreviewThread::start().

Referenced by AddPhotosDialog::updatePreview().

00227 {
00228   //handle requests to update the preview information by asking
00229   //the generator thread to handle them. by using
00230   //an auxiallary thread we can process requests very quickly while
00231   //any current work being done to generate an image preview continues
00232   if( generatorThread != NULL)
00233   {
00234     generatorThread->start( filename );
00235   }
00236 }

void FilePreview::customEvent ( QCustomEvent e  )  [protected]

handle update events that come from the GeneratePreviewThread

Definition at line 207 of file addPhotosDialog.cpp.

References fileDetails, filePreview, and UPDATE_PREVIEW_DETAILS.

00208 {
00209   //handle UpdatePrevewEvents that are sent from the worker thread
00210   //by update the preview image and details that are shown
00211   if ( e->type() == UPDATE_PREVIEW_DETAILS ) 
00212   {  
00213     UpdatePreviewEvent* upe = (UpdatePreviewEvent*)e;
00214 
00215     if( !upe->getImage().isNull() )
00216     {
00217       QPixmap scaledPixmap;
00218       scaledPixmap.convertFromImage( upe->getImage() );
00219       filePreview->setPixmap( scaledPixmap );
00220     }
00221     
00222     fileDetails->setText( upe->getDetails() );
00223   }
00224 }


Member Data Documentation

QLabel* FilePreview::filePreview [private]

preview of last selected file

Definition at line 74 of file addPhotosDialog.h.

Referenced by customEvent(), and FilePreview().

QLabel* FilePreview::fileDetails [private]

details about last selected file

Definition at line 77 of file addPhotosDialog.h.

Referenced by customEvent(), and FilePreview().

GeneratePreviewThread* FilePreview::generatorThread [private]

a worker thread that actually generates the file preview image and details information that is displayed.

Definition at line 82 of file addPhotosDialog.h.

Referenced by FilePreview(), updatePreview(), and ~FilePreview().


The documentation for this class was generated from the following files:
Generated on Wed Jan 24 05:38:31 2007 for AlbumShaper by  doxygen 1.5.1