#include "GraphicsLoader.h"
-#include "BufferView.h"
-
#include "GraphicsCache.h"
#include "GraphicsCacheItem.h"
#include "GraphicsImage.h"
#include "LoaderQueue.h"
#include "frontends/LyXView.h"
-#include "frontends/Timeout.h"
-#include <boost/weak_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/signals/trackable.hpp>
struct Loader::Impl : boost::signals::trackable {
///
- Impl(Params const &);
+ Impl();
///
~Impl();
///
void resetParams(Params const &);
///
void createPixmap();
-
///
- void startLoading(Inset const &, BufferView const &);
+ void startLoading();
+ ///
+ Params const & params() const { return params_; }
/// The loading status of the image.
ImageStatus status_;
///
Params params_;
- // Multiple Insets can share the same image
- typedef std::list<Inset const *> InsetList;
- ///
- InsetList insets;
- ///
- boost::weak_ptr<BufferView const> view;
};
Loader::Loader()
- : pimpl_(new Impl(Params()))
+ : pimpl_(new Impl)
{}
Loader::Loader(string const & file, DisplayType type)
- : pimpl_(new Impl(Params()))
+ : pimpl_(new Impl)
{
reset(file, type);
}
Loader::Loader(string const & file, Params const & params)
- : pimpl_(new Impl(params))
+ : pimpl_(new Impl)
{
reset(file, params);
}
+Loader::Loader(Loader const & other)
+ : pimpl_(new Impl)
+{
+ Params const & params = other.pimpl_->params();
+ reset(params.filename, params);
+}
+
+
Loader::~Loader()
{}
+Loader & Loader::operator=(Loader const & other)
+{
+ if (this != &other) {
+ Params const & params = other.pimpl_->params();
+ reset(params.filename, params);
+ }
+ return *this;
+}
+
+
void Loader::reset(string const & file, DisplayType type) const
{
Params params;
{
if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_.get())
return;
- pimpl_->cached_item_->startLoading();
-}
-
-
-void Loader::startLoading(Inset const & inset, BufferView const & bv) const
-{
- if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_.get())
- return;
- pimpl_->startLoading(inset, bv);
+ pimpl_->startLoading();
}
}
-Loader::Impl::Impl(Params const & params)
- : status_(WaitingToLoad), params_(params)
+Loader::Impl::Impl()
+ : status_(WaitingToLoad)
{
}
}
}
-
-void Loader::Impl::startLoading(Inset const & inset, BufferView const & bv)
+void Loader::Impl::startLoading()
{
if (status_ != WaitingToLoad)
return;
- InsetList::const_iterator it = insets.begin();
- InsetList::const_iterator end = insets.end();
- it = std::find(it, end, &inset);
- if (it == end)
- insets.push_back(&inset);
- view = bv.owner()->view();
-
LoaderQueue::get().touch(cached_item_);
}