]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsCacheItem.cpp
Embedding: display a pin at the top left corner of embedded figures
[lyx.git] / src / graphics / GraphicsCacheItem.cpp
index 83bf09d289a0b88d09c716dc07705daa0b8ba33f..2960ae6002d84484c244acb718edeb3b733d7bc6 100644 (file)
 #include "GraphicsImage.h"
 
 #include "ConverterCache.h"
-#include "debug.h"
+#include "support/debug.h"
 #include "Format.h"
 
+#include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/FileMonitor.h"
-#include "support/lyxlib.h"
 
 #include <boost/bind.hpp>
 
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
-using support::FileMonitor;
-using support::FileName;
-using support::makeDisplayPath;
-using support::onlyFilename;
-using support::tempName;
-using support::unlink;
-using support::unzipFile;
-
-using std::endl;
-using std::string;
-
-
 namespace graphics {
 
 class CacheItem::Impl : public boost::signals::trackable {
@@ -224,11 +214,11 @@ void CacheItem::Impl::reset()
 {
        zipped_ = false;
        if (!unzipped_filename_.empty())
-               unlink(unzipped_filename_);
+               unzipped_filename_.removeFile();
        unzipped_filename_.erase();
 
        if (remove_loaded_file_ && !file_to_load_.empty())
-               unlink(file_to_load_);
+               file_to_load_.removeFile();
        remove_loaded_file_ = false;
        file_to_load_.erase();
        to_.erase();
@@ -269,14 +259,14 @@ void CacheItem::Impl::imageConverted(bool success)
        converter_.reset();
        cc_.disconnect();
 
-       success = !file_to_load_.empty() && file_to_load_.isFileReadable();
+       success = !file_to_load_.empty() && file_to_load_.isReadableFile();
 
        if (!success) {
                LYXERR(Debug::GRAPHICS, "Unable to find converted file!");
                setStatus(ErrorConverting);
 
                if (zipped_)
-                       unlink(unzipped_filename_);
+                       unzipped_filename_.removeFile();
 
                return;
        }
@@ -311,10 +301,10 @@ void CacheItem::Impl::imageLoaded(bool success)
 
        // Clean up after loading.
        if (zipped_)
-               unlink(unzipped_filename_);
+               unzipped_filename_.removeFile();
 
        if (remove_loaded_file_ && unzipped_filename_ != file_to_load_)
-               unlink(file_to_load_);
+               file_to_load_.removeFile();
 
        cl_.disconnect();
 
@@ -370,7 +360,7 @@ void CacheItem::Impl::convertToDisplayFormat()
        setStatus(Converting);
 
        // First, check that the file exists!
-       if (!filename_.isFileReadable()) {
+       if (!filename_.isReadableFile()) {
                if (status_ != ErrorNoFile) {
                        setStatus(ErrorNoFile);
                        LYXERR(Debug::GRAPHICS, "\tThe file is not readable");
@@ -382,7 +372,8 @@ void CacheItem::Impl::convertToDisplayFormat()
        FileName filename;
        zipped_ = filename_.isZippedFile();
        if (zipped_) {
-               unzipped_filename_ = tempName(FileName(), filename_.toFilesystemEncoding());
+               unzipped_filename_ = FileName::tempName(
+                       filename_.toFilesystemEncoding());
                if (unzipped_filename_.empty()) {
                        setStatus(ErrorConverting);
                        LYXERR(Debug::GRAPHICS, "\tCould not create temporary file.");
@@ -425,12 +416,12 @@ void CacheItem::Impl::convertToDisplayFormat()
 
        // Add some stuff to create a uniquely named temporary file.
        // This file is deleted in loadImage after it is loaded into memory.
-       FileName const to_file_base(tempName(FileName(), "CacheItem"));
+       FileName const to_file_base = FileName::tempName("CacheItem");
        remove_loaded_file_ = true;
 
        // Remove the temp file, we only want the name...
        // FIXME: This is unsafe!
-       unlink(to_file_base);
+       to_file_base.removeFile();
 
        // Connect a signal to this->imageConverted and pass this signal to
        // the graphics converter so that we can load the modified file