]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiImage.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiImage.cpp
index efa198bc69efb2137d6385108456ed7b4f425657..75c78a6ee8335b71db7728e7935a009e57a27dec 100644 (file)
 #include "GuiImage.h"
 #include "qt_helpers.h"
 
-#include "debug.h"
 #include "Format.h"
 
 #include "graphics/GraphicsParams.h"
 
+#include "support/debug.h"
 #include "support/FileName.h"
 #include "support/lstrings.h"       // ascii_lowercase
 
 #include <QImage>
 #include <QImageReader>
 
-#include <boost/bind.hpp>
-#include <boost/tuple/tuple.hpp>
-
-using lyx::support::ascii_lowercase;
-
-using boost::bind;
-
-using std::endl;
-using std::equal_to;
-using std::find_if;
-using std::string;
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 namespace graphics {
 
 /// Access to this class is through this static method.
-Image::ImagePtr GuiImage::newImage()
+Image * GuiImage::newImage()
 {
-       ImagePtr ptr;
-       ptr.reset(new GuiImage);
-       return ptr;
+       return new GuiImage;
 }
 
 
@@ -62,29 +51,24 @@ Image::FormatList GuiImage::loadableFormats()
        Formats::const_iterator begin = formats.begin();
        Formats::const_iterator end   = formats.end();
 
-
-//     LYXERR(Debug::GRAPHICS)
-//             << "D:/msys/home/yns/src/lyx-devel/lib/images/banner.png mis of format: "
-//             << fromqstr(Pic.pictureFormat("D:/msys/home/yns/src/lyx-devel/lib/images/banner.png"))
-//             << endl;
-//     if (Pic.pictureFormat("D:/msys/home/yns/src/lyx-devel/lib/images/banner.png"))
-//             LYXERR(Debug::GRAPHICS)
-//                     << "pictureFormat not returned NULL\n" << endl;
-//                     << "Supported formats are: " << Pic.inputFormats() << endl;
+       //LYXERR(Debug::GRAPHICS,
+       //      "D:/msys/home/yns/src/lyx-devel/lib/images/banner.png mis of format: "
+       //      << fromqstr(Pic.pictureFormat("D:/msys/.../banner.png")))
+       //if (Pic.pictureFormat("D:/msys/.../banner.png"))
+       //      LYXERR(Debug::GRAPHICS, "pictureFormat not returned NULL\n"
+       //              << "Supported formats are: " << Pic.inputFormats());
 
        QList<QByteArray> qt_formats = QImageReader::supportedImageFormats();
 
-       LYXERR(Debug::GRAPHICS)
-               << "\nThe image loader can load the following directly:\n";
+       LYXERR(Debug::GRAPHICS,
+               "\nThe image loader can load the following directly:\n");
 
-       if (qt_formats.empty()) {
-               LYXERR(Debug::GRAPHICS)
-                       << "\nQt4 Problem: No Format available!" << endl;
-       }
+       if (qt_formats.empty())
+               LYXERR(Debug::GRAPHICS, "\nQt4 Problem: No Format available!");
 
        for (QList<QByteArray>::const_iterator it = qt_formats.begin(); it != qt_formats.end(); ++it) {
 
-               LYXERR(Debug::GRAPHICS) << (const char *) *it << ", ";
+               LYXERR(Debug::GRAPHICS, (const char *) *it << ", ");
 
                string ext = ascii_lowercase((const char *) *it);
 
@@ -92,28 +76,24 @@ Image::FormatList GuiImage::loadableFormats()
                if (ext == "jpeg")
                        ext = "jpg";
 
-               Formats::const_iterator fit =
-                       find_if(begin, end,
-                               bind(equal_to<string>(),
-                                    bind(&Format::extension, _1),
-                                    ext));
-               if (fit != end)
-                       fmts.push_back(fit->name());
+               for (Formats::const_iterator fit = begin; fit != end; ++fit) 
+                       if (fit->extension() == ext) {
+                               fmts.push_back(fit->name());
+                               break;
+                       }
        }
 
        if (lyxerr.debugging()) {
-               LYXERR(Debug::GRAPHICS)
-                       << "\nOf these, LyX recognises the following formats:\n";
+               LYXERR(Debug::GRAPHICS, "Of these, LyX recognises the following formats:");
 
                FormatList::const_iterator fbegin = fmts.begin();
                FormatList::const_iterator fend   = fmts.end();
                for (FormatList::const_iterator fit = fbegin; fit != fend; ++fit) {
-                       if (fit != fbegin) {
-                               LYXERR(Debug::GRAPHICS) << ", ";
-                       }
-                       LYXERR(Debug::GRAPHICS) << *fit;
+                       if (fit != fbegin)
+                               LYXERR(Debug::GRAPHICS, ", ");
+                       LYXERR(Debug::GRAPHICS, *fit);
                }
-               LYXERR(Debug::GRAPHICS) << '\n' << endl;
+               LYXERR(Debug::GRAPHICS, '\n');
        }
 
        return fmts;
@@ -127,36 +107,34 @@ GuiImage::GuiImage(GuiImage const & other)
 {}
 
 
-Image * GuiImage::clone_impl() const
+Image * GuiImage::clone() const
 {
        return new GuiImage(*this);
 }
 
 
-unsigned int GuiImage::getWidth_impl() const
+unsigned int GuiImage::width() const
 {
        return transformed_.width();
 }
 
 
-unsigned int GuiImage::getHeight_impl() const
+unsigned int GuiImage::height() const
 {
        return transformed_.height();
 }
 
 
-void GuiImage::load_impl(support::FileName const & filename)
+void GuiImage::load(FileName const & filename)
 {
        if (!original_.isNull()) {
-               LYXERR(Debug::GRAPHICS)
-                       << "Image is loaded already!" << endl;
+               LYXERR(Debug::GRAPHICS, "Image is loaded already!");
                finishedLoading(false);
                return;
        }
 
        if (!original_.load(toqstr(filename.absFilename()))) {
-               LYXERR(Debug::GRAPHICS)
-                       << "Unable to open image" << endl;
+               LYXERR(Debug::GRAPHICS, "Unable to open image");
                finishedLoading(false);
                return;
        }
@@ -186,7 +164,7 @@ static QImage & toGray(QImage & img)
 }
 
 
-bool GuiImage::setPixmap_impl(Params const & params)
+bool GuiImage::setPixmap(Params const & params)
 {
        if (original_.isNull() || params.display == NoDisplay)
                return false;
@@ -211,7 +189,7 @@ bool GuiImage::setPixmap_impl(Params const & params)
 }
 
 
-void GuiImage::clip_impl(Params const & params)
+void GuiImage::clip(Params const & params)
 {
        if (transformed_.isNull())
                return;
@@ -242,7 +220,7 @@ void GuiImage::clip_impl(Params const & params)
 }
 
 
-void GuiImage::rotate_impl(Params const & params)
+void GuiImage::rotate(Params const & params)
 {
        if (transformed_.isNull())
                return;
@@ -257,20 +235,18 @@ void GuiImage::rotate_impl(Params const & params)
 }
 
 
-void GuiImage::scale_impl(Params const & params)
+void GuiImage::scale(Params const & params)
 {
        if (transformed_.isNull())
                return;
 
-       unsigned int width;
-       unsigned int height;
-       boost::tie(width, height) = getScaledDimensions(params);
+       Dimension dim = scaledDimension(params);
 
-       if (width == getWidth() && height == getHeight())
+       if (dim.width() == width() && dim.height() == height())
                return;
 
        QMatrix m;
-       m.scale(double(width) / getWidth(), double(height) / getHeight());
+       m.scale(double(dim.width()) / width(), double(dim.height()) / height());
        transformed_ = transformed_.transformed(m);
 }