// -*- C++ -*-
/**
* \file PreviewedInset.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 <leeming@lyx.org>
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include <config.h>
#include "PreviewedInset.h"
#include <boost/bind.hpp>
+#include "debug.h" // temporary
namespace grfx {
}
+BufferView * PreviewedInset::view() const
+{
+ return inset_.view();
+}
+
+
void PreviewedInset::generatePreview()
{
if (!Previews::activated() || !previewWanted() ||
if (!Previews::activated() || !previewWanted())
return;
- setView(ploader.buffer().getUser());
-
snippet_ = trim(latexString());
if (snippet_.empty())
return;
}
+void PreviewedInset::removePreview()
+{
+ if (!view() || !view()->buffer() || snippet_.empty())
+ return;
+
+ grfx::Previews & previews = grfx::Previews::get();
+ grfx::PreviewLoader & loader = previews.loader(view()->buffer());
+ loader.remove(snippet_);
+ snippet_.erase();
+ pimage_ = 0;
+}
+
+
bool PreviewedInset::previewReady() const
{
if (!Previews::activated() || !previewWanted() ||
if (!pimage_)
return false;
- return pimage_->image(inset_, *view());
+ return pimage_->image();
}
-void PreviewedInset::setView(BufferView * bv)
-{
- if (!bv)
- return;
-
- view_ = bv->owner()->view();
-}
-
void PreviewedInset::imageReady(grfx::PreviewImage const & pimage) const
{
// Check snippet against the Inset's current contents