AlbumShaper  1.0a3
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
FilePreview Class Reference

#include <addPhotosDialog.h>

Inheritance diagram for FilePreview:
Inheritance graph
[legend]
Collaboration diagram for FilePreview:
Collaboration graph
[legend]

Public Member Functions

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

Protected Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 59 of file addPhotosDialog.h.

Constructor & Destructor Documentation

§ FilePreview()

FilePreview::FilePreview ( QWidget parent = 0)

Definition at line 176 of file addPhotosDialog.cpp.

References fileDetails, filePreview, and generatorThread.

176  : QWidget(parent)
177 {
178  //create widgets for display preview image and details
179  filePreview = new QLabel( this );
180  fileDetails = new QLabel( this );
181 
182  Q3GridLayout* grid = new Q3GridLayout( this, 4, 3 );
183  grid->setRowStretch( 0, 1 );
184  grid->addWidget( filePreview, 1, 1, Qt::AlignHCenter );
185  grid->addWidget( fileDetails, 2, 1, Qt::AlignHCenter );
186  grid->setRowStretch( 3, 1 );
187 
188  grid->setColStretch( 0, 1 );
189  grid->setColStretch( 2, 1 );
190 
191  //create a generator thread that will be used for actually generating
192  //preview images and constructing details strings
194 }
GeneratePreviewThread * generatorThread
a worker thread that actually generates the file preview image and details information that is displa...
QLabel * fileDetails
details about last selected file
QLabel * filePreview
preview of last selected file

§ ~FilePreview()

FilePreview::~FilePreview ( )

Definition at line 196 of file addPhotosDialog.cpp.

References generatorThread.

197 {
198  //make sure generator thread is done!
199  generatorThread->wait();
200  delete generatorThread;
201  generatorThread = NULL;
202 }
GeneratePreviewThread * generatorThread
a worker thread that actually generates the file preview image and details information that is displa...

Member Function Documentation

§ customEvent()

void FilePreview::customEvent ( QCustomEvent e)
protected

handle update events that come from the GeneratePreviewThread

Definition at line 210 of file addPhotosDialog.cpp.

References fileDetails, filePreview, UpdatePreviewEvent::getDetails(), UpdatePreviewEvent::getImage(), and UPDATE_PREVIEW_DETAILS.

211 {
212  //handle UpdatePrevewEvents that are sent from the worker thread
213  //by update the preview image and details that are shown
214  if ( e->type() == UPDATE_PREVIEW_DETAILS )
215  {
217 
218  if( !upe->getImage().isNull() )
219  {
220  QPixmap scaledPixmap;
221  scaledPixmap.convertFromImage( upe->getImage() );
222  filePreview->setPixmap( scaledPixmap );
223  }
224 
225  fileDetails->setText( upe->getDetails() );
226  }
227 }
QLabel * fileDetails
details about last selected file
QLabel * filePreview
preview of last selected file
#define UPDATE_PREVIEW_DETAILS
QString getDetails() const
QImage getImage() const

§ minimumSizeHint()

QSize FilePreview::minimumSizeHint ( ) const

Definition at line 204 of file addPhotosDialog.cpp.

References MIN_HEIGHT, and MIN_WIDTH.

205 {
206  QFontMetrics fm( font() );
207  return QSize(MIN_WIDTH, MIN_HEIGHT + 2*fm.height() );
208 }
#define MIN_HEIGHT
#define MIN_WIDTH

§ previewUrl()

void FilePreview::previewUrl ( const Q3Url &  )
inline

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

Definition at line 67 of file addPhotosDialog.h.

67 {}

§ updatePreview()

void FilePreview::updatePreview ( const QString &  path)

call this function to update the file preview

Definition at line 229 of file addPhotosDialog.cpp.

References generatorThread, and GeneratePreviewThread::start().

Referenced by AddPhotosDialog::updatePreview().

230 {
231  //handle requests to update the preview information by asking
232  //the generator thread to handle them. by using
233  //an auxiallary thread we can process requests very quickly while
234  //any current work being done to generate an image preview continues
235  if( generatorThread != NULL)
236  {
237  generatorThread->start( filename );
238  }
239 }
GeneratePreviewThread * generatorThread
a worker thread that actually generates the file preview image and details information that is displa...
void start(QString filename)

Member Data Documentation

§ fileDetails

QLabel* FilePreview::fileDetails
private

details about last selected file

Definition at line 81 of file addPhotosDialog.h.

Referenced by customEvent(), and FilePreview().

§ filePreview

QLabel* FilePreview::filePreview
private

preview of last selected file

Definition at line 78 of file addPhotosDialog.h.

Referenced by customEvent(), and FilePreview().

§ generatorThread

GeneratePreviewThread* FilePreview::generatorThread
private

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

Definition at line 86 of file addPhotosDialog.h.

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


The documentation for this class was generated from the following files: