/**
* \file PreviewImage.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "PreviewImage.h"
#include "PreviewLoader.h"
#include "GraphicsImage.h"
#include "GraphicsLoader.h"
-#include "debug.h"
-
#include "support/lyxlib.h"
#include <boost/bind.hpp>
///
~Impl();
///
- void startLoading();
- ///
Image const * image();
///
void statusChanged();
///
PreviewLoader & ploader_;
///
- boost::scoped_ptr<Loader> const iloader_;
+ Loader iloader_;
///
string const snippet_;
///
{}
-void PreviewImage::startLoading()
-{
- return pimpl_->startLoading();
-}
-
-
string const & PreviewImage::snippet() const
{
return pimpl_->snippet_;
}
+
int PreviewImage::ascent() const
{
- Image const * const image = pimpl_->image();
+ Image const * const image = pimpl_->iloader_.image();
if (!image)
return 0;
int PreviewImage::descent() const
{
- Image const * const image = pimpl_->image();
+ Image const * const image = pimpl_->iloader_.image();
if (!image)
return 0;
int PreviewImage::width() const
{
- Image const * const image = pimpl_->image();
+ Image const * const image = pimpl_->iloader_.image();
return image ? image->getWidth() : 0;
}
string const & s,
string const & bf,
double af)
- : parent_(p), ploader_(l), iloader_(new Loader(bf)),
+ : parent_(p), ploader_(l), iloader_(bf),
snippet_(s), ascent_frac_(af)
-{}
-
-
-PreviewImage::Impl::~Impl()
{
- lyx::unlink(iloader_->filename());
+ iloader_.connect(boost::bind(&Impl::statusChanged, this));
}
-void PreviewImage::Impl::startLoading()
+PreviewImage::Impl::~Impl()
{
- if (iloader_->status() != WaitingToLoad)
- return;
-
- iloader_->statusChanged.connect(
- boost::bind(&Impl::statusChanged, this));
- iloader_->startLoading();
+ lyx::unlink(iloader_.filename());
}
Image const * PreviewImage::Impl::image()
{
-// startLoading();
- return iloader_->image();
+ if (iloader_.status() == WaitingToLoad)
+ iloader_.startLoading();
+
+ return iloader_.image();
}
+
void PreviewImage::Impl::statusChanged()
{
- switch (iloader_->status()) {
+ switch (iloader_.status()) {
case WaitingToLoad:
case Loading:
case Converting:
case ErrorLoading:
case ErrorGeneratingPixmap:
case ErrorUnknown:
- //lyx::unlink(iloader_->filename());
+ //lyx::unlink(iloader_.filename());
ploader_.remove(snippet_);
break;
case Ready:
- lyx::unlink(iloader_->filename());
- ploader_.imageReady(parent_);
+ lyx::unlink(iloader_.filename());
+ ploader_.emitSignal(parent_);
break;
}
}