Simplify image creation with a new factory function: newImage().

GraphicsImage: now a pure virtual interface.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26457 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-09-19 12:01:01 +00:00
parent 482468dda6
commit d25c74c0eb
8 changed files with 10 additions and 68 deletions

View File

@ -409,7 +409,6 @@ src_graphics_files = Split('''
GraphicsCache.cpp GraphicsCache.cpp
GraphicsCacheItem.cpp GraphicsCacheItem.cpp
GraphicsConverter.cpp GraphicsConverter.cpp
GraphicsImage.cpp
GraphicsLoader.cpp GraphicsLoader.cpp
GraphicsParams.cpp GraphicsParams.cpp
PreviewImage.cpp PreviewImage.cpp

View File

@ -300,7 +300,6 @@ liblyxgraphics_la_SOURCES = \
graphics/GraphicsConverter.h \ graphics/GraphicsConverter.h \
graphics/GraphicsConverter.cpp \ graphics/GraphicsConverter.cpp \
graphics/GraphicsImage.h \ graphics/GraphicsImage.h \
graphics/GraphicsImage.cpp \
graphics/GraphicsLoader.h \ graphics/GraphicsLoader.h \
graphics/GraphicsLoader.cpp \ graphics/GraphicsLoader.cpp \
graphics/GraphicsParams.cpp \ graphics/GraphicsParams.cpp \

View File

@ -693,10 +693,6 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(onLastWindowClosed())); connect(this, SIGNAL(lastWindowClosed()), this, SLOT(onLastWindowClosed()));
using namespace lyx::graphics;
Image::newImage = boost::bind(&GuiImage::newImage);
// needs to be done before reading lyxrc // needs to be done before reading lyxrc
QWidget w; QWidget w;
lyxrc.dpi = (w.logicalDpiX() + w.logicalDpiY()) / 2; lyxrc.dpi = (w.logicalDpiX() + w.logicalDpiY()) / 2;

View File

@ -31,8 +31,8 @@ using namespace lyx::support;
namespace lyx { namespace lyx {
namespace graphics { namespace graphics {
/// Access to this class is through this static method. /// Implement factory method defined in GraphicsImage.h
Image * GuiImage::newImage() Image * newImage()
{ {
return new GuiImage; return new GuiImage;
} }

View File

@ -24,8 +24,10 @@ namespace graphics {
class GuiImage : public Image class GuiImage : public Image
{ {
public: public:
/// Access to this class is through this static method. /// Access to the class is through newImage() and clone.
static Image * newImage(); GuiImage();
///
GuiImage(GuiImage const &);
/// Retrieve the rendered image. /// Retrieve the rendered image.
QImage const & image() const; QImage const & image() const;
@ -58,11 +60,6 @@ private:
/// Scale the image using params. /// Scale the image using params.
bool scale(Params const & params); bool scale(Params const & params);
/// Access to the class is through newImage() and clone.
GuiImage();
///
GuiImage(GuiImage const &);
/// The original loaded image. /// The original loaded image.
QImage original_; QImage original_;

View File

@ -291,7 +291,7 @@ bool CacheItem::Impl::loadImage()
{ {
LYXERR(Debug::GRAPHICS, "Loading image."); LYXERR(Debug::GRAPHICS, "Loading image.");
image_.reset(Image::newImage()); image_.reset(newImage());
bool success = image_->load(file_to_load_); bool success = image_->load(file_to_load_);
string const text = success ? "succeeded" : "failed"; string const text = success ? "succeeded" : "failed";

View File

@ -1,29 +0,0 @@
/**
* \file GraphicsImage.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Baruch Even
* \author Angus Leeming
* \author Herbert Voß
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "GraphicsImage.h"
#include "GraphicsParams.h"
#include "support/debug.h"
namespace lyx {
namespace graphics {
// This is to be connected to a function that will return a new
// instance of a viable derived class.
boost::function<Image *()> Image::newImage;
} // namespace graphics
} // namespace lyx

View File

@ -26,11 +26,6 @@
#include "Dimension.h" #include "Dimension.h"
#include <boost/function.hpp>
#include <boost/signal.hpp>
#include <vector>
namespace lyx { namespace lyx {
namespace support { class FileName; } namespace support { class FileName; }
@ -41,11 +36,6 @@ class Params;
class Image { class Image {
public: public:
/** This is to be connected to a function that will return a new
* instance of a viable derived class.
*/
static boost::function<Image *()> newImage;
/// ///
virtual ~Image() {} virtual ~Image() {}
@ -61,13 +51,6 @@ public:
/// Is the image drawable ? /// Is the image drawable ?
virtual bool isDrawable() const = 0; virtual bool isDrawable() const = 0;
/** At the end of the loading process inform the outside world
* by emitting a signal
*/
typedef boost::signal<void(bool)> SignalType;
///
SignalType finishedLoading;
/** Start loading the image file. /** Start loading the image file.
* The caller should expect this process to be asynchronous and * The caller should expect this process to be asynchronous and
* so should connect to the "finished" signal above. * so should connect to the "finished" signal above.
@ -79,14 +62,11 @@ public:
* Returns true if the pixmap is created. * Returns true if the pixmap is created.
*/ */
virtual bool setPixmap(Params const & params) = 0; virtual bool setPixmap(Params const & params) = 0;
protected:
/// Must define default c-tor explicitly as we define a copy c-tor.
Image() {}
/// Don't copy the signal finishedLoading
Image(Image const &) {}
}; };
/// Only way to create a new Image.
/// Implemented in the frontend.
Image * newImage();
} // namespace graphics } // namespace graphics
} // namespace lyx } // namespace lyx