]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsLoader.C
Trivial fixes to some warnings thrown up by MSVS.Net 2003.
[lyx.git] / src / graphics / GraphicsLoader.C
index 5bfa5ac6ccee6b24948e89cf62019ce220bfcb25..bea847426a961b48801a6ea18cdfba1af9c67122 100644 (file)
@@ -5,35 +5,31 @@
  *
  * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "GraphicsLoader.h"
 
-#include "BufferView.h"
-
-#include "GraphicsCache.h"
 #include "GraphicsCacheItem.h"
 #include "GraphicsImage.h"
 #include "GraphicsParams.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>
 
-#include <list>
 
-namespace grfx {
+using std::string;
+
+
+namespace lyx {
+namespace graphics {
 
-struct Loader::Impl : boost::signals::trackable {
+class Loader::Impl : public boost::signals::trackable {
+public:
        ///
-       Impl(Params const &);
+       Impl();
        ///
        ~Impl();
        ///
@@ -42,9 +38,10 @@ struct Loader::Impl : boost::signals::trackable {
        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_;
@@ -55,7 +52,7 @@ struct Loader::Impl : boost::signals::trackable {
        /// We modify a local copy of the image once it is loaded.
        Image::ImagePtr image_;
        /// This signal is emitted when the image loading status changes.
-       boost::signal0<void> signal_;
+       boost::signal<void()> signal_;
 
 private:
        ///
@@ -65,39 +62,50 @@ private:
 
        ///
        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;
@@ -128,15 +136,7 @@ void Loader::startLoading() const
 {
        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();
 }
 
 
@@ -193,8 +193,8 @@ Image const * Loader::image() const
 }
 
 
-Loader::Impl::Impl(Params const & params)
-       : status_(WaitingToLoad), params_(params)
+Loader::Impl::Impl()
+       : status_(WaitingToLoad)
 {
 }
 
@@ -286,21 +286,14 @@ void Loader::Impl::createPixmap()
        }
 }
 
-
-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_);
 }
 
 
-} // namespace grfx
+} // namespace graphics
+} // namespace lyx