]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiClipboard.h
Enable OK/Apply buttons when resetting to class defaults.
[lyx.git] / src / frontends / qt4 / GuiClipboard.h
1 // -*- C++ -*-
2 /**
3  * \file GuiClipboard.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUICLIPBOARD_H
15 #define GUICLIPBOARD_H
16
17 #include "frontends/Clipboard.h"
18
19 #include <QMimeData>
20 #include <QObject>
21 #include <QStringList>
22
23 #include <boost/cstdint.hpp>
24
25 namespace lyx {
26 namespace frontend {
27
28 class QMacPasteboardMimeGraphics;
29
30 /**
31  *  \class CacheMimeData
32  *
33  *  This class is used in order to query the clipboard only once on
34  *  startup and once each time the contents of the clipboard changes.
35  */
36 class CacheMimeData : public QMimeData
37 {
38         Q_OBJECT
39 public:
40         // LyX calls "on_dataChanged" on startup, so it is not necessary to
41         // query the clipboard here.
42         CacheMimeData()
43         {}
44
45         /// reads the clipboard and updates the cached_formats_
46         void update();
47         /// returns the cached list of formats supported by the object
48         virtual QStringList formats() const { return cached_formats_; }
49         /// reads the clipboard and returns the data
50         QByteArray data(QString const & mimeType) const;
51
52 private:
53         /// the cached list of formats supported by the object
54         QStringList cached_formats_;
55 };
56
57
58 /**
59  * The Qt4 version of the Clipboard.
60  */
61 class GuiClipboard: public QObject, public Clipboard
62 {
63         Q_OBJECT
64 public:
65         GuiClipboard();
66
67         /** Clipboard overloaded methods
68          */
69         //@{
70         std::string const getAsLyX() const;
71         support::FileName getAsGraphics(Cursor const & cur, GraphicsType type) const;
72         docstring const getAsText(TextType type) const;
73         void put(std::string const & text) const;
74         void put(std::string const & lyx, docstring const & html, docstring const & text);
75         bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const;
76         bool hasTextContents(TextType typetype = AnyTextType) const;
77         bool isInternal() const;
78         bool hasInternal() const;
79         bool empty() const;
80         //@}
81
82         support::FileName getPastedGraphicsFileName(Cursor const & cur,
83                 Clipboard::GraphicsType & type) const;
84
85 private Q_SLOTS:
86         void on_dataChanged();
87         void update();
88
89 private:
90         bool plaintext_clipboard_empty_;
91         bool has_text_contents_;
92         bool has_graphics_contents_;
93         /// the cached mime data used to describe the information
94         /// that can be stored in the clipboard
95         CacheMimeData cache_;
96         /// checksum for internal clipboard data (used on Mac)
97         boost::uint32_t checksum;
98 };
99
100 QString const lyxMimeType();
101 QString const pdfMimeType();
102 QString const emfMimeType();
103 QString const wmfMimeType();
104
105 } // namespace frontend
106 } // namespace lyx
107
108 #endif // GUICLIPBOARD_H