]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiClipboard.h
Fix handling of the add branch textfield in GuiBranches
[lyx.git] / src / frontends / qt4 / GuiClipboard.h
index 4bb808cda318b523d3e4ea3c6a81626287c1af0e..a6540f1ce8a15eef7bfcc90d7c6cbfa8309d982a 100644 (file)
 
 #include "frontends/Clipboard.h"
 
+#include <QMimeData>
 #include <QObject>
+#include <QStringList>
+
+#include <boost/cstdint.hpp>
 
 namespace lyx {
 namespace frontend {
 
+class QMacPasteboardMimeGraphics;
+
+/**
+ *  \class CacheMimeData 
+ * 
+ *  This class is used in order to query the clipboard only once on 
+ *  startup and once each time the contents of the clipboard changes.
+ */
+class CacheMimeData : public QMimeData
+{
+       Q_OBJECT
+public:
+       // LyX calls "on_dataChanged" on startup, so it is not necessary to
+       // query the clipboard here.
+       CacheMimeData()
+       {}
+
+       /// reads the clipboard and updates the cached_formats_
+       void update();
+       /// returns the cached list of formats supported by the object
+       virtual QStringList formats() const { return cached_formats_; }
+       /// reads the clipboard and returns the data
+       QByteArray data(QString const & mimeType) const;
+
+private:
+       /// the cached list of formats supported by the object
+       QStringList cached_formats_;
+};
+
+
 /**
  * The Qt4 version of the Clipboard.
  */
@@ -29,7 +63,6 @@ class GuiClipboard: public QObject, public Clipboard
        Q_OBJECT
 public:
        GuiClipboard();
-       virtual ~GuiClipboard();
 
        /** Clipboard overloaded methods
         */
@@ -40,6 +73,7 @@ public:
        void put(std::string const & lyx, docstring const & text);
        bool hasLyXContents() const;
        bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const;
+       bool hasTextContents() const;
        bool isInternal() const;
        bool hasInternal() const;
        bool empty() const;
@@ -55,8 +89,18 @@ private:
        bool text_clipboard_empty_;
        bool has_lyx_contents_;
        bool has_graphics_contents_;
+       /// the cached mime data used to describe the information
+       /// that can be stored in the clipboard
+       CacheMimeData cache_;
+       /// checksum for internal clipboard data (used on Mac) 
+       boost::uint32_t checksum;
 };
 
+QString const lyxMimeType();
+QString const pdfMimeType();
+QString const emfMimeType();
+QString const wmfMimeType();
+
 } // namespace frontend
 } // namespace lyx