1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #ifndef _U2_ANNOTATED_DNA_VIEW_CLIPBOARD_H_
23 #define _U2_ANNOTATED_DNA_VIEW_CLIPBOARD_H_
24 
25 #include <QAction>
26 
27 #include <U2Core/U2Region.h>
28 
29 namespace U2 {
30 
31 class AnnotatedDNAView;
32 class LRegionsSelection;
33 class Annotation;
34 class AnnotationSelection;
35 class ADVSequenceObjectContext;
36 class ADVSequenceWidget;
37 
38 class U2VIEW_EXPORT ADVClipboard : public QObject {
39     Q_OBJECT
40 public:
41     ADVClipboard(AnnotatedDNAView *ctx);
42 
43     QAction *getCopySequenceAction() const;
44     QAction *getCopyComplementAction() const;
45     QAction *getCopyTranslationAction() const;
46     QAction *getCopyComplementTranslationAction() const;
47 
48     QAction *getCopyAnnotationSequenceAction() const;
49     QAction *getCopyAnnotationSequenceTranslationAction() const;
50 
51     QAction *getCopyQualifierAction() const;
52     QAction *getPasteSequenceAction() const;
53 
54     ADVSequenceObjectContext *getSequenceContext() const;
55 
56     void addCopyMenu(QMenu *m);
57 
58     void connectSequence(ADVSequenceObjectContext *s);
59 
60     static QAction *createPasteSequenceAction(QObject *parent);
61 
62 public slots:
63 
64     void sl_onDNASelectionChanged(LRegionsSelection *s, const QVector<U2Region> &added, const QVector<U2Region> &removed);
65     void sl_onAnnotationSelectionChanged(AnnotationSelection *s, const QList<Annotation *> &added, const QList<Annotation *> &removed);
66 
67     /** Calls 'updateState' to handle new active sequence correctly. */
68     void sl_onActiveSequenceChanged();
69 
70     void sl_copySequence();
71     void sl_copyComplementSequence();
72     void sl_copyTranslation();
73     void sl_copyComplementTranslation();
74 
75     void sl_copyAnnotationSequence();
76     void sl_copyAnnotationSequenceTranslation();
77 
78     void sl_setCopyQualifierActionStatus(bool isEnabled, QString text);
79 
80 private:
81     void updateActions();
82     void copySequenceSelection(bool complement, bool amino);
83     void copyAnnotationSelection(bool amino);
84     void putIntoClipboard(const QString &data);
85 
86     AnnotatedDNAView *ctx;
87     QAction *copySequenceAction;
88     QAction *copyComplementSequenceAction;
89     QAction *copyTranslationAction;
90     QAction *copyComplementTranslationAction;
91 
92     QAction *copyAnnotationSequenceAction;
93     QAction *copyAnnotationSequenceTranslationAction;
94 
95     QAction *copyQualifierAction;
96 
97     QAction *pasteSequenceAction;
98 
99     static const QString COPY_FAILED_MESSAGE;
100 };
101 
102 }  // namespace U2
103 
104 #endif
105