Debian Codegraph @

avogadro/qtplugins/copypaste/copypaste.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_QTPLUGINS_COPYPASTE_H
7 #define AVOGADRO_QTPLUGINS_COPYPASTE_H
8
9 #include <avogadro/core/avogadrocore.h>
10 #include <avogadro/qtgui/extensionplugin.h>
11
12 #include <QtGui/QIcon>
13
14 namespace Avogadro {
15 namespace Io {
16 class FileFormat;
17 }
18
19 namespace QtPlugins {
20
21 /**
22 * @brief The CopyPaste class allows interaction with the system clipboard.
23 */
24 class CopyPaste : public QtGui::ExtensionPlugin
25 {
26 Q_OBJECT
27 public:
28 explicit CopyPaste(QObject* parent_ = nullptr);
29 ~CopyPaste() override;
30
31 QString name() const override { return tr("Copy and paste"); }
32
33 QString description() const override
34 {
35 return tr("Interact with the clipboard.");
36 }
37
38 QList<QAction*> actions() const override;
39
40 QStringList menuPath(QAction* action) const override;
41
42 public slots:
43 void setMolecule(QtGui::Molecule* mol) override;
44
45 private slots:
46 bool copy(
47 Io::FileFormat* format); // returns bool so cut can reuse implementation.
48 bool copyCJSON();
49 void copySMILES();
50 void copyInChI();
51 void copyXYZ();
52 void cut();
53 void paste();
54 void clear();
55
56 private:
57 // Cached between emitting moleculeReady() and calling readMolecule().
58 QByteArray m_pastedData;
59 Io::FileFormat* m_pastedFormat;
60
61 QtGui::Molecule* m_molecule;
62
63 QAction* m_copyAction;
64 QAction* m_copySMILES;
65 QAction* m_copyInChI;
66 QAction* m_copyXYZ;
67 QAction* m_cutAction;
68 QAction* m_clearAction;
69 QAction* m_pasteAction;
70 };
71
72 } // namespace QtPlugins
73 } // namespace Avogadro
74
75 #endif // AVOGADRO_QTPLUGINS_COPYPASTE_H