mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
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:
parent
482468dda6
commit
d25c74c0eb
@ -409,7 +409,6 @@ src_graphics_files = Split('''
|
||||
GraphicsCache.cpp
|
||||
GraphicsCacheItem.cpp
|
||||
GraphicsConverter.cpp
|
||||
GraphicsImage.cpp
|
||||
GraphicsLoader.cpp
|
||||
GraphicsParams.cpp
|
||||
PreviewImage.cpp
|
||||
|
@ -300,7 +300,6 @@ liblyxgraphics_la_SOURCES = \
|
||||
graphics/GraphicsConverter.h \
|
||||
graphics/GraphicsConverter.cpp \
|
||||
graphics/GraphicsImage.h \
|
||||
graphics/GraphicsImage.cpp \
|
||||
graphics/GraphicsLoader.h \
|
||||
graphics/GraphicsLoader.cpp \
|
||||
graphics/GraphicsParams.cpp \
|
||||
|
@ -693,10 +693,6 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
|
||||
|
||||
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(onLastWindowClosed()));
|
||||
|
||||
using namespace lyx::graphics;
|
||||
|
||||
Image::newImage = boost::bind(&GuiImage::newImage);
|
||||
|
||||
// needs to be done before reading lyxrc
|
||||
QWidget w;
|
||||
lyxrc.dpi = (w.logicalDpiX() + w.logicalDpiY()) / 2;
|
||||
|
@ -31,8 +31,8 @@ using namespace lyx::support;
|
||||
namespace lyx {
|
||||
namespace graphics {
|
||||
|
||||
/// Access to this class is through this static method.
|
||||
Image * GuiImage::newImage()
|
||||
/// Implement factory method defined in GraphicsImage.h
|
||||
Image * newImage()
|
||||
{
|
||||
return new GuiImage;
|
||||
}
|
||||
|
@ -24,8 +24,10 @@ namespace graphics {
|
||||
class GuiImage : public Image
|
||||
{
|
||||
public:
|
||||
/// Access to this class is through this static method.
|
||||
static Image * newImage();
|
||||
/// Access to the class is through newImage() and clone.
|
||||
GuiImage();
|
||||
///
|
||||
GuiImage(GuiImage const &);
|
||||
|
||||
/// Retrieve the rendered image.
|
||||
QImage const & image() const;
|
||||
@ -58,11 +60,6 @@ private:
|
||||
/// Scale the image using params.
|
||||
bool scale(Params const & params);
|
||||
|
||||
/// Access to the class is through newImage() and clone.
|
||||
GuiImage();
|
||||
///
|
||||
GuiImage(GuiImage const &);
|
||||
|
||||
/// The original loaded image.
|
||||
QImage original_;
|
||||
|
||||
|
@ -291,7 +291,7 @@ bool CacheItem::Impl::loadImage()
|
||||
{
|
||||
LYXERR(Debug::GRAPHICS, "Loading image.");
|
||||
|
||||
image_.reset(Image::newImage());
|
||||
image_.reset(newImage());
|
||||
|
||||
bool success = image_->load(file_to_load_);
|
||||
string const text = success ? "succeeded" : "failed";
|
||||
|
@ -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
|
@ -26,11 +26,6 @@
|
||||
|
||||
#include "Dimension.h"
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/signal.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace support { class FileName; }
|
||||
@ -41,11 +36,6 @@ class Params;
|
||||
|
||||
class Image {
|
||||
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() {}
|
||||
|
||||
@ -61,13 +51,6 @@ public:
|
||||
/// Is the image drawable ?
|
||||
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.
|
||||
* The caller should expect this process to be asynchronous and
|
||||
* so should connect to the "finished" signal above.
|
||||
@ -79,14 +62,11 @@ public:
|
||||
* Returns true if the pixmap is created.
|
||||
*/
|
||||
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 lyx
|
||||
|
Loading…
Reference in New Issue
Block a user