]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiClipboard.h
Move the buffer related part from GuiView::renameBuffer to Buffer::saveAs.
[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 namespace lyx {
24 namespace frontend {
25
26 class QMacPasteboardMimeGraphics;
27
28 /**
29  *  \class CacheMimeData 
30  * 
31  *  This class is used in order to query the clipboard only once on 
32  *  startup and once each time the contents of the clipboard changes.
33  */
34 class CacheMimeData : public QMimeData
35 {
36         Q_OBJECT
37 public:
38         // LyX calls "on_dataChanged" on startup, so it is not necessary to
39         // query the clipboard here.
40         CacheMimeData()
41         {}
42
43         /// reads the clipboard and updates the cached_formats_
44         void update();
45         /// returns the cached list of formats supported by the object
46         virtual QStringList formats() const { return cached_formats_; }
47         /// reads the clipboard and returns the data
48         QByteArray data(QString const & mimeType) const;
49
50 private:
51         /// the cached list of formats supported by the object
52         QStringList cached_formats_;
53 };
54
55
56 /**
57  * The Qt4 version of the Clipboard.
58  */
59 class GuiClipboard: public QObject, public Clipboard
60 {
61         Q_OBJECT
62 public:
63         GuiClipboard();
64
65         /** Clipboard overloaded methods
66          */
67         //@{
68         std::string const getAsLyX() const;
69         FileName getAsGraphics(Cursor const & cur, GraphicsType type) const;
70         docstring const getAsText() const;
71         void put(std::string const & lyx, docstring const & text);
72         bool hasLyXContents() const;
73         bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const;
74         bool hasTextContents() const;
75         bool isInternal() const;
76         bool hasInternal() const;
77         bool empty() const;
78         //@}
79
80         FileName getPastedGraphicsFileName(Cursor const & cur,
81                 Clipboard::GraphicsType & type) const;
82
83 private Q_SLOTS:
84         void on_dataChanged();
85
86 private:
87         bool text_clipboard_empty_;
88         bool has_lyx_contents_;
89         bool has_graphics_contents_;
90         /// the cached mime data used to describe the information
91         /// that can be stored in the clipboard
92         CacheMimeData cache_;
93 };
94
95 QString const lyxMimeType();
96 QString const pdfMimeType();
97 QString const emfMimeType();
98 QString const wmfMimeType();
99
100 } // namespace frontend
101 } // namespace lyx
102
103 #endif // GUICLIPBOARD_H